summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/FreeChatgpt.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g4f/Provider/FreeChatgpt.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/g4f/Provider/FreeChatgpt.py b/g4f/Provider/FreeChatgpt.py
index 6485ced2..a9dc0f56 100644
--- a/g4f/Provider/FreeChatgpt.py
+++ b/g4f/Provider/FreeChatgpt.py
@@ -10,25 +10,22 @@ class FreeChatgpt(AsyncGeneratorProvider, ProviderModelMixin):
url = "https://chat.chatgpt.org.uk"
api_endpoint = "/api/openai/v1/chat/completions"
working = True
- supports_gpt_35_turbo = True
- default_model = 'gpt-3.5-turbo'
+ default_model = '@cf/qwen/qwen1.5-14b-chat-awq'
models = [
- 'gpt-3.5-turbo',
- 'SparkDesk-v1.1',
- 'deepseek-coder',
'@cf/qwen/qwen1.5-14b-chat-awq',
- 'deepseek-chat',
+ 'SparkDesk-v1.1',
'Qwen2-7B-Instruct',
'glm4-9B-chat',
'chatglm3-6B',
'Yi-1.5-9B-Chat',
]
+
model_aliases = {
"qwen-1.5-14b": "@cf/qwen/qwen1.5-14b-chat-awq",
"sparkdesk-v1.1": "SparkDesk-v1.1",
- "qwen2-7b": "Qwen2-7B-Instruct",
- "glm4-9b": "glm4-9B-chat",
- "chatglm3-6b": "chatglm3-6B",
+ "qwen-2-7b": "Qwen2-7B-Instruct",
+ "glm-4-9b": "glm4-9B-chat",
+ "glm-3-6b": "chatglm3-6B",
"yi-1.5-9b": "Yi-1.5-9B-Chat",
}
@@ -40,7 +37,7 @@ class FreeChatgpt(AsyncGeneratorProvider, ProviderModelMixin):
return cls.model_aliases[model.lower()]
else:
return cls.default_model
-
+
@classmethod
async def create_async_generator(
cls,
@@ -49,6 +46,8 @@ class FreeChatgpt(AsyncGeneratorProvider, ProviderModelMixin):
proxy: str = None,
**kwargs
) -> AsyncResult:
+ model = cls.get_model(model)
+
headers = {
"accept": "application/json, text/event-stream",
"accept-language": "en-US,en;q=0.9",
@@ -64,7 +63,6 @@ class FreeChatgpt(AsyncGeneratorProvider, ProviderModelMixin):
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
}
- model = cls.get_model(model)
async with ClientSession(headers=headers) as session:
prompt = format_prompt(messages)
data = {
@@ -93,6 +91,6 @@ class FreeChatgpt(AsyncGeneratorProvider, ProviderModelMixin):
chunk = json.loads(line_str[6:])
delta_content = chunk.get("choices", [{}])[0].get("delta", {}).get("content", "")
accumulated_text += delta_content
- yield delta_content
+ yield delta_content # Yield each chunk of content
except json.JSONDecodeError:
pass