-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Implement Overwrite Tools Functionality in GPTAssistantAgent #1434
Implement Overwrite Tools Functionality in GPTAssistantAgent #1434
Conversation
Thanks for your contributor @jtrugman . I'm inspired by your contribution! It sparked a new idea—what if we added specific functions like
What are your thoughts on this suggestion? |
Thank you! I will take a look tomorrow morning. |
I think the overwrite instructions (and now overwrite tools) is good enough and straightforward enough in the short term. But I can see that being helpful in the long term. For example, this is how I am using both overwrites locally: researcher = GPTAssistantAgent(
name=create_valid_agent_name("Researcher", recordStatus),
instructions= researcher_instructions[recordStatus],
overwrite_instructions = True, # overwrite any existing instructions with the ones provided
overwrite_tools = True,
llm_config = {
"config_list": config_list,
"tools": [{
"type": "function",
"function": {
"name": "google_search",
"description": "search on google for more information",
"parameters": {
"type": "object",
"properties": {
"search_keyword": {
"type": "string",
"description": "Keyword optimized to return the results you are looking for"
}
},
"required": ["search_keyword"]
}
}
}, {
"type": "function",
"function": {
"name": "web_scraping",
"description": "Scrape the webpage",
"parameters": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "the address of the website to scrape"
},
"objective": {
"type": "string",
"description": "scrape the webpage for the information you are looking"
}
},
"required": ["url", "objective"]
}
}
}] + researcher_tools.get(recordStatus, []),
"assistant_id": researcher_assistant_id[recordStatus]
}
) I think this is straightforward enough for now. What would be more helpful (at least for me) though is more robust documentation with examples showing how to use the overwrite instructions and pass in the tools in the llm_config. Happy to contribute to this to by the way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtrugman , when I run the tests, I get
"FAILED test/agentchat/contrib/test_gpt_assistant.py::test_gpt_assistant_tools_overwrite - AttributeError: 'GPTAssistantAgent' object has no attribute 'get_assistant_tools'"
@jtrugman After looking at your test cases, I realized that getTools might be quite useful. It seems necessary to check the current state before updating tools, which is where my idea comes from. Feel free to proceed with the current tasks, and we can consider my suggestions at a later stage. It would be really helpful if we could include a comprehensive example to demonstrate the use of the 'overwrite' feature. Could you contribute such an example? |
Thanks @sonichi, just fixed the code formatting. Please let me know if there are any additional changes you would like me to make |
Sounds good to me, will submit a new PR with the notebook for it |
@IANTHEREAL , @jtrugman Are all the tests passing for you? All tests pass for current main. For this branch, I am still getting this error in dev container, when I run pytest.
|
Made a fix, should resolve the issue causing the tests to fail |
@gagb my local tests can pass now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ft#1434) * added overwrite_tools logic to GPTAssistantAgent * added test test_gpt_assistant_tools_overwrite * fetch tools without get_assistant_tools method * fixed code formatting * fixed no .get found
Summary:
This pull request introduces a new feature to the GPTAssistantAgent class within autogen, specifically focusing on enhancing the flexibility and control over the assistant's tools configuration. The key addition is the overwrite_tools logic, which allows users to explicitly decide whether they want to overwrite the existing tools of an OpenAI Assistant with a new set specified in the llm_config.
Why are these changes needed?
Prior to this update, the GPTAssistantAgent class did not provide a straightforward mechanism to update or overwrite the tools of an existing assistant. This limitation posed challenges in dynamic environments where the needs or capabilities associated with an assistant might change over time. With the introduction of the overwrite_tools flag, users now have the ability to update the toolset of an assistant easily, enhancing the assistant's adaptability and usefulness in various scenarios.
Details of the Change:
This enhancement aligns with the goal of making the GPTAssistantAgent more flexible and capable of adapting to changing requirements, thereby improving its utility in a broader range of applications.
Related issue number
N/A
Checks