Spaces:
Running
Running
add parse exception
Browse files
app.py
CHANGED
@@ -20,6 +20,13 @@ def safe_parse_json(model_answer):
|
|
20 |
except json.JSONDecodeError as e:
|
21 |
print("Failed to parse JSON: %s", e)
|
22 |
print(f"Raw model answer is: {model_answer}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return None
|
24 |
|
25 |
def check_password():
|
|
|
20 |
except json.JSONDecodeError as e:
|
21 |
print("Failed to parse JSON: %s", e)
|
22 |
print(f"Raw model answer is: {model_answer}")
|
23 |
+
model_answer = model_answer.replace("```json", "")
|
24 |
+
model_answer = model_answer.replace("```", "")
|
25 |
+
try:
|
26 |
+
return json.loads(model_answer)
|
27 |
+
except json.JSONDecodeError as e:
|
28 |
+
print("Failed to parse JSON: %s", e)
|
29 |
+
print(f"Tried to parse cleaned model answer which was: {model_answer}")
|
30 |
return None
|
31 |
|
32 |
def check_password():
|