From e64da8b2aa5588a44cd2c3dd816dd990b4ee6ceb Mon Sep 17 00:00:00 2001 From: Liu An Date: Tue, 3 Jun 2025 15:22:26 +0800 Subject: [PATCH] Fix: sdk can not update chat model (#8016) ### What problem does this PR solve? #7791 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/sdk/chat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/apps/sdk/chat.py b/api/apps/sdk/chat.py index 24d89db85..3667dab54 100644 --- a/api/apps/sdk/chat.py +++ b/api/apps/sdk/chat.py @@ -173,8 +173,10 @@ def update(tenant_id, chat_id): if llm: if "model_name" in llm: req["llm_id"] = llm.pop("model_name") - if not TenantLLMService.query(tenant_id=tenant_id, llm_name=req["llm_id"], model_type="chat"): - return get_error_data_result(f"`model_name` {req.get('llm_id')} doesn't exist") + if req.get("llm_id") is not None: + llm_name, llm_factory = TenantLLMService.split_model_name_and_factory(req["llm_id"]) + if not TenantLLMService.query(tenant_id=tenant_id, llm_name=llm_name, llm_factory=llm_factory, model_type="chat"): + return get_error_data_result(f"`model_name` {req.get('llm_id')} doesn't exist") req["llm_setting"] = req.pop("llm") e, tenant = TenantService.get_by_id(tenant_id) if not e: