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

XFEstudio/gpt4free

Fix load json in DeepInfra

0b4c6247
Heiner Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +3 -7
Modified g4f/Provider/DeepInfra.py +3 -7
@@ -60,17 +60,13 @@ class DeepInfra(AsyncGeneratorProvider):
60 60 async for line in response.iter_lines():
61 61 if not line.startswith(b"data: "):
62 62 continue
63
64 63 try:
65 decoded_line = line.decode().lstrip("data: ")
66 json_line = json.loads(decoded_line)
67
64 json_line = json.loads(line[6:])
68 65 choices = json_line.get("choices", [{}])
69 finish_reason = choices[0].get("finish_reason", "")
66 finish_reason = choices[0].get("finish_reason")
70 67 if finish_reason:
71 68 break
72 token = choices[0].get("delta", {}).get("content", "")
73
69 token = choices[0].get("delta", {}).get("content")
74 70 if token:
75 71 if first:
76 72 token = token.lstrip()