返回提交历史
Added
g4f/client/helper.py
+16
-0
XFEstudio/gpt4free
Update client
912dc634
代码差异
1 个文件
+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