Fix only one of multiple retrieval tools is effective (#12110)

### What problem does this PR solve?

Fix only one of multiple retrieval tools is effective

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
TeslaZY
2025-12-23 14:08:25 +08:00
committed by GitHub
parent 321474fb97
commit d1bc7ad2ee
2 changed files with 6 additions and 4 deletions

View File

@ -84,9 +84,10 @@ class Agent(LLM, ToolBase):
def __init__(self, canvas, id, param: LLMParam): def __init__(self, canvas, id, param: LLMParam):
LLM.__init__(self, canvas, id, param) LLM.__init__(self, canvas, id, param)
self.tools = {} self.tools = {}
for cpn in self._param.tools: for idx, cpn in enumerate(self._param.tools):
cpn = self._load_tool_obj(cpn) cpn = self._load_tool_obj(cpn)
self.tools[cpn.get_meta()["function"]["name"]] = cpn name = cpn.get_meta()["function"]["name"]
self.tools[f"{name}_{idx}"] = cpn
self.chat_mdl = LLMBundle(self._canvas.get_tenant_id(), TenantLLMService.llm_id2llm_type(self._param.llm_id), self._param.llm_id, self.chat_mdl = LLMBundle(self._canvas.get_tenant_id(), TenantLLMService.llm_id2llm_type(self._param.llm_id), self._param.llm_id,
max_retries=self._param.max_retries, max_retries=self._param.max_retries,

View File

@ -324,8 +324,9 @@ def tool_schema(tools_description: list[dict], complete_task=False):
} }
} }
} }
for tool in tools_description: for idx, tool in enumerate(tools_description):
desc[tool["function"]["name"]] = tool name = tool["function"]["name"]
desc[f"{name}_{idx}"] = tool
return "\n\n".join([f"## {i+1}. {fnm}\n{json.dumps(des, ensure_ascii=False, indent=4)}" for i, (fnm, des) in enumerate(desc.items())]) return "\n\n".join([f"## {i+1}. {fnm}\n{json.dumps(des, ensure_ascii=False, indent=4)}" for i, (fnm, des) in enumerate(desc.items())])