diff options
author | Heiner Lohaus <heiner@lohaus.eu> | 2023-09-18 15:27:36 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner@lohaus.eu> | 2023-09-18 15:27:36 +0200 |
commit | 78bee085274f493f9ad8764adb5f436d60a9e54f (patch) | |
tree | 30af2244525261a2567dfc50e00261ee373681ed /g4f | |
parent | Improve event loop (diff) | |
download | gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.tar gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.tar.gz gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.tar.bz2 gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.tar.lz gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.tar.xz gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.tar.zst gpt4free-78bee085274f493f9ad8764adb5f436d60a9e54f.zip |
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/__init__.py | 9 | ||||
-rw-r--r-- | g4f/models.py | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/g4f/__init__.py b/g4f/__init__.py index d8681297..a49e60e9 100644 --- a/g4f/__init__.py +++ b/g4f/__init__.py @@ -16,14 +16,17 @@ class ChatCompletion: auth : Union[str, None] = None, **kwargs: Any) -> Union[CreateResult, str]: if isinstance(model, str): - try: + if model in models.ModelUtils.convert: model = models.ModelUtils.convert[model] - except KeyError: + else: raise Exception(f'The model: {model} does not exist') if not provider: if isinstance(model.best_provider, list): - provider = random.choice(model.best_provider) + if stream: + provider = random.choice([p for p in model.best_provider if p.supports_stream]) + else: + provider = random.choice(model.best_provider) else: provider = model.best_provider diff --git a/g4f/models.py b/g4f/models.py index 0e2680b6..9b01fa3c 100644 --- a/g4f/models.py +++ b/g4f/models.py @@ -7,7 +7,6 @@ from .Provider import ( CodeLinkAva, ChatgptAi, ChatBase, - Yqcloud, Vercel, DeepAi, Aivvm, @@ -32,7 +31,7 @@ gpt_35_turbo = Model( name = 'gpt-3.5-turbo', base_provider = 'openai', best_provider = [ - Yqcloud, DeepAi, CodeLinkAva, ChatgptLogin, ChatgptAi, ChatBase, Aivvm + DeepAi, CodeLinkAva, ChatgptLogin, ChatgptAi, ChatBase, Aivvm ] ) |