mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-05 18:20:35 -08:00
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:
parent
c6fead0313
commit
919308a7a8
1 changed files with 2 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue