Merge pull request #27 from R0m1k3/dev

Dev
This commit is contained in:
LogiFlow authored and GitHub committed 2025-10-04 14:51:05 +02:00
commit 752055c9cd
6 files changed
+25 -7

No files matched your search

-4
View File
@@ -26,10 +26,6 @@ externalPort = 3000
localPort = 43245 localPort = 43245
externalPort = 3001 externalPort = 3001
[[ports]]
localPort = 46341
externalPort = 3003
[env] [env]
PORT = "5000" PORT = "5000"
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

+25 -3
View File
@@ -50,10 +50,18 @@ export class OpenRouterService {
}); });
if (!response.ok) { if (!response.ok) {
const errorText = await response.text();
console.error('OpenRouter API Error Response:', errorText);
throw new Error(`OpenRouter API error: ${response.status} ${response.statusText}`); throw new Error(`OpenRouter API error: ${response.status} ${response.statusText}`);
} }
const data = await response.json(); const data = await response.json();
if (!data.choices || !data.choices[0]) {
console.error('Invalid OpenRouter response - no choices:', { hasChoices: !!data.choices, model: config.model });
throw new Error('Réponse invalide de l\'API OpenRouter. Vérifiez votre clé API et votre modèle.');
}
const content = data.choices[0]?.message?.content || ""; const content = data.choices[0]?.message?.content || "";
return this.parseGeneratedText(content); return this.parseGeneratedText(content);
@@ -90,9 +98,23 @@ VERSION 3 - ÉMOTIONNELLE:
private parseGeneratedText(content: string): GeneratedText[] { private parseGeneratedText(content: string): GeneratedText[] {
const variants: GeneratedText[] = []; const variants: GeneratedText[] = [];
const version1Match = content.match(/VERSION 1 - DYNAMIQUE:\s*\n([\s\S]*?)(?=VERSION 2|$)/i); // Normaliser les retours à la ligne (CRLF -> LF)
const version2Match = content.match(/VERSION 2 - INFORMATIVE:\s*\n([\s\S]*?)(?=VERSION 3|$)/i); const normalizedContent = content.replace(/\r\n/g, '\n');
const version3Match = content.match(/VERSION 3 - ÉMOTIONNELLE:\s*\n([\s\S]*?)$/i);
console.log('🔍 AI Response to parse (first 800 chars):\n', normalizedContent.substring(0, 800));
console.log('🔍 AI Response length:', normalizedContent.length);
// Regex ultra-flexibles acceptant:
// - markdown (** optionnel)
// - tirets variés (-, –, —)
// - espaces variables
// - deux-points optionnel
// - séparateurs (---, ***, etc.)
const version1Match = normalizedContent.match(/\*{0,2}\s*VERSION\s+1\s*[-–—]\s*DYNAMIQUE\s*\*{0,2}:?\s*[\r\n]+([\s\S]*?)(?=\s*[-*]{3,}\s*[\r\n]+|\*{0,2}\s*VERSION\s+2|$)/i);
const version2Match = normalizedContent.match(/\*{0,2}\s*VERSION\s+2\s*[-–—]\s*INFORMATIVE?\s*\*{0,2}:?\s*[\r\n]+([\s\S]*?)(?=\s*[-*]{3,}\s*[\r\n]+|\*{0,2}\s*VERSION\s+3|$)/i);
const version3Match = normalizedContent.match(/\*{0,2}\s*VERSION\s+3\s*[-–—]\s*[ÉE]MOTIONNELLE?\s*\*{0,2}:?\s*[\r\n]+([\s\S]*?)$/i);
console.log('🔍 Matches found:', { v1: !!version1Match, v2: !!version2Match, v3: !!version3Match });
if (version1Match) { if (version1Match) {
const text = version1Match[1].trim(); const text = version1Match[1].trim();