mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
6 files changed
+25
-7
No files matched your search
@@ -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"
|
||||||
|
|
||||||
|
|||||||
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 |
@@ -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();
|
||||||
|
|||||||
Reference in new issue
Block a user