mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 17:16:52 +08:00
Fix:remove duplicate tool_meta (#12139)
### What problem does this PR solve? pr:#12117 change:remove duplicate tool_meta ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -277,19 +277,15 @@ class Agent(LLM, ToolBase):
|
|||||||
else:
|
else:
|
||||||
user_request = history[-1]["content"]
|
user_request = history[-1]["content"]
|
||||||
|
|
||||||
def build_task_desc(prompt: str, user_request: str, tool_metas: list[dict], user_defined_prompt: dict | None = None) -> str:
|
def build_task_desc(prompt: str, user_request: str, user_defined_prompt: dict | None = None) -> str:
|
||||||
"""Build a minimal task_desc by concatenating prompt, query, and tool schemas."""
|
"""Build a minimal task_desc by concatenating prompt, query, and tool schemas."""
|
||||||
user_defined_prompt = user_defined_prompt or {}
|
user_defined_prompt = user_defined_prompt or {}
|
||||||
|
|
||||||
tools_json = json.dumps(tool_metas, ensure_ascii=False, indent=2)
|
|
||||||
|
|
||||||
task_desc = (
|
task_desc = (
|
||||||
"### Agent Prompt\n"
|
"### Agent Prompt\n"
|
||||||
f"{prompt}\n\n"
|
f"{prompt}\n\n"
|
||||||
"### User Request\n"
|
"### User Request\n"
|
||||||
f"{user_request}\n\n"
|
f"{user_request}\n\n"
|
||||||
"### Tools (schemas)\n"
|
|
||||||
f"{tools_json}\n"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if user_defined_prompt:
|
if user_defined_prompt:
|
||||||
@ -368,7 +364,7 @@ class Agent(LLM, ToolBase):
|
|||||||
hist.append({"role": "user", "content": content})
|
hist.append({"role": "user", "content": content})
|
||||||
|
|
||||||
st = timer()
|
st = timer()
|
||||||
task_desc = build_task_desc(prompt, user_request, tool_metas, user_defined_prompt)
|
task_desc = build_task_desc(prompt, user_request, user_defined_prompt)
|
||||||
self.callback("analyze_task", {}, task_desc, elapsed_time=timer()-st)
|
self.callback("analyze_task", {}, task_desc, elapsed_time=timer()-st)
|
||||||
for _ in range(self._param.max_rounds + 1):
|
for _ in range(self._param.max_rounds + 1):
|
||||||
if self.check_if_canceled("Agent streaming"):
|
if self.check_if_canceled("Agent streaming"):
|
||||||
|
|||||||
@ -94,7 +94,7 @@ This content will NOT be shown to the user.
|
|||||||
## Step 2: Structured Reflection (MANDATORY before `complete_task`)
|
## Step 2: Structured Reflection (MANDATORY before `complete_task`)
|
||||||
|
|
||||||
### Context
|
### Context
|
||||||
- Goal: {{ task_analysis }}
|
- Goal: Reflect on the current task based on the full conversation context
|
||||||
- Executed tool calls so far (if any): reflect from conversation history
|
- Executed tool calls so far (if any): reflect from conversation history
|
||||||
|
|
||||||
### Task Complexity Assessment
|
### Task Complexity Assessment
|
||||||
|
|||||||
Reference in New Issue
Block a user