diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-02-09 05:53:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-09 05:53:47 +0100 |
commit | 999bc2d617a70ad70d185ba59c108d01794f9b5f (patch) | |
tree | d27a53d1549b352c8ab723680d51f01db6ae9d5c /g4f/Provider/needs_auth/ThebApi.py | |
parent | Merge pull request #1554 from Masha/patch-1 (diff) | |
parent | Add example for Image Upload & Generation (diff) | |
download | gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.gz gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.bz2 gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.lz gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.xz gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.zst gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.zip |
Diffstat (limited to 'g4f/Provider/needs_auth/ThebApi.py')
-rw-r--r-- | g4f/Provider/needs_auth/ThebApi.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/g4f/Provider/needs_auth/ThebApi.py b/g4f/Provider/needs_auth/ThebApi.py index 8ec7bda8..ea633243 100644 --- a/g4f/Provider/needs_auth/ThebApi.py +++ b/g4f/Provider/needs_auth/ThebApi.py @@ -3,7 +3,8 @@ from __future__ import annotations import requests from ...typing import Any, CreateResult, Messages -from ..base_provider import AbstractProvider +from ..base_provider import AbstractProvider, ProviderModelMixin +from ...errors import MissingAuthError models = { "theb-ai": "TheB.AI", @@ -29,13 +30,16 @@ models = { "qwen-7b-chat": "Qwen 7B" } -class ThebApi(AbstractProvider): +class ThebApi(AbstractProvider, ProviderModelMixin): url = "https://theb.ai" working = True needs_auth = True + default_model = "gpt-3.5-turbo" + models = list(models) - @staticmethod + @classmethod def create_completion( + cls, model: str, messages: Messages, stream: bool, @@ -43,8 +47,8 @@ class ThebApi(AbstractProvider): proxy: str = None, **kwargs ) -> CreateResult: - if model and model not in models: - raise ValueError(f"Model are not supported: {model}") + if not auth: + raise MissingAuthError("Missing auth") headers = { 'accept': 'application/json', 'authorization': f'Bearer {auth}', @@ -54,7 +58,7 @@ class ThebApi(AbstractProvider): # models = dict([(m["id"], m["name"]) for m in response]) # print(json.dumps(models, indent=4)) data: dict[str, Any] = { - "model": model if model else "gpt-3.5-turbo", + "model": cls.get_model(model), "messages": messages, "stream": False, "model_params": { |