From ea8de1bb475f89e0a4b3561c0129858489aa69af Mon Sep 17 00:00:00 2001 From: Magicbook1108 Date: Thu, 16 Apr 2026 20:37:01 +0800 Subject: [PATCH] Fix: different llm in chat (#14162) ### What problem does this PR solve? Fix: different llm in chat ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/db/services/dialog_service.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index 5dacc32bb..32de922ab 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -241,7 +241,14 @@ async def async_chat_solo(dialog, messages, stream=True): else: text_attachments, image_files = split_file_attachments(messages[-1]["files"], raw=True) attachments = "\n\n".join(text_attachments) - model_config = get_model_config_by_id(dialog.tenant_llm_id) + + if dialog.llm_id: + model_config = get_model_config_by_type_and_name(dialog.tenant_id, LLMType.CHAT, dialog.llm_id) + elif dialog.tenant_llm_id: + model_config = get_model_config_by_id(dialog.tenant_llm_id) + else: + model_config = get_tenant_default_model_by_type(dialog.tenant_id, LLMType.CHAT) + chat_mdl = LLMBundle(dialog.tenant_id, model_config) factory = model_config.get("llm_factory", "") if model_config else "" @@ -290,10 +297,10 @@ def get_models(dialog): if not embd_mdl: raise LookupError("Embedding model(%s) not found" % embedding_list[0]) - if dialog.tenant_llm_id: - chat_model_config = get_model_config_by_id(dialog.tenant_llm_id) - elif dialog.llm_id: + if dialog.llm_id: chat_model_config = get_model_config_by_type_and_name(dialog.tenant_id, LLMType.CHAT, dialog.llm_id) + elif dialog.tenant_llm_id: + chat_model_config = get_model_config_by_id(dialog.tenant_llm_id) else: chat_model_config = get_tenant_default_model_by_type(dialog.tenant_id, LLMType.CHAT)