Feat: model provider (#16028)

### What problem does this PR solve?

Feat:
- Allow upsert model_type for instance model

Fix:
- Allow create instance with duplicate api_key

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Lynn
2026-06-15 19:10:33 +08:00
committed by GitHub
parent ba93ac3bd7
commit 47495c1f6a
6 changed files with 216 additions and 51 deletions
+60
View File
@@ -630,6 +630,66 @@ def list_instance_models(tenant_id: str = None, provider_name: str = None, insta
return get_error_data_result(message="Internal server error")
@manager.route("/providers/<provider_name>/instances/<instance_name>/models", methods=["PUT"]) # noqa: F821
@login_required
@add_tenant_id_to_kwargs
async def update_instance_models(tenant_id: str, provider_name: str, instance_name: str):
"""
Batch update model_type for models in instance.
---
tags:
- Providers
security:
- ApiKeyAuth: []
parameters:
- in: path
name: provider_name
type: string
required: true
description: Provider name.
- in: path
name: instance_name
type: string
required: true
description: Instance name.
- in: header
name: Authorization
type: string
required: true
description: Bearer token for authentication.
- in: body
name: body
description: Model details.
required: true
schema:
type: object
required:
- model_name
- model_type
properties:
model_name:
type: list of string
description: Model name.
model_type:
type: list of string
description: Model type.
"""
data = await request.get_json()
if not data or "model_name" not in data or "model_type" not in data:
return get_error_argument_result(message="model_name and model_type are required")
model_name = data["model_name"]
model_type = data["model_type"]
try:
success, msg = provider_api_service.update_instance_models(tenant_id, provider_name, instance_name, model_name, model_type)
if success:
return get_result(message=msg)
else:
return get_error_data_result(message=msg)
except Exception as e:
logging.exception(e)
return get_error_data_result(message="Internal server error")
@manager.route("/providers/<provider_name>/instances/<instance_name>/models", methods=["POST"]) # noqa: F821
@login_required
@add_tenant_id_to_kwargs