feat: Handle alternate JSON format delimiter in read_json function

- Modified `read_json` function in `copilot.py`
- Added handling for alternate text delimiter `"\n\n---\n\n"` when extracting JSON content
This commit is contained in:
hlohaus 2025-05-29 04:17:33 +02:00
parent c6fead0313
commit 919308a7a8

View file

@ -67,6 +67,8 @@ def read_json(text: str) -> dict:
match = re.search(r"```(json|)\n(?P<code>[\S\s]+?)\n```", text)
if match:
text = match.group("code")
else:
text = text.split("\n\n---\n\n")[0]
try:
return json.loads(text.strip())
except json.JSONDecodeError: