Append attachments content to last message (#17993)

This commit is contained in:
Wang Qi
2026-08-07 16:04:19 +08:00
committed by GitHub
parent 3f78c156d4
commit 993b41b7b1
5 changed files with 9 additions and 25 deletions

View File

@@ -574,20 +574,9 @@ class RAGTools:
if self.tool_started_sink is not None:
self.tool_started_sink()
if self.text_attachments_content:
self.kbinfos = {
"chunks": [
{
"id": "chat_attachment",
"chunk_id": "chat_attachment",
"doc_id": "chat_attachment",
"docnm_kwd": "Chat attachment",
"content_with_weight": self.text_attachments_content,
}
],
"doc_aggs": [{"doc_id": "chat_attachment", "doc_name": "Chat attachment", "count": 1}],
}
messages = [{"role": "user", "content": question}] if question else []
if self.text_attachments_content and messages:
messages[-1]["content"] += self.text_attachments_content
final = ""
async for kind, delta in _split_think_stream(run_agentic_rag(self, messages)):
if kind == "answer":

View File

@@ -143,8 +143,6 @@ async def agentic_research(state: dict, tools) -> dict:
if action == "ANSWER_PARTIAL":
return _finalize(ctx, tools, partial=True)
if action == "ABSTAIN":
if getattr(tools, "text_attachments_content", ""):
return {"verdict": verdict.__dict__, "kbinfos": tools.kbinfos}
tools.kbinfos["chunks"] = []
return {"verdict": verdict.__dict__, "abstain": True}
if action == "REPLAN":

View File

@@ -186,8 +186,6 @@ async def decompose_and_search(state: dict, tools) -> dict:
if action in ("ANSWER", "ANSWER_PARTIAL"):
return _finalize(ctx, tools, partial=action == "ANSWER_PARTIAL", loop=completed_cycles)
if action == "ABSTAIN":
if getattr(tools, "text_attachments_content", ""):
return {"verdict": verdict.__dict__, "kbinfos": tools.kbinfos}
tools.kbinfos["chunks"] = []
return {"verdict": verdict.__dict__, "abstain": True, "loop": completed_cycles}
if action == "FALLBACK_LLM":