diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 17:21:10 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 17:21:10 +0100 |
commit | 7953560303ad82f13f3d4c910db1193da21b11d7 (patch) | |
tree | e88b25bcc756e02741ea1875fcf62ff9ba76b975 /g4f/Provider/FreeChatgpt.py | |
parent | Fix isssue with stop in client (diff) | |
download | gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.gz gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.bz2 gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.lz gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.xz gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.zst gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.zip |
Diffstat (limited to 'g4f/Provider/FreeChatgpt.py')
-rw-r--r-- | g4f/Provider/FreeChatgpt.py | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/g4f/Provider/FreeChatgpt.py b/g4f/Provider/FreeChatgpt.py index 0f993690..8981ef79 100644 --- a/g4f/Provider/FreeChatgpt.py +++ b/g4f/Provider/FreeChatgpt.py @@ -4,24 +4,13 @@ import json, random from aiohttp import ClientSession from ..typing import AsyncResult, Messages -from .base_provider import AsyncGeneratorProvider +from .base_provider import AsyncGeneratorProvider, ProviderModelMixin -models = { - "claude-v2": "claude-2.0", - "claude-v2.1":"claude-2.1", - "gemini-pro": "google-gemini-pro" -} -urls = [ - "https://free.chatgpt.org.uk", - "https://ai.chatgpt.org.uk" -] - -class FreeChatgpt(AsyncGeneratorProvider): +class FreeChatgpt(AsyncGeneratorProvider, ProviderModelMixin): url = "https://free.chatgpt.org.uk" working = True - supports_gpt_35_turbo = True - supports_gpt_4 = True supports_message_history = True + default_model = "google-gemini-pro" @classmethod async def create_async_generator( @@ -31,11 +20,6 @@ class FreeChatgpt(AsyncGeneratorProvider): proxy: str = None, **kwargs ) -> AsyncResult: - if model in models: - model = models[model] - elif not model: - model = "gpt-3.5-turbo" - url = random.choice(urls) headers = { "Accept": "application/json, text/event-stream", "Content-Type":"application/json", @@ -51,16 +35,15 @@ class FreeChatgpt(AsyncGeneratorProvider): } async with ClientSession(headers=headers) as session: data = { - "messages":messages, - "stream":True, - "model":model, - "temperature":0.5, - "presence_penalty":0, - "frequency_penalty":0, - "top_p":1, - **kwargs + "messages": messages, + "stream": True, + "model": cls.get_model(""), + "temperature": kwargs.get("temperature", 0.5), + "presence_penalty": kwargs.get("presence_penalty", 0), + "frequency_penalty": kwargs.get("frequency_penalty", 0), + "top_p": kwargs.get("top_p", 1) } - async with session.post(f'{url}/api/openai/v1/chat/completions', json=data, proxy=proxy) as response: + async with session.post(f'{cls.url}/api/openai/v1/chat/completions', json=data, proxy=proxy) as response: response.raise_for_status() started = False async for line in response.content: |