XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Update FreeGpt.py

ce92e598
H Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +5 -5
Modified g4f/Provider/FreeGpt.py +5 -5
@@ -3,7 +3,7 @@ from __future__ import annotations
3 3 import time, hashlib, random
4 4
5 5 from ..typing import AsyncResult, Messages
6 from ..requests import StreamSession
6 from ..requests import StreamSession, raise_for_status
7 7 from .base_provider import AsyncGeneratorProvider
8 8 from ..errors import RateLimitError
9 9
@@ -29,9 +29,9 @@ class FreeGpt(AsyncGeneratorProvider):
29 29 **kwargs
30 30 ) -> AsyncResult:
31 31 async with StreamSession(
32 impersonate="chrome107",
32 impersonate="chrome",
33 33 timeout=timeout,
34 proxies={"https": proxy}
34 proxies={"all": proxy}
35 35 ) as session:
36 36 prompt = messages[-1]["content"]
37 37 timestamp = int(time.time())
@@ -43,9 +43,9 @@ class FreeGpt(AsyncGeneratorProvider):
43 43 }
44 44 domain = random.choice(domains)
45 45 async with session.post(f"{domain}/api/generate", json=data) as response:
46 response.raise_for_status()
46 await raise_for_status(response)
47 47 async for chunk in response.iter_content():
48 chunk = chunk.decode()
48 chunk = chunk.decode(errors="ignore")
49 49 if chunk == "当前地区当日额度已消耗完":
50 50 raise RateLimitError("Rate limit reached")
51 51 yield chunk