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/models.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'g4f/models.py') diff --git a/g4f/models.py b/g4f/models.py index 9a4539c5..264cd40e 100644 --- a/g4f/models.py +++ b/g4f/models.py @@ -1,7 +1,6 @@ from __future__ import annotations from dataclasses import dataclass -from .typing import Union -from .Provider import BaseProvider, RetryProvider +from .Provider import RetryProvider, ProviderType from .Provider import ( Chatgpt4Online, ChatgptDemoAi, @@ -36,7 +35,7 @@ from .Provider import ( class Model: name: str base_provider: str - best_provider: Union[type[BaseProvider], RetryProvider] = None + best_provider: ProviderType = None @staticmethod def __all__() -> list[str]: @@ -101,28 +100,39 @@ gpt_4_turbo = Model( llama2_7b = Model( name = "meta-llama/Llama-2-7b-chat-hf", base_provider = 'huggingface', - best_provider = RetryProvider([Llama2, DeepInfra])) + best_provider = RetryProvider([Llama2, DeepInfra]) +) llama2_13b = Model( name = "meta-llama/Llama-2-13b-chat-hf", base_provider = 'huggingface', - best_provider = RetryProvider([Llama2, DeepInfra])) + best_provider = RetryProvider([Llama2, DeepInfra]) +) llama2_70b = Model( name = "meta-llama/Llama-2-70b-chat-hf", base_provider = "huggingface", - best_provider = RetryProvider([Llama2, DeepInfra, HuggingChat])) + best_provider = RetryProvider([Llama2, DeepInfra, HuggingChat]) +) # Mistal mixtral_8x7b = Model( name = "mistralai/Mixtral-8x7B-Instruct-v0.1", base_provider = "huggingface", - best_provider = HuggingChat) + best_provider = RetryProvider([DeepInfra, HuggingChat]) +) mistral_7b = Model( name = "mistralai/Mistral-7B-Instruct-v0.1", base_provider = "huggingface", - best_provider = HuggingChat) + best_provider = RetryProvider([DeepInfra, HuggingChat]) +) + +openchat_35 = Model( + name = "openchat/openchat_3.5", + base_provider = "huggingface", + best_provider = RetryProvider([DeepInfra, HuggingChat]) +) # Bard palm = Model( @@ -313,6 +323,7 @@ class ModelUtils: # Mistral 'mixtral-8x7b': mixtral_8x7b, 'mistral-7b': mistral_7b, + 'openchat_3.5': openchat_35, # Bard 'palm2' : palm, -- cgit v1.2.3