From c617b18d12c2f9d82ce7c73aae46d353b83f625a Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 1 Jan 2024 17:48:57 +0100 Subject: Add support for all models Add AbstractProvider class Add ProviderType type Add get_last_provider function Add version module and VersionUtils Display used provider in gui Fix error response in api --- g4f/Provider/needs_auth/Bard.py | 4 ++-- g4f/Provider/needs_auth/HuggingChat.py | 8 +++++++- g4f/Provider/needs_auth/Poe.py | 4 ++-- g4f/Provider/needs_auth/Raycast.py | 4 ++-- g4f/Provider/needs_auth/Theb.py | 4 ++-- g4f/Provider/needs_auth/ThebApi.py | 4 ++-- 6 files changed, 17 insertions(+), 11 deletions(-) (limited to 'g4f/Provider/needs_auth') diff --git a/g4f/Provider/needs_auth/Bard.py b/g4f/Provider/needs_auth/Bard.py index 48e535dd..cf1000c4 100644 --- a/g4f/Provider/needs_auth/Bard.py +++ b/g4f/Provider/needs_auth/Bard.py @@ -8,11 +8,11 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from ...typing import CreateResult, Messages -from ..base_provider import BaseProvider +from ..base_provider import AbstractProvider from ..helper import format_prompt from ...webdriver import WebDriver, WebDriverSession -class Bard(BaseProvider): +class Bard(AbstractProvider): url = "https://bard.google.com" working = True needs_auth = True diff --git a/g4f/Provider/needs_auth/HuggingChat.py b/g4f/Provider/needs_auth/HuggingChat.py index 41c938b4..e4fa237d 100644 --- a/g4f/Provider/needs_auth/HuggingChat.py +++ b/g4f/Provider/needs_auth/HuggingChat.py @@ -8,6 +8,9 @@ from ...typing import AsyncResult, Messages from ..base_provider import AsyncGeneratorProvider from ..helper import format_prompt, get_cookies +map = { + "openchat/openchat_3.5": "openchat/openchat-3.5-1210", +} class HuggingChat(AsyncGeneratorProvider): url = "https://huggingface.co/chat" @@ -25,7 +28,10 @@ class HuggingChat(AsyncGeneratorProvider): cookies: dict = None, **kwargs ) -> AsyncResult: - model = model if model else cls.model + if not model: + model = cls.model + elif model in map: + model = map[model] if not cookies: cookies = get_cookies(".huggingface.co") diff --git a/g4f/Provider/needs_auth/Poe.py b/g4f/Provider/needs_auth/Poe.py index 200ded3b..41c5315a 100644 --- a/g4f/Provider/needs_auth/Poe.py +++ b/g4f/Provider/needs_auth/Poe.py @@ -3,7 +3,7 @@ from __future__ import annotations import time from ...typing import CreateResult, Messages -from ..base_provider import BaseProvider +from ..base_provider import AbstractProvider from ..helper import format_prompt from ...webdriver import WebDriver, WebDriverSession @@ -20,7 +20,7 @@ models = { "palm": {"name": "Google-PaLM"}, } -class Poe(BaseProvider): +class Poe(AbstractProvider): url = "https://poe.com" working = True needs_auth = True diff --git a/g4f/Provider/needs_auth/Raycast.py b/g4f/Provider/needs_auth/Raycast.py index d7be98ac..07abeda3 100644 --- a/g4f/Provider/needs_auth/Raycast.py +++ b/g4f/Provider/needs_auth/Raycast.py @@ -5,10 +5,10 @@ import json import requests from ...typing import CreateResult, Messages -from ..base_provider import BaseProvider +from ..base_provider import AbstractProvider -class Raycast(BaseProvider): +class Raycast(AbstractProvider): url = "https://raycast.com" supports_gpt_35_turbo = True supports_gpt_4 = True diff --git a/g4f/Provider/needs_auth/Theb.py b/g4f/Provider/needs_auth/Theb.py index 82eac6e2..efb38a40 100644 --- a/g4f/Provider/needs_auth/Theb.py +++ b/g4f/Provider/needs_auth/Theb.py @@ -3,7 +3,7 @@ from __future__ import annotations import time from ...typing import CreateResult, Messages -from ..base_provider import BaseProvider +from ..base_provider import AbstractProvider from ..helper import format_prompt from ...webdriver import WebDriver, WebDriverSession @@ -31,7 +31,7 @@ models = { "qwen-7b-chat": "Qwen 7B" } -class Theb(BaseProvider): +class Theb(AbstractProvider): url = "https://beta.theb.ai" working = True supports_gpt_35_turbo = True diff --git a/g4f/Provider/needs_auth/ThebApi.py b/g4f/Provider/needs_auth/ThebApi.py index 0441f352..8ec7bda8 100644 --- a/g4f/Provider/needs_auth/ThebApi.py +++ b/g4f/Provider/needs_auth/ThebApi.py @@ -3,7 +3,7 @@ from __future__ import annotations import requests from ...typing import Any, CreateResult, Messages -from ..base_provider import BaseProvider +from ..base_provider import AbstractProvider models = { "theb-ai": "TheB.AI", @@ -29,7 +29,7 @@ models = { "qwen-7b-chat": "Qwen 7B" } -class ThebApi(BaseProvider): +class ThebApi(AbstractProvider): url = "https://theb.ai" working = True needs_auth = True -- cgit v1.2.3