summaryrefslogtreecommitdiffstats
path: root/g4f/requests
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-05 21:00:35 +0200
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-05 21:00:35 +0200
commit1e2cf48cbac7e8fa13882f41e023a67fd9f286b7 (patch)
treeb4ab92cd92c386b86cdeea1b4d80d3eec43eb02f /g4f/requests
parentFix Gemini Proxy Connect call failed (#1768) (diff)
downloadgpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.tar
gpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.tar.gz
gpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.tar.bz2
gpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.tar.lz
gpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.tar.xz
gpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.tar.zst
gpt4free-1e2cf48cbac7e8fa13882f41e023a67fd9f286b7.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}")