mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-15 14:56:00 +08:00
fix: setting default model to gpt-3.5-turbo-1106 and remove default m… (#2274)
This commit is contained in:
parent
c97b7f6748
commit
34634bddf1
@ -107,7 +107,20 @@ class AppListApi(Resource):
|
|||||||
# validate config
|
# validate config
|
||||||
model_config_dict = args['model_config']
|
model_config_dict = args['model_config']
|
||||||
|
|
||||||
# get model provider
|
# Get provider configurations
|
||||||
|
provider_manager = ProviderManager()
|
||||||
|
provider_configurations = provider_manager.get_configurations(current_user.current_tenant_id)
|
||||||
|
|
||||||
|
# get available models from provider_configurations
|
||||||
|
available_models = provider_configurations.get_models(
|
||||||
|
model_type=ModelType.LLM,
|
||||||
|
only_active=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# check if model is available
|
||||||
|
available_models_names = [f'{model.provider.provider}.{model.model}' for model in available_models]
|
||||||
|
provider_model = f"{model_config_dict['model']['provider']}.{model_config_dict['model']['name']}"
|
||||||
|
if provider_model not in available_models_names:
|
||||||
model_manager = ModelManager()
|
model_manager = ModelManager()
|
||||||
model_instance = model_manager.get_default_model_instance(
|
model_instance = model_manager.get_default_model_instance(
|
||||||
tenant_id=current_user.current_tenant_id,
|
tenant_id=current_user.current_tenant_id,
|
||||||
|
@ -218,6 +218,21 @@ class ProviderManager:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if available_models:
|
if available_models:
|
||||||
|
found = False
|
||||||
|
for available_model in available_models:
|
||||||
|
if available_model.model == "gpt-3.5-turbo-1106":
|
||||||
|
default_model = TenantDefaultModel(
|
||||||
|
tenant_id=tenant_id,
|
||||||
|
model_type=model_type.to_origin_model_type(),
|
||||||
|
provider_name=available_model.provider.provider,
|
||||||
|
model_name=available_model.model
|
||||||
|
)
|
||||||
|
db.session.add(default_model)
|
||||||
|
db.session.commit()
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not found:
|
||||||
available_model = available_models[0]
|
available_model = available_models[0]
|
||||||
default_model = TenantDefaultModel(
|
default_model = TenantDefaultModel(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user