Spaces:
Running
Running
Refactor: Update Gradio app initialization to use create_gradio_interface function
Browse files
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
|
| 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(
|
| 458 |
-
return
|
| 459 |
-
if isinstance(
|
| 460 |
try:
|
| 461 |
-
return json.loads(
|
| 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)}
|