mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 15:20:30 +08:00
Fix deepcopy the chat model (#17560)
This commit is contained in:
@@ -82,7 +82,7 @@ class RAGTools:
|
||||
thinking_mode: str = "medium",
|
||||
):
|
||||
self.tenant_ids = tenant_ids
|
||||
self.chat_mdl = chat_mdl
|
||||
self.chat_mdl = chat_mdl.clone()
|
||||
self.embed_mdl = embed_mdl
|
||||
self.thinking_mode = thinking_mode
|
||||
self.field_map = {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Research Agent — inner tool-calling loop for high/ultra modes.
|
||||
|
||||
Native tool-calling: a chat model deep-copied from ``tools.chat_mdl`` is bound
|
||||
Native tool-calling: a chat model cloned from ``tools.chat_mdl`` is bound
|
||||
(via ``bind_tools``) to the phase-gated tool schemas plus ``think_tool`` /
|
||||
``generate_report``, and a lightweight session routes each tool call to the
|
||||
harness pipeline. Binding onto a *copy* keeps the shared ``tools.chat_mdl``
|
||||
@@ -14,7 +14,6 @@ that the loop parses.
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from copy import deepcopy
|
||||
|
||||
from rag.advanced_rag.harness.types import ClaimTarget, ExecutionStrategy, ToolResult
|
||||
from rag.advanced_rag.harness.pipeline import Pipeline
|
||||
@@ -158,8 +157,8 @@ async def research_agent_loop(
|
||||
has_routed_scope=bool(getattr(pipeline, "_routed_docs", None)),
|
||||
)
|
||||
|
||||
# Deep-copy so binding tools never leaks onto the shared chat model.
|
||||
agent_mdl = deepcopy(tools.chat_mdl)
|
||||
# Clone so binding tools never leaks onto the shared chat model.
|
||||
agent_mdl = tools.chat_mdl.clone()
|
||||
if getattr(agent_mdl, "is_tools", False):
|
||||
return await _research_native(claim, agent_mdl, pipeline, phase, phase_config, gated_defs, mode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user