Spaces:
Sleeping
Sleeping
add exception log
Browse files
app.py
CHANGED
@@ -16,14 +16,17 @@ st.caption("Team UMBC-SBU-UT")
|
|
16 |
def safe_parse_json(model_answer):
|
17 |
""".."""
|
18 |
try:
|
19 |
-
|
|
|
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 |
-
|
|
|
|
|
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}")
|
|
|
16 |
def safe_parse_json(model_answer):
|
17 |
""".."""
|
18 |
try:
|
19 |
+
parsed_answer = json.loads(model_answer)
|
20 |
+
return parsed_answer
|
21 |
except json.JSONDecodeError as e:
|
22 |
print("Failed to parse JSON: %s", e)
|
23 |
print(f"Raw model answer is: {model_answer}")
|
24 |
model_answer = model_answer.replace("```json", "")
|
25 |
model_answer = model_answer.replace("```", "")
|
26 |
try:
|
27 |
+
parsed_answer = json.loads(model_answer)
|
28 |
+
print(f"Hit parsing error but cleaned json as markdown code snippet and it can be parsed now")
|
29 |
+
return parsed_answer
|
30 |
except json.JSONDecodeError as e:
|
31 |
print("Failed to parse JSON: %s", e)
|
32 |
print(f"Tried to parse cleaned model answer which was: {model_answer}")
|