Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: different llm in chat (#14162)

Magicbook1108ea8de1bb475f
diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py
index 5dacc32bb2..32de922ab1 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)