summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-09-23 17:32:21 +0200
committerGitHub <noreply@github.com>2023-09-23 17:32:21 +0200
commiteaa8f712abd6d2ae181cf3f1524239658d7da5a3 (patch)
tree107121cfa813bcdb1d5f0d86216ef74561306b9a /g4f
parent ~ | improve Vercel & g4f.Completion.create (diff)
parentTypeError: issubclass() arg 1 must be a class (diff)
downloadgpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.tar
gpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.tar.gz
gpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.tar.bz2
gpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.tar.lz
gpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.tar.xz
gpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.tar.zst
gpt4free-eaa8f712abd6d2ae181cf3f1524239658d7da5a3.zip
Diffstat (limited to 'g4f')
-rw-r--r--g4f/Provider/Aivvm.py12
-rw-r--r--g4f/__init__.py3
-rw-r--r--g4f/models.py2
3 files changed, 12 insertions, 5 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/__init__.py b/g4f/__init__.py
index c0f70d8a..d6388fb5 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -64,7 +64,8 @@ class ChatCompletion:
model, provider = get_model_and_provider(model, provider, False)
- if not issubclass(provider, AsyncProvider) and not issubclass(type(provider), AsyncProvider):
+ provider_type = provider if isinstance(provider, type) else type(provider)
+ if not issubclass(provider_type, AsyncProvider):
raise Exception(f"Provider: {provider.__name__} doesn't support create_async")
return await provider.create_async(model.name, messages, **kwargs)
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