From b4225bedb53ef47ff4a661ebb80ddd91b3e44b99 Mon Sep 17 00:00:00 2001 From: takatost Date: Thu, 4 Jan 2024 17:33:26 +0800 Subject: [PATCH] fix: app create raise error when no available model providers (#1921) --- api/controllers/console/app/app.py | 10 ++-------- api/core/provider_manager.py | 7 +++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py index c5d24f049..7f6502373 100644 --- a/api/controllers/console/app/app.py +++ b/api/controllers/console/app/app.py @@ -141,15 +141,9 @@ class AppListApi(Resource): model_type=ModelType.LLM ) except ProviderTokenNotInitError: - raise ProviderNotInitializeError( - f"No Default System Reasoning Model available. Please configure " - f"in the Settings -> Model Provider.") + model_instance = None - if not model_instance: - raise ProviderNotInitializeError( - f"No Default System Reasoning Model available. Please configure " - f"in the Settings -> Model Provider.") - else: + if model_instance: model_dict = app_model_config.model_dict model_dict['provider'] = model_instance.provider model_dict['name'] = model_instance.model diff --git a/api/core/provider_manager.py b/api/core/provider_manager.py index 82c149673..60a388a63 100644 --- a/api/core/provider_manager.py +++ b/api/core/provider_manager.py @@ -401,10 +401,13 @@ class ProviderManager: Provider.tenant_id == tenant_id, Provider.provider_name == provider_name, Provider.provider_type == ProviderType.SYSTEM.value, - Provider.quota_type == ProviderQuotaType.TRIAL.value, - Provider.is_valid == True + Provider.quota_type == ProviderQuotaType.TRIAL.value ).first() + if provider_record and not provider_record.is_valid: + provider_record.is_valid = True + db.session.commit() + provider_name_to_provider_records_dict[provider_name].append(provider_record) return provider_name_to_provider_records_dict