From 1e2cf48cbac7e8fa13882f41e023a67fd9f286b7 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Fri, 5 Apr 2024 21:00:35 +0200 Subject: Add authless OpenaiChat --- g4f/requests/raise_for_status.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'g4f/requests') diff --git a/g4f/requests/raise_for_status.py b/g4f/requests/raise_for_status.py index 9e8e141c..0e91505e 100644 --- a/g4f/requests/raise_for_status.py +++ b/g4f/requests/raise_for_status.py @@ -13,12 +13,17 @@ class CloudflareError(ResponseStatusError): def is_cloudflare(text: str) -> bool: return '
' in text or "Just a moment..." in text +def is_openai(text: str) -> bool: + return "

Unable to load site

" in text + async def raise_for_status_async(response: Union[StreamResponse, ClientResponse], message: str = None): if response.status in (429, 402): raise RateLimitError(f"Response {response.status}: Rate limit reached") message = await response.text() if not response.ok and message is None else message if response.status == 403 and is_cloudflare(message): raise CloudflareError(f"Response {response.status}: Cloudflare detected") + elif response.status == 403 and is_openai(message): + raise ResponseStatusError(f"Response {response.status}: Bot are detected") elif not response.ok: raise ResponseStatusError(f"Response {response.status}: {message}") -- cgit v1.2.3