diff --git a/supabase/functions/analyze-essay/index.ts b/supabase/functions/analyze-essay/index.ts index eb5b1a5..c064af1 100644 --- a/supabase/functions/analyze-essay/index.ts +++ b/supabase/functions/analyze-essay/index.ts @@ -155,7 +155,52 @@ Responda em formato JSON seguindo exatamente esta estrutura: content: prompt } ], - response_format: { type: "json_object" } + response_format: { + type: "json_schema", + json_schema: { + type: "object", + name: "EssayAnalysis", + schema: { + type: "object", + schema: { + type: "object", + additionalProperties: false, + properties: { + overall_score: { type: "number" }, + feedback: { + type: "object", + additionalProperties: false, + properties: { + structure: { type: "string" }, + content: { type: "string" }, + language: { type: "string" } + } + }, + strengths: { + type: "array", + items: { type: "string" } + }, + improvements: { + type: "array", + items: { type: "string" } + }, + suggestions: { type: "string" }, + criteria_scores: { + type: "object", + additionalProperties: false, + properties: { + adequacy: { type: "number" }, + coherence: { type: "number" }, + cohesion: { type: "number" }, + vocabulary: { type: "number" }, + grammar: { type: "number" } + } + } + } + } + } + } + } }); const analysis: EssayAnalysisResponse = JSON.parse(completion.choices[0].message.content)