mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Improve AI response parsing by adding more flexible regex and logging
Add console logs to `server/services/openrouter.ts` to aid in debugging AI response parsing, specifically for different versions (1, 2, 3) of AI-generated content. Enhance regex flexibility for recognizing version separators and content. 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
eb0ea6f14f
commit
468394022c
1 file changed
+5
@@ -101,6 +101,9 @@ VERSION 3 - ÉMOTIONNELLE:
|
||||
// Normaliser les retours à la ligne (CRLF -> LF)
|
||||
const normalizedContent = content.replace(/\r\n/g, '\n');
|
||||
|
||||
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 (-, –, —)
|
||||
@@ -110,6 +113,8 @@ 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 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) {
|
||||
const text = version1Match[1].trim();
|
||||
|
||||
Reference in new issue
Block a user