diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-04-06 23:41:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-06 23:41:42 +0200 |
commit | cab64a7fb4b9f1ca651c2fda3a64b1cd2b3c9f82 (patch) | |
tree | 3bdc28d0baf08619078be475f9065e47f5aa5bd4 /g4f/Provider | |
parent | Update Aura.py (diff) | |
download | gpt4free-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 'g4f/Provider')
-rw-r--r-- | g4f/Provider/ChatForAi.py | 10 |
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): |