summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-06 23:41:42 +0200
committerGitHub <noreply@github.com>2024-04-06 23:41:42 +0200
commitcab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82 (patch)
tree3bdc28d0baf08619078be475f9065e47f5aa5bd4 /g4f/Provider
parentUpdate Aura.py (diff)
downloadgpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.tar
gpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.tar.gz
gpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.tar.bz2
gpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.tar.lz
gpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.tar.xz
gpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.tar.zst
gpt4free-cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82.zip
Diffstat (limited to '')
-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):