summaryrefslogtreecommitdiffstats
path: root/g4f/requests
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-05 21:03:12 +0200
committerGitHub <noreply@github.com>2024-04-05 21:03:12 +0200
commitc791012b218667e1449e1224014f05213fb1fc9c (patch)
treeb4ab92cd92c386b86cdeea1b4d80d3eec43eb02f /g4f/requests
parentFix Gemini Proxy Connect call failed (#1768) (diff)
parentAdd authless OpenaiChat (diff)
downloadgpt4free-0.2.8.0.tar
gpt4free-0.2.8.0.tar.gz
gpt4free-0.2.8.0.tar.bz2
gpt4free-0.2.8.0.tar.lz
gpt4free-0.2.8.0.tar.xz
gpt4free-0.2.8.0.tar.zst
gpt4free-0.2.8.0.zip
Diffstat (limited to 'g4f/requests')
-rw-r--r--g4f/requests/raise_for_status.py5
1 files changed, 5 insertions, 0 deletions
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 '<div id="cf-please-wait">' in text or "<title>Just a moment...</title>" in text
+def is_openai(text: str) -> bool:
+ return "<p>Unable to load site</p>" 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}")