From e4f743881c915ba250b859d01ef78c7b90a96bf5 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Tue, 23 Jan 2024 12:17:16 +0100 Subject: Fix: Model sometimes not converted #1507 --- g4f/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'g4f') diff --git a/g4f/__init__.py b/g4f/__init__.py index 2b0e5b46..996acf6c 100644 --- a/g4f/__init__.py +++ b/g4f/__init__.py @@ -45,12 +45,13 @@ def get_model_and_provider(model : Union[Model, str], else: raise ProviderNotFoundError(f'Provider not found: {provider}') + if isinstance(model, str): + if model in ModelUtils.convert: + model = ModelUtils.convert[model] + if not provider: if isinstance(model, str): - if model in ModelUtils.convert: - model = ModelUtils.convert[model] - else: - raise ModelNotFoundError(f'Model not found: {model}') + raise ModelNotFoundError(f'Model not found: {model}') provider = model.best_provider if not provider: -- cgit v1.2.3