diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-01-23 20:08:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 20:08:41 +0100 |
commit | 2b140a32554c1e94d095c55599a2f93e86f957cf (patch) | |
tree | e2770d97f0242a0b99a3af68ea4fcf25227dfcc8 /g4f/Provider/HuggingChat.py | |
parent | ~ (diff) | |
parent | Add ProviderModelMixin for model selection (diff) | |
download | gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.gz gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.bz2 gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.lz gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.xz gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.zst gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.zip |
Diffstat (limited to 'g4f/Provider/HuggingChat.py')
-rw-r--r-- | g4f/Provider/HuggingChat.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/g4f/Provider/HuggingChat.py b/g4f/Provider/HuggingChat.py index 3b4a520c..d493da8f 100644 --- a/g4f/Provider/HuggingChat.py +++ b/g4f/Provider/HuggingChat.py @@ -5,11 +5,11 @@ import json, uuid from aiohttp import ClientSession from ..typing import AsyncResult, Messages -from .base_provider import AsyncGeneratorProvider +from .base_provider import AsyncGeneratorProvider, ProviderModelMixin from .helper import format_prompt, get_cookies -class HuggingChat(AsyncGeneratorProvider): +class HuggingChat(AsyncGeneratorProvider, ProviderModelMixin): url = "https://huggingface.co/chat" working = True default_model = "meta-llama/Llama-2-70b-chat-hf" @@ -21,7 +21,7 @@ class HuggingChat(AsyncGeneratorProvider): "mistralai/Mistral-7B-Instruct-v0.2", "openchat/openchat-3.5-0106" ] - model_map = { + model_aliases = { "openchat/openchat_3.5": "openchat/openchat-3.5-1210", "mistralai/Mixtral-8x7B-Instruct-v0.1": "mistralai/Mistral-7B-Instruct-v0.2" } @@ -37,12 +37,6 @@ class HuggingChat(AsyncGeneratorProvider): cookies: dict = None, **kwargs ) -> AsyncResult: - if not model: - model = cls.default_model - elif model in cls.model_map: - model = cls.model_map[model] - elif model not in cls.models: - raise ValueError(f"Model is not supported: {model}") if not cookies: cookies = get_cookies(".huggingface.co") @@ -53,7 +47,7 @@ class HuggingChat(AsyncGeneratorProvider): cookies=cookies, headers=headers ) as session: - async with session.post(f"{cls.url}/conversation", json={"model": model}, proxy=proxy) as response: + async with session.post(f"{cls.url}/conversation", json={"model": cls.get_model(model)}, proxy=proxy) as response: conversation_id = (await response.json())["conversationId"] send = { |