XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Update client

912dc634
H Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +16 -0
Added g4f/client/helper.py +16 -0
@@ -0,0 +1,16 @@
1 import re
2
3 def read_json(text: str) -> dict:
4 """
5 Parses JSON code block from a string.
6
7 Args:
8 text (str): A string containing a JSON code block.
9
10 Returns:
11 dict: A dictionary parsed from the JSON code block.
12 """
13 match = re.search(r"```(json|)\n(?P<code>[\S\s]+?)\n```", text)
14 if match:
15 return match.group("code")
16 return text