From 4edd7518de837d6469a5ec982cc5ffb959ae4e92 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 23 Sep 2023 15:35:17 +0200 Subject: Fix: Aivvm: KeyError: '' and TypeError: issubclass() arg 1 must be a class --- g4f/Provider/Aivvm.py | 12 +++++++++--- g4f/models.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/g4f/Provider/Aivvm.py b/g4f/Provider/Aivvm.py index 97c9dff0..c38c4a74 100644 --- a/g4f/Provider/Aivvm.py +++ b/g4f/Provider/Aivvm.py @@ -2,7 +2,7 @@ from __future__ import annotations import requests from .base_provider import BaseProvider -from ..typing import Any, CreateResult +from ..typing import CreateResult models = { 'gpt-3.5-turbo': {'id': 'gpt-3.5-turbo', 'name': 'GPT-3.5'}, @@ -26,8 +26,14 @@ class Aivvm(BaseProvider): def create_completion(cls, model: str, messages: list[dict[str, str]], - stream: bool, **kwargs: Any) -> CreateResult: - + stream: bool, + **kwargs + ) -> CreateResult: + if not model: + model = "gpt-3.5-turbo" + elif model not in models: + raise ValueError(f"Model are not supported: {model}") + headers = { "authority" : "chat.aivvm.com", "accept" : "*/*", diff --git a/g4f/models.py b/g4f/models.py index 71fd6b18..01b42106 100644 --- a/g4f/models.py +++ b/g4f/models.py @@ -24,7 +24,7 @@ from .Provider import ( class Model: name: str base_provider: str - best_provider: Union[type[BaseProvider], tuple[type[BaseProvider]]] = None + best_provider: Union[type[BaseProvider], RetryProvider] = None # Config for HuggingChat, OpenAssistant # Works for Liaobots, H2o, OpenaiChat, Yqcloud, You -- cgit v1.2.3