Lashtw commited on
Commit
eef5011
·
verified ·
1 Parent(s): aec1781

Upload 10 files

Browse files
Files changed (1) hide show
  1. src/services/gemini.js +8 -1
src/services/gemini.js CHANGED
@@ -190,7 +190,14 @@ ${entries}
190
 
191
  try {
192
  const messages = [{ role: "user", parts: [{ text: fullPrompt }] }];
193
- const text = await callGeminiAPI(messages, true); // JSON Mode = true
 
 
 
 
 
 
 
194
  return JSON.parse(text);
195
  } catch (e) {
196
  console.error("AI Evaluation Failed", e);
 
190
 
191
  try {
192
  const messages = [{ role: "user", parts: [{ text: fullPrompt }] }];
193
+ let text = await callGeminiAPI(messages, true); // JSON Mode = true
194
+
195
+ // Strip markdown code block if present (```json ... ```)
196
+ text = text.trim();
197
+ if (text.startsWith("```")) {
198
+ text = text.replace(/^```(?:json)?\s*\n?/, '').replace(/\n?```\s*$/, '');
199
+ }
200
+
201
  return JSON.parse(text);
202
  } catch (e) {
203
  console.error("AI Evaluation Failed", e);