Meet Patel commited on
Commit
efc786d
·
2 Parent(s): ff522ab 795f7b7

Refactor: Update Gradio app initialization to use create_gradio_interface function

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -447,18 +447,18 @@ async def on_generate_learning_path(student_id, concept_ids, student_level):
447
  "student_level": student_level
448
  })
449
  if hasattr(result, 'content') and isinstance(result.content, list):
450
- for item in result.content:
451
  if hasattr(item, 'text') and item.text:
452
  try:
453
  lp_data = json.loads(item.text)
454
  return lp_data
455
  except Exception:
456
  return {"raw_pretty": json.dumps(item.text, indent=2)}
457
- if isinstance(result, dict):
458
- return result
459
- if isinstance(result, str):
460
  try:
461
- return json.loads(result)
462
  except Exception:
463
  return {"raw_pretty": json.dumps(result, indent=2)}
464
  return {"raw_pretty": json.dumps(str(result), indent=2)}
 
447
  "student_level": student_level
448
  })
449
  if hasattr(result, 'content') and isinstance(result.content, list):
450
+ for item in response.content:
451
  if hasattr(item, 'text') and item.text:
452
  try:
453
  lp_data = json.loads(item.text)
454
  return lp_data
455
  except Exception:
456
  return {"raw_pretty": json.dumps(item.text, indent=2)}
457
+ if isinstance(response, dict):
458
+ return response
459
+ if isinstance(response, str):
460
  try:
461
+ return json.loads(response)
462
  except Exception:
463
  return {"raw_pretty": json.dumps(result, indent=2)}
464
  return {"raw_pretty": json.dumps(str(result), indent=2)}