summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/ChatForAi.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider/ChatForAi.py')
-rw-r--r--g4f/Provider/ChatForAi.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/g4f/Provider/ChatForAi.py b/g4f/Provider/ChatForAi.py
index 5aa728a1..1c693955 100644
--- a/g4f/Provider/ChatForAi.py
+++ b/g4f/Provider/ChatForAi.py
@@ -5,7 +5,7 @@ import hashlib
import uuid
from ..typing import AsyncResult, Messages
-from ..requests import StreamSession
+from ..requests import StreamSession, raise_for_status
from ..errors import RateLimitError
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
@@ -54,13 +54,11 @@ class ChatForAi(AsyncGeneratorProvider, ProviderModelMixin):
"sign": generate_signature(timestamp, "", conversation_id)
}
async with session.post(f"{cls.url}/api/handle/provider-openai", json=data) as response:
- if response.status == 429:
- raise RateLimitError("Rate limit reached")
- response.raise_for_status()
+ await raise_for_status(response)
async for chunk in response.iter_content():
if b"https://chatforai.store" in chunk:
- raise RuntimeError(f"Response: {chunk.decode()}")
- yield chunk.decode()
+ raise RuntimeError(f"Response: {chunk.decode(errors='ignore')}")
+ yield chunk.decode(errors="ignore")
def generate_signature(timestamp: int, message: str, id: str):