返回提交历史
Modified
g4f/Provider/FreeGpt.py
+4
-1
Modified
g4f/Provider/NoowAi.py
+2
-0
XFEstudio/gpt4free
Add rate limit error messages
78f93bb7
代码差异
2 个文件
+6
-1
@@ -41,7 +41,10 @@ class FreeGpt(AsyncGeneratorProvider):
41
41
async with session.post(f"{url}/api/generate", json=data) as response:
42
42
response.raise_for_status()
43
43
async for chunk in response.iter_content():
44
yield chunk.decode()
44
chunk = chunk.decode()
45
if chunk == "当前地区当日额度已消耗完":
46
raise RuntimeError("Rate limit reached")
47
yield chunk
45
48
46
49
@classmethod
47
50
@property
@@ -61,6 +61,8 @@ class NoowAi(AsyncGeneratorProvider):
61
61
yield line["data"]
62
62
elif line["type"] == "end":
63
63
break
64
elif line["type"] == "error":
65
raise RuntimeError(line["data"])
64
66
65
67
def random_string(length: int = 10):
66
68
return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length))