LiamKhoaLe commited on
Commit
470975e
·
1 Parent(s): d9bd342
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -274,15 +274,15 @@ async def create_classroom(payload: ClassroomRequest = Body(...)):
274
  """
275
  raw = gemini_flash_completion(prompt).strip()
276
 
277
- # ---------- Attempt to parse JSON ----------
278
- try:
279
- timetable_json = json.loads(raw)
280
- except json.JSONDecodeError:
281
- logger.warning("Gemini returned invalid JSON; sending raw text.")
282
- return JSONResponse(content={"classroom_id": payload.id, "timetable_raw": raw})
283
- # Ensure id is echoed (fallback if model forgot)
284
- timetable_json["classroom_id"] = payload.id
285
- return JSONResponse(content=timetable_json)
286
 
287
 
288
 
 
274
  """
275
  raw = gemini_flash_completion(prompt).strip()
276
 
277
+ # ---------- Attempt to parse JSON ----------
278
+ try:
279
+ timetable_json = json.loads(raw)
280
+ except json.JSONDecodeError:
281
+ logger.warning("Gemini returned invalid JSON; sending raw text.")
282
+ return JSONResponse(content={"classroom_id": payload.id, "timetable_raw": raw})
283
+ # Ensure id is echoed (fallback if model forgot)
284
+ timetable_json["classroom_id"] = payload.id
285
+ return JSONResponse(content=timetable_json)
286
 
287
 
288