summaryrefslogtreecommitdiffstats
path: root/g4f/requests
diff options
context:
space:
mode:
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}")