ykl7 commited on
Commit
f8c2a86
·
1 Parent(s): d4e577f

add exception log

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -16,14 +16,17 @@ st.caption("Team UMBC-SBU-UT")
16
  def safe_parse_json(model_answer):
17
  """.."""
18
  try:
19
- return json.loads(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
  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}")
 
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}")