bpHigh commited on
Commit
0b81e37
·
1 Parent(s): 359e0bf

Add codefence utils

Browse files
Files changed (1) hide show
  1. utils/utils.py +4 -1
utils/utils.py CHANGED
@@ -14,7 +14,10 @@ def parse_json_codefences(text: str) -> List[Any]:
14
  json_str = match.group(1).strip()
15
  try:
16
  data = json.loads(json_str)
17
- results.append(data)
 
 
 
18
  except json.JSONDecodeError as e:
19
  print(f"⚠️ Failed to parse JSON block:\n{json_str}\nError: {e}")
20
  return results
 
14
  json_str = match.group(1).strip()
15
  try:
16
  data = json.loads(json_str)
17
+ if isinstance(data, list):
18
+ results.extend(data)
19
+ else:
20
+ results.append(data)
21
  except json.JSONDecodeError as e:
22
  print(f"⚠️ Failed to parse JSON block:\n{json_str}\nError: {e}")
23
  return results