summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/FreeGpt.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-06 23:18:44 +0200
committerGitHub <noreply@github.com>2024-04-06 23:18:44 +0200
commitce92e598a08998e55c6e39e9b178920d56b952f3 (patch)
tree5bf4544169d0ab407f5fc0667239609bf7725243 /g4f/Provider/FreeGpt.py
parentUpdate async.py (diff)
downloadgpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.tar
gpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.tar.gz
gpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.tar.bz2
gpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.tar.lz
gpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.tar.xz
gpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.tar.zst
gpt4free-ce92e598a08998e55c6e39e9b178920d56b952f3.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/FreeGpt.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/g4f/Provider/FreeGpt.py b/g4f/Provider/FreeGpt.py
index 9c210f0b..f79f0a66 100644
--- a/g4f/Provider/FreeGpt.py
+++ b/g4f/Provider/FreeGpt.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import time, hashlib, random
from ..typing import AsyncResult, Messages
-from ..requests import StreamSession
+from ..requests import StreamSession, raise_for_status
from .base_provider import AsyncGeneratorProvider
from ..errors import RateLimitError
@@ -29,9 +29,9 @@ class FreeGpt(AsyncGeneratorProvider):
**kwargs
) -> AsyncResult:
async with StreamSession(
- impersonate="chrome107",
+ impersonate="chrome",
timeout=timeout,
- proxies={"https": proxy}
+ proxies={"all": proxy}
) as session:
prompt = messages[-1]["content"]
timestamp = int(time.time())
@@ -43,9 +43,9 @@ class FreeGpt(AsyncGeneratorProvider):
}
domain = random.choice(domains)
async with session.post(f"{domain}/api/generate", json=data) as response:
- response.raise_for_status()
+ await raise_for_status(response)
async for chunk in response.iter_content():
- chunk = chunk.decode()
+ chunk = chunk.decode(errors="ignore")
if chunk == "当前地区当日额度已消耗完":
raise RateLimitError("Rate limit reached")
yield chunk