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

XFEstudio/gpt4free

Update ChatForAi.py

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

代码差异

1 个文件 +4 -6
Modified g4f/Provider/ChatForAi.py +4 -6
@@ -5,7 +5,7 @@ import hashlib
5 5 import uuid
6 6
7 7 from ..typing import AsyncResult, Messages
8 from ..requests import StreamSession
8 from ..requests import StreamSession, raise_for_status
9 9 from ..errors import RateLimitError
10 10 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
11 11
@@ -54,13 +54,11 @@ class ChatForAi(AsyncGeneratorProvider, ProviderModelMixin):
54 54 "sign": generate_signature(timestamp, "", conversation_id)
55 55 }
56 56 async with session.post(f"{cls.url}/api/handle/provider-openai", json=data) as response:
57 if response.status == 429:
58 raise RateLimitError("Rate limit reached")
59 response.raise_for_status()
57 await raise_for_status(response)
60 58 async for chunk in response.iter_content():
61 59 if b"https://chatforai.store" in chunk:
62 raise RuntimeError(f"Response: {chunk.decode()}")
63 yield chunk.decode()
60 raise RuntimeError(f"Response: {chunk.decode(errors='ignore')}")
61 yield chunk.decode(errors="ignore")
64 62
65 63
66 64 def generate_signature(timestamp: int, message: str, id: str):