mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 12:29:17 +08:00
fix: create basic app causing internal error when default model is not exist
This commit is contained in:
parent
115c9486c3
commit
f0637ba332
@ -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
|
||||||
|
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user