Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Aivvm: KeyError: '' #934

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions g4f/Provider/Aivvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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'},
Expand All @@ -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" : "*/*",
Expand Down
3 changes: 2 additions & 1 deletion g4f/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ async def create_async(

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)
Expand Down
2 changes: 1 addition & 1 deletion g4f/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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
Expand Down