diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-08-31 08:47:39 +0200 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-08-31 08:47:39 +0200 |
commit | f1683c8db83cee5805a6e103fca2c2551aae5086 (patch) | |
tree | 44712b453191566e7ce0877d43a3ed2f807d78b6 /g4f/Provider/FreeChatgpt.py | |
parent | Merge pull request #2206 from Parthsadaria/patch-1 (diff) | |
download | gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.tar gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.tar.gz gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.tar.bz2 gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.tar.lz gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.tar.xz gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.tar.zst gpt4free-f1683c8db83cee5805a6e103fca2c2551aae5086.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/FreeChatgpt.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/g4f/Provider/FreeChatgpt.py b/g4f/Provider/FreeChatgpt.py index 6485ced2..20487594 100644 --- a/g4f/Provider/FreeChatgpt.py +++ b/g4f/Provider/FreeChatgpt.py @@ -10,19 +10,16 @@ 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", @@ -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 |