fix: app create raise error when no available model providers (#1921)

This commit is contained in:
takatost 2024-01-04 17:33:26 +08:00 committed by GitHub
parent a82b4d315a
commit b4225bedb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -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

View File

@ -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