mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 07:10:29 +08:00
fix: synchronize chat model configuration (#17717)
This commit is contained in:
@@ -1859,16 +1859,15 @@ async def gen_mindmap(question, kb_ids, tenant_id, search_config={}):
|
||||
|
||||
|
||||
async def rag_agent(dialog, messages, stream=True, **kwargs):
|
||||
logging.debug("Begin rag_agent")
|
||||
prompt_config = dialog.prompt_config or {}
|
||||
assert messages[-1]["role"] == "user", "The last content of this conversation is not from user."
|
||||
prompt_config = dialog.prompt_config
|
||||
if not prompt_config.get("reasoning", 0) and not kwargs.get("reasoning"):
|
||||
async for ans in async_chat(dialog, messages, stream, **kwargs):
|
||||
yield ans
|
||||
return
|
||||
kbs, embd_mdl, rerank_mdl, chat_mdl, tts_mdl = get_models(dialog)
|
||||
use_web_search = _should_use_web_search(prompt_config, kwargs.get("internet"))
|
||||
logging.debug("web_search kb=%s tavily=%s internet=%r enabled=%s", bool(dialog.kb_ids), bool(dialog.prompt_config.get("tavily_api_key")), kwargs.get("internet"), use_web_search)
|
||||
logging.debug("web_search kb=%s tavily=%s internet=%r enabled=%s", bool(dialog.kb_ids), bool(prompt_config.get("tavily_api_key")), kwargs.get("internet"), use_web_search)
|
||||
tenant_ids = list(set([kb.tenant_id for kb in kbs]))
|
||||
# "reasoning" arrives as "1".."4" mapping to the ordered THINKING_MODES
|
||||
# (low, medium, high, ultra); fall back to "medium" on anything else.
|
||||
@@ -1881,12 +1880,13 @@ async def rag_agent(dialog, messages, stream=True, **kwargs):
|
||||
except (TypeError, ValueError):
|
||||
thinking_mode = "medium"
|
||||
|
||||
gen_conf = dialog.llm_setting or {}
|
||||
rag_tools = RAGTools(
|
||||
tenant_ids,
|
||||
chat_mdl,
|
||||
embed_mdl=embd_mdl,
|
||||
kb_ids=dialog.kb_ids,
|
||||
tav=Tavily(prompt_config["tavily_api_key"]) if use_web_search else None,
|
||||
tav=Tavily(prompt_config.get("tavily_api_key")) if use_web_search else None,
|
||||
do_refer=False,
|
||||
thinking_mode=thinking_mode,
|
||||
)
|
||||
@@ -1949,7 +1949,6 @@ async def rag_agent(dialog, messages, stream=True, **kwargs):
|
||||
# small models mangle or drop, so the client receives nothing.
|
||||
if getattr(chat_mdl, "mdl", None) is not None:
|
||||
chat_mdl.mdl.terminal_tools = {"rag"}
|
||||
gen_conf = dialog.llm_setting
|
||||
if stream:
|
||||
# Surface the agentic pipeline's bracket-tagged progress logs to the
|
||||
# client as <think> content, interleaved with the real token stream.
|
||||
|
||||
Reference in New Issue
Block a user