Spaces:
Sleeping
Sleeping
Update llm_utils.py
Browse files- llm_utils.py +7 -1
llm_utils.py
CHANGED
|
@@ -56,7 +56,13 @@ def explain_with_llm(solution_text, equation_type, llm_url, yaml_path="theorems.
|
|
| 56 |
)
|
| 57 |
|
| 58 |
if response.status_code == 200:
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
else:
|
| 61 |
return f"❌ LLM request failed: {response.status_code}"
|
| 62 |
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
if response.status_code == 200:
|
| 59 |
+
res_json = response.json()
|
| 60 |
+
if isinstance(res_json, dict):
|
| 61 |
+
return res_json.get("explanation", "❌ No explanation returned.")
|
| 62 |
+
elif isinstance(res_json, list) and len(res_json) > 0:
|
| 63 |
+
return res_json[0]
|
| 64 |
+
else:
|
| 65 |
+
return "❌ LLM response was empty or invalid."
|
| 66 |
else:
|
| 67 |
return f"❌ LLM request failed: {response.status_code}"
|
| 68 |
|