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

XFEstudio/gpt4free

~ |

trying to improve compability with python versions < 3.8

d4c8f3e8
abc <98614666+xtekky@users.noreply.github.com>
提交于

代码差异

5 个文件 +13 -12
Modified g4f/Provider/AItianhu.py +3 -4
@@ -71,12 +71,11 @@ class AItianhu(AsyncGeneratorProvider):
71 71
72 72 if "detail" not in line:
73 73 raise RuntimeError(f"Response: {line}")
74 if content := line["detail"]["choices"][0]["delta"].get(
75 "content"
76 ):
74
75 content = line["detail"]["choices"][0]["delta"].get("content")
76 if content:
77 77 yield content
78 78
79
80 79 @classmethod
81 80 @property
82 81 def params(cls):
Modified g4f/Provider/GptForLove.py +2 -3
@@ -55,9 +55,8 @@ class GptForLove(AsyncGeneratorProvider):
55 55 except:
56 56 raise RuntimeError(f"Broken line: {line}")
57 57 if "detail" in line:
58 if content := line["detail"]["choices"][0]["delta"].get(
59 "content"
60 ):
58 content = line["detail"]["choices"][0]["delta"].get("content")
59 if content:
61 60 yield content
62 61 elif "10分钟内提问超过了5次" in line:
63 62 raise RuntimeError("Rate limit reached")
Modified g4f/Provider/GptGo.py +3 -1
@@ -62,7 +62,9 @@ class GptGo(AsyncGeneratorProvider):
62 62 line = json.loads(line[len(start):-1])
63 63 if line["choices"][0]["finish_reason"] == "stop":
64 64 break
65 if content := line["choices"][0]["delta"].get("content"):
65
66 content = line["choices"][0]["delta"].get("content"):
67 if content:
66 68 yield content
67 69
68 70
Modified g4f/Provider/Ylokh.py +2 -3
@@ -50,9 +50,8 @@ class Ylokh(AsyncGeneratorProvider):
50 50 if line.startswith("data: [DONE]"):
51 51 break
52 52 line = json.loads(line[6:])
53 if content := line["choices"][0]["delta"].get(
54 "content"
55 ):
53 content = line["choices"][0]["delta"].get("content")
54 if content:
56 55 yield content
57 56 else:
58 57 chat = await response.json()
Modified g4f/Provider/deprecated/Ails.py +3 -1
@@ -69,7 +69,9 @@ class Ails(AsyncGeneratorProvider):
69 69 if line.startswith(start) and line != "data: [DONE]":
70 70 line = line[len(start):-1]
71 71 line = json.loads(line)
72 if token := line["choices"][0]["delta"].get("content"):
72 token = line["choices"][0]["delta"].get("content")
73
74 if token:
73 75 if "ai.ls" in token or "ai.ci" in token:
74 76 raise Exception(f"Response Error: {token}")
75 77 yield token