-
Notifications
You must be signed in to change notification settings - Fork 5.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]: OpenAI agent with query engine tools crashes while calling the tool #9411
Comments
🤖 Hello @vaibhavp4! 👋 I'm Dosu, a friendly bot here to lend a hand with bugs, answer your questions, and guide you as a contributor while we wait for a human maintainer. Just a reminder, I'm not a human, but I'll do my best to assist. 🤖🛠️ Let's get coding! 🚀 Based on the error message you provided, it seems like the issue is related to the name of the function you're trying to call with the OpenAI agent. The error message indicates that the name of the function, 'Tesla April 2022 Valuation', does not match the expected pattern '^[a-zA-Z0-9_-]{1,64}$'. This pattern requires the function name to be between 1 and 64 characters long and only contain alphanumeric characters, underscores, and hyphens. As for the warning that the agent code doesn't see query engine tools as a subclass of BaseTools, this could be due to an incorrect import statement or a missing inheritance declaration in the class definition of the query engine tools. Regarding the crash when submitting a query, there are a couple of potential reasons based on the context provided:
Here is the relevant code: def read(self, query: str) -> Any:
# Query the index for the result
if not self._index:
return (
"Error: No content has been loaded into the index. "
f"You must call {self._metadata.name} first"
)
query_engine = self._index.as_query_engine()
response = query_engine.query(query)
return str(response) (Source: llama_index/tools/tool_spec/load_and_search/base.py) There was a similar issue reported in the LlamaIndex repository: [Bug]: Validation Error for tools in OpenAI Assistant Agent example. This issue was resolved by a pull request: one line fix for wrapping of custom function tools to create OpenAI assistant. The changes made in this pull request might help resolve your issue. Please try to update your function name to match the required pattern and ensure that the query engine tools are correctly subclassed from BaseTools. If the issue persists, please provide more details about your setup and the steps you're taking so that I can better assist you. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
As you can see from the error, the name you gave your tool is invalid It can only be alpha-numeric with dashes or underscores, but your tool name has spaces |
Thanks, missed it because the same names were working fine with the sub question query engine |
Bug Description
I setup an openai agent with query engine tools
The agent was able to start and enter the chat repl
But it fails as soon as you submit a query
![image](https://private-user-images.githubusercontent.com/4822281/289260603-24d48085-80a4-47d5-8009-4c14238e195e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTA0MDYsIm5iZiI6MTczOTYxMDEwNiwicGF0aCI6Ii80ODIyMjgxLzI4OTI2MDYwMy0yNGQ0ODA4NS04MGE0LTQ3ZDUtODAwOS00YzE0MjM4ZTE5NWUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTVUMDkwMTQ2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmFjYTI4ZTIzYjliMDdjNTFhYzAwNDkyYTllYjIxNWQ5MWM4OWU1NWJlMWNlZjkyYjM0N2YxYjhjMWFhOTYzNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ZR2foTjVukGoitgWc6aJh-F64kn7zSt16hSgF5nTH0M)
(The editor also warns that agent code doesn't see query engine tools as a subclass of BaseTools)
Version
0.9.13
Steps to Reproduce
setup openai agent with query tools engine as per this documentation https://docs.llamaindex.ai/en/stable/examples/agent/openai_agent_with_query_engine.html
Run the agent - agent.chat_repl()
Submit a query
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: