summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-23 17:21:10 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-23 17:21:10 +0100
commit7953560303ad82f13f3d4c910db1193da21b11d7 (patch)
treee88b25bcc756e02741ea1875fcf62ff9ba76b975 /g4f
parentFix isssue with stop in client (diff)
downloadgpt4free-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 '')
-rw-r--r--g4f/Provider/FreeChatgpt.py39
-rw-r--r--g4f/Provider/GeminiProChat.py1
-rw-r--r--g4f/models.py10
3 files changed, 16 insertions, 34 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:
diff --git a/g4f/Provider/GeminiProChat.py b/g4f/Provider/GeminiProChat.py
index 488f5f0e..8b8fc5dc 100644
--- a/g4f/Provider/GeminiProChat.py
+++ b/g4f/Provider/GeminiProChat.py
@@ -11,7 +11,6 @@ from .base_provider import AsyncGeneratorProvider
class GeminiProChat(AsyncGeneratorProvider):
url = "https://gemini-chatbot-sigma.vercel.app"
working = True
- supports_gpt_35_turbo = True
@classmethod
async def create_async_generator(
diff --git a/g4f/models.py b/g4f/models.py
index f5951a29..bf58ff25 100644
--- a/g4f/models.py
+++ b/g4f/models.py
@@ -99,31 +99,31 @@ gpt_4_turbo = Model(
llama2_7b = Model(
name = "meta-llama/Llama-2-7b-chat-hf",
- base_provider = 'huggingface',
+ base_provider = 'meta',
best_provider = RetryProvider([Llama2, DeepInfra])
)
llama2_13b = Model(
name = "meta-llama/Llama-2-13b-chat-hf",
- base_provider = 'huggingface',
+ base_provider = 'meta',
best_provider = RetryProvider([Llama2, DeepInfra])
)
llama2_70b = Model(
name = "meta-llama/Llama-2-70b-chat-hf",
- base_provider = "huggingface",
+ base_provider = "meta",
best_provider = RetryProvider([Llama2, DeepInfra, HuggingChat, PerplexityLabs])
)
codellama_34b_instruct = Model(
name = "codellama/CodeLlama-34b-Instruct-hf",
- base_provider = "huggingface",
+ base_provider = "meta",
best_provider = RetryProvider([HuggingChat, PerplexityLabs, DeepInfra])
)
codellama_70b_instruct = Model(
name = "codellama/CodeLlama-70b-Instruct-hf",
- base_provider = "huggingface",
+ base_provider = "meta",
best_provider = DeepInfra
)