completion
This commit is contained in:
@@ -138,13 +138,14 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
|
||||
let questions;
|
||||
try {
|
||||
// Clean up the response and parse JSON
|
||||
const cleanedContent = aiContent
|
||||
// Clean up the response and parse JSON
|
||||
console.log('[DEBUG-ENHANCE]Raw AI content:', aiContent);
|
||||
const cleanedContent = aiContent
|
||||
.replace(/^```json\s*/i, '')
|
||||
.replace(/\s*```\s*$/, '')
|
||||
.trim();
|
||||
|
||||
questions = JSON.parse(cleanedContent);
|
||||
console.log('[DEBUG-ENHANCE]Cleaned content:', cleanedContent);
|
||||
questions = JSON.parse(cleanedContent);
|
||||
|
||||
if (!Array.isArray(questions) || questions.length === 0) {
|
||||
throw new Error('Invalid questions format');
|
||||
|
||||
Reference in New Issue
Block a user