summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/FreeGpt.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-03-12 02:06:06 +0100
committerGitHub <noreply@github.com>2024-03-12 02:06:06 +0100
commit6ef282de3a3245acbfecd08ae48dba85ff91d031 (patch)
tree0236c9678eea8f9c78ed7c09f3d86eaf3d7c691c /g4f/Provider/FreeGpt.py
parentUpdate .gitignore (diff)
downloadgpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.tar
gpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.tar.gz
gpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.tar.bz2
gpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.tar.lz
gpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.tar.xz
gpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.tar.zst
gpt4free-6ef282de3a3245acbfecd08ae48dba85ff91d031.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/FreeGpt.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/g4f/Provider/FreeGpt.py b/g4f/Provider/FreeGpt.py
index 15232c8d..9c210f0b 100644
--- a/g4f/Provider/FreeGpt.py
+++ b/g4f/Provider/FreeGpt.py
@@ -5,15 +5,18 @@ import time, hashlib, random
from ..typing import AsyncResult, Messages
from ..requests import StreamSession
from .base_provider import AsyncGeneratorProvider
+from ..errors import RateLimitError
domains = [
- 'https://s.aifree.site'
+ "https://s.aifree.site",
+ "https://v.aifree.site/"
]
class FreeGpt(AsyncGeneratorProvider):
- url = "https://freegpts1.aifree.site/"
- working = False
+ url = "https://freegptsnav.aifree.site"
+ working = True
supports_message_history = True
+ supports_system_message = True
supports_gpt_35_turbo = True
@classmethod
@@ -38,15 +41,14 @@ class FreeGpt(AsyncGeneratorProvider):
"pass": None,
"sign": generate_signature(timestamp, prompt)
}
- url = random.choice(domains)
- async with session.post(f"{url}/api/generate", json=data) as response:
+ domain = random.choice(domains)
+ async with session.post(f"{domain}/api/generate", json=data) as response:
response.raise_for_status()
async for chunk in response.iter_content():
chunk = chunk.decode()
if chunk == "当前地区当日额度已消耗完":
- raise RuntimeError("Rate limit reached")
+ raise RateLimitError("Rate limit reached")
yield chunk
-
def generate_signature(timestamp: int, message: str, secret: str = ""):
data = f"{timestamp}:{message}:{secret}"