summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
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