| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- const fs = require('fs');
- const content = fs.readFileSync('temp/rich-outline-fail_57_1779014691106.txt', 'utf-8');
- const marker = '========== AI 原始响应 ';
- const markerIdx = content.indexOf(marker);
- const headerEndIdx = content.indexOf(' ==========', markerIdx);
- const aiStart = content.indexOf('\n', headerEndIdx) + 1;
- const aiEnd = content.indexOf('\n\n', aiStart);
- const aiResponse = content.substring(aiStart, aiEnd);
- console.log('Response length:', aiResponse.length);
- // The error is at position 523, char at 523 is "{"
- // The snippet shows: ..."呼吸"},{number":2,"title":
- // Wait - let me look more carefully at the actual bytes
- // At 520 we have " (quote, closing keyTakeaway string)
- // At 521 we have } (closing the parent object)
- // At 522 we have , (comma)
- // At 523 we have { (opening a new object)
- // At 524-529 we have number (but it should be "number")
- // At 530 we have "
- // At 531 we have :
- // At 532 we have 2
- // So the AI returned: ...呼吸"},{number":2,...
- // But properly formatted JSON would be: ...呼吸"},{"number":2,...
- // The issue is there's a missing quote BEFORE "number"
- // Let's check if this is a truncation or an AI generation error
- // by looking at what's around pos 523 more carefully
- console.log('\nContext around pos 523 (200 chars before and after):');
- console.log(JSON.stringify(aiResponse.substring(323, 623)));
- // Check the last 200 chars
- console.log('\nLast 200 chars:');
- console.log(JSON.stringify(aiResponse.substring(aiResponse.length - 200)));
- // Count all occurrences of ",{" to see if there's a pattern
- let count = 0;
- let idx = aiResponse.indexOf(',{');
- while (idx !== -1) { count++; idx = aiResponse.indexOf(',{', idx + 1); }
- console.log('\nOccurrences of ",{":', count);
- // Count all occurrences of number": without opening quote
- const badPattern = /,\{number":/g;
- const matches = aiResponse.match(badPattern);
- console.log('Bad pattern ",{number":":', matches ? matches.length : 0);
- // The issue: there's NO space after the comma, it's ","{number":2"
- // That's a JSON error - missing quote before "number"
- // This is likely an AI generation error, not truncation
|