fix: create basic app causing internal error when default model is not exist

This commit is contained in:
takatost 2024-11-08 23:09:52 +08:00
parent 115c9486c3
commit f0637ba332
2 changed files with 5 additions and 2 deletions

View File

@ -409,7 +409,7 @@ class ModelManager:
return ModelInstance(provider_model_bundle, model) return ModelInstance(provider_model_bundle, model)
def get_default_provider_model_name(self, tenant_id: str, model_type: ModelType) -> tuple[str, str]: def get_default_provider_model_name(self, tenant_id: str, model_type: ModelType) -> tuple[str | None, str | None]:
""" """
Return first provider and the first model in the provider Return first provider and the first model in the provider
:param tenant_id: tenant id :param tenant_id: tenant id

View File

@ -270,7 +270,7 @@ class ProviderManager:
), ),
) )
def get_first_provider_first_model(self, tenant_id: str, model_type: ModelType) -> tuple[str, str]: def get_first_provider_first_model(self, tenant_id: str, model_type: ModelType) -> tuple[str | None, str | None]:
""" """
Get names of first model and its provider Get names of first model and its provider
@ -283,6 +283,9 @@ class ProviderManager:
# get available models from provider_configurations # get available models from provider_configurations
all_models = provider_configurations.get_models(model_type=model_type, only_active=False) all_models = provider_configurations.get_models(model_type=model_type, only_active=False)
if not all_models:
return None, None
return all_models[0].provider.provider, all_models[0].model return all_models[0].provider.provider, all_models[0].model
def update_default_model_record( def update_default_model_record(