-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: ValueError: Tool with name functions not found, some queries will result in this error, while others won't. #13649
Comments
To resolve the Ensure Tool Names are Correctly Defined and Added
Modify the
|
Hi @dosu, I have verified my tools names I am using in my queries match the names defined in the ToolMetadata. But the error still happend. |
To resolve the Step-by-Step Debugging
Example Code for Initialization and RetrievalHere is a complete example that includes tool initialization, printing available tool names, and retrieving a tool by name: from llama_index.core.tools.query_engine import QueryEngineTool
from llama_index.core.query_engine.router_query_engine import ToolMetadata
from typing import List
# Define the get_function_by_name function with debugging print statement
def get_function_by_name(tools: List[BaseTool], name: str) -> BaseTool:
"""Get function by name."""
name_to_tool = {tool.metadata.name: tool for tool in tools}
print("Available tools:", name_to_tool.keys()) # Add this line for debugging
if name not in name_to_tool:
raise ValueError(f"Tool with name {name} not found")
return name_to_tool[name]
# Initialize tools
tools = []
file_names = ["file1", "file2", "file3"]
for file_name in file_names:
metadata = ToolMetadata(name=file_name, description=f"Tool for {file_name}")
tool = QueryEngineTool(query_engine=some_query_engine, metadata=metadata)
tools.append(tool)
# Attempt to retrieve a tool by name
tool_name = "file1"
try:
tool = get_function_by_name(tools, tool_name)
print(f"Successfully retrieved tool: {tool.metadata.name}")
except ValueError as e:
print(e) By following these steps and ensuring that the tool names are correctly defined, initialized, and retrieved, you should be able to identify and correct the mismatch causing the
|
I'm not sure what LLM you are using, but it's just hallucinating a tool name, which can happen |
Hi @logan-markewich, I use AzuerOpenAI gpt3.5, so could this be an issue with the LLM API? |
Hi @dosu , some queries won't result in this error, but some querirs will happen.. |
To address the intermittent Steps to Ensure Correct Tool Name Recognition
Enhanced Code with Detailed Logging
|
Bug Description
I have modified according to this page, adding unique names to the metadata.
But the error still happend.
I have modified all the EnginTool's ToolMetadata
I also print the metadata for the retrieval step, ensuring that the names in the metadata are included.
I follow the these two Example, got same error.
Multi-Document Agents (V1)
Multi-Document Agents
Version
0.10.38
Steps to Reproduce
response = agent.query("my_query")
Relevant Logs/Tracbacks
No response
The text was updated successfully, but these errors were encountered: