mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Improve error handling and remove unnecessary logs in AI content generation
Refactor OpenRouterService error handling for invalid responses and remove debug console logs from AI content generation service. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/sEXz3DF
This commit is contained in:
1 parent
a0d519dec0
commit
85fdea3f30
4 files changed
+5
-11
No files matched your search
@@ -22,6 +22,10 @@ externalPort = 3002
|
|||||||
localPort = 40537
|
localPort = 40537
|
||||||
externalPort = 3000
|
externalPort = 3000
|
||||||
|
|
||||||
|
[[ports]]
|
||||||
|
localPort = 41317
|
||||||
|
externalPort = 3003
|
||||||
|
|
||||||
[[ports]]
|
[[ports]]
|
||||||
localPort = 43245
|
localPort = 43245
|
||||||
externalPort = 3001
|
externalPort = 3001
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 149 KiB |
@@ -56,10 +56,9 @@ export class OpenRouterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log('OpenRouter API Response:', JSON.stringify(data, null, 2));
|
|
||||||
|
|
||||||
if (!data.choices || !data.choices[0]) {
|
if (!data.choices || !data.choices[0]) {
|
||||||
console.error('Invalid OpenRouter response structure:', data);
|
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.');
|
throw new Error('Réponse invalide de l\'API OpenRouter. Vérifiez votre clé API et votre modèle.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,9 +101,6 @@ VERSION 3 - ÉMOTIONNELLE:
|
|||||||
// Normaliser les retours à la ligne (CRLF -> LF)
|
// Normaliser les retours à la ligne (CRLF -> LF)
|
||||||
const normalizedContent = content.replace(/\r\n/g, '\n');
|
const normalizedContent = content.replace(/\r\n/g, '\n');
|
||||||
|
|
||||||
// Debug: Logger le contenu pour diagnostiquer les échecs de parsing
|
|
||||||
console.log('📝 AI Generated Content (first 500 chars):', normalizedContent.substring(0, 500));
|
|
||||||
|
|
||||||
// Regex ultra-flexibles acceptant:
|
// Regex ultra-flexibles acceptant:
|
||||||
// - markdown (** optionnel)
|
// - markdown (** optionnel)
|
||||||
// - tirets variés (-, –, —)
|
// - tirets variés (-, –, —)
|
||||||
@@ -114,12 +110,6 @@ VERSION 3 - ÉMOTIONNELLE:
|
|||||||
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 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 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);
|
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('🔍 Regex matches:', {
|
|
||||||
version1: !!version1Match,
|
|
||||||
version2: !!version2Match,
|
|
||||||
version3: !!version3Match
|
|
||||||
});
|
|
||||||
|
|
||||||
if (version1Match) {
|
if (version1Match) {
|
||||||
const text = version1Match[1].trim();
|
const text = version1Match[1].trim();
|
||||||
|
|||||||
Reference in new issue
Block a user