summaryrefslogtreecommitdiffstats
path: root/g4f/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g4f/__init__.py9
1 files changed, 6 insertions, 3 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