autogen
autogen copied to clipboard
Add tool library, tool retriever and tool support for agents.
Why are these changes needed?
We introduce a tool library into autogen, as well as a ToolRetriever class that can retrieve tools from library and equip the agents with tools.
Tool Library
We create a new folder tools that contain manually created python tools. These tools have three categories: math, data_analysis and information_retrieval. The tools follow the layout pattern: tools/{category}/{tool_name}.py and can be imported via from tools.{category}.{tool_name} import {tool_name}.
Tool Builder
The tool builder retrieves the tools from library based on semantic similarity between tool description and query.
Tool Binding
We update the system message of AssistantAgent to inform it of the tools' existance. Refer to ToolBuilder.TOOL_USING_PROMPT for related prompts.
The user proxy gets a new LocalCommandLineExecutor that has access to all the tools in the library, in order for it to execute from functions import * code.
Related issue number
#2101 #1510
This PR relies on PR #1929.
Checks
- [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
- [ ] I've added tests (if relevant) corresponding to the changes introduced in this PR.
- [x] I've made sure all auto checks have passed.
Codecov Report
Attention: Patch coverage is 0% with 66 lines in your changes are missing coverage. Please review.
Project coverage is 27.21%. Comparing base (
4a44093) to head (24c9c6d). Report is 33 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| autogen/tool_utils.py | 0.00% | 35 Missing :warning: |
| autogen/agentchat/contrib/tool_retriever.py | 0.00% | 31 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #2414 +/- ##
===========================================
- Coverage 38.14% 27.21% -10.93%
===========================================
Files 78 84 +6
Lines 7865 8417 +552
Branches 1683 1931 +248
===========================================
- Hits 3000 2291 -709
- Misses 4615 5855 +1240
- Partials 250 271 +21
| Flag | Coverage Δ | |
|---|---|---|
| unittest | 12.87% <0.00%> (?) |
|
| unittests | 26.77% <0.00%> (-11.36%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Great to see this OG feature/PR popping up: https://github.com/microsoft/autogen/pull/1601/files
There is a lot overlap with the Mdconvert library that was developed in ComplexTasks (see: https://github.com/microsoft/autogen/blob/gaia_multiagent_v01_march_1st/autogen/mdconvert.py), and appears is #1929: https://github.com/microsoft/autogen/blob/266cefc1737e0077667bce441c541a90865582b1/autogen/browser_utils/mdconvert.py
The Mdconvert library indeed started life as @gagb 's library #1601
We should discuss how to avoid duplication here.
@ekzhu
There are indeed some overlapping effort in separate branches.
@LeoLjl can you take a look at: https://github.com/microsoft/autogen/blob/gaia_multiagent_v01_march_1st/autogen/mdconvert.py first (@afourney can you suggest a more recent branch) to identify tools that are already being worked on.
My suggestion is to avoid duplication. For example, you can leave space for those functions rather than creating future conflicts.
Yeah, we've refined the converters a bunch. The latest are in: https://github.com/microsoft/autogen/blob/266cefc1737e0077667bce441c541a90865582b1/autogen/browser_utils/mdconvert.py (PR 1929).
Actually on further review, it appears that some functions were largely copy-pasted from this branch already.
Amazing PR. I have two questions:
- Do we still need the
import xxxstatements inside the functions? The functions are already usingwith_requirementsdecorator so we can assume the Python environment already has the dependencies installed. If the functions are invoked as tool use, then the Python environment should have those dependencies as they are already imported at the module level.
You are right, I'll add all the package requirements into with_requirements and see if it will invoke any problems.
- The
bindmethod API looks rather different from the tool use API in the core library: https://microsoft.github.io/autogen/docs/tutorial/tool-use. Do we need to introduce a new API?
In my opinion, tools generally have two formats: function call and python function. Function call is black box to llms and they can only use tools by giving arguments and wait for the response. python function allows llm to generate freeform code to import and call any tools at will, potentially using multiple tools and orchestrate the outputs to solve a problem in one response. The bind method attempts to implement the latter. I'm not sure what you mean by a new API, could you elaborate more?
There are indeed some overlapping effort in separate branches. @LeoLjl can you take a look at: https://github.com/microsoft/autogen/blob/gaia_multiagent_v01_march_1st/autogen/mdconvert.py first (@afourney can you suggest a more recent branch) to identify tools that are already being worked on. My suggestion is to avoid duplication. For example, you can leave space for those functions rather than creating future conflicts.
Yeah, we've refined the converters a bunch. The latest are in: https://github.com/microsoft/autogen/blob/266cefc1737e0077667bce441c541a90865582b1/autogen/browser_utils/mdconvert.py (PR 1929).
Actually on further review, it appears that some functions were largely copy-pasted from this branch already.
Yes. We believe that complex file support is an important function for agents. We changed part of the markdown converter into functions for file support. Maybe we can reuse the related class in browser_utils when PR 1929 is merged.
I'm not sure what you mean by a new API, could you elaborate more?
I see you are already using the new User-Defined function API to implement bind. I meant the tool use and the user-defined function APIs.
- https://microsoft.github.io/autogen/docs/tutorial/tool-use
- https://microsoft.github.io/autogen/docs/topics/code-execution/user-defined-functions
My comment was regarding adding the tool builder class which calls the user-defined function API. I am not sure if we need to introduce another abstraction to register the user-defined functions... Having more than one way to do things tend to confuse users.
Yes. We believe that complex file support is an important function for agents. We changed part of the markdown converter into functions for file support. Maybe we can reuse the related class in browser_utils when PR 1929 is merged.
Let's leave space for those functions. We can have a future PR to rewire the converters. @gagb @afourney does this sounds good?
Yes. We believe that complex file support is an important function for agents. We changed part of the markdown converter into functions for file support. Maybe we can reuse the related class in browser_utils when PR 1929 is merged.
Let's leave space for those functions. We can have a future PR to rewire the converters. @gagb @afourney does this sounds good?
I would need some time to evaluate this. The converters we have are battle-tested on GAIA, and there are some subtleties about filetype discovery (magic numbers, mime-types, ecc), converter precedence, and class hierarchy (e.g., were media types occupy one branch, and handle metadata, html types occupy a different branch with some special handling for some sites like YouTube, Wikipedia, BingSERP, etc.) I am not thrilled with just copy-pasting some things around, reimplementing some stuff, etc.
Yes. We believe that complex file support is an important function for agents. We changed part of the markdown converter into functions for file support. Maybe we can reuse the related class in browser_utils when PR 1929 is merged.
Let's leave space for those functions. We can have a future PR to rewire the converters. @gagb @afourney does this sounds good?
I agree with the plan. We can add file converting related tools when converter PR 1929 is ready and remove the related tools for now.
I'm not sure what you mean by a new API, could you elaborate more?
I see you are already using the new User-Defined function API to implement
bind. I meant the tool use and the user-defined function APIs.
- https://microsoft.github.io/autogen/docs/tutorial/tool-use
- https://microsoft.github.io/autogen/docs/topics/code-execution/user-defined-functions
My comment was regarding adding the tool builder class which calls the user-defined function API. I am not sure if we need to introduce another abstraction to register the user-defined functions... Having more than one way to do things tend to confuse users.
Ahh I get your point now. Let me see what I can do about unifying this api.
Converting this PR to draft and awaiting the merge of #1929 for further development.
Right now the code in spreedsheet_to_md.py, docx_to_md.py and pptx_to_md.py in tools/information_retrieval folder is copied from PR#1929. Later when the PR is merged will import the functions directly.
⚠️ GitGuardian has uncovered 96 secrets following the scan of your pull request.
Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.
Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard. Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.
🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 12853598 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | e43a86c78f3f947b6e142b3aaf36e7a9852f7078 | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | bdb40d77d7be9ea42e5fa28f6e851edf549ef0af | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | 954ca451f949a4924578bb7e3e93c97ad4ba1dd5 | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 10404662 | Triggered | Generic CLI Secret | eff19acf1365e34fe17d9ac0939666f32b3ceda5 | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 06a0a5ddb39fb3000e40cb4872741dead9fcb7e0 | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 0524c774dda696855e9a8f87fe0b9ed96cce13f6 | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | d7ea410501cb96bc97a203a0a95431541515f9cc | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | e43a86c78f3f947b6e142b3aaf36e7a9852f7078 | .github/workflows/dotnet-build.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 841ed315e2f19d79a6b86ed587eb6e0fc4a0c0da | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 802f099588bedf1d022b2bba5fb534635df8e6f1 | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 9a484d8589761d58940e3c0b79215204ce6a23c1 | .github/workflows/dotnet-build.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | e973ac38ea4f7b36687ea03aa44f770d7e2ddcac | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 89650e74f572bbc60e9c24e04b4c601616e439c7 | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | e07b06bc939353dee2afc6dd52c159d6cb3428d5 | .github/workflows/dotnet-release.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | abe4c419c45a244e2399508f9ffef606ce6a4685 | .github/workflows/dotnet-build.yml | View secret |
| 10404662 | Triggered | Generic CLI Secret | 7362fb9cf4f0a6b3e7ae4e97229afad655d5d87b | .github/workflows/dotnet-release.yml | View secret |
| 12853599 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 10404694 | Triggered | Generic High Entropy Secret | e43a86c78f3f947b6e142b3aaf36e7a9852f7078 | test/oai/test_utils.py | View secret |
| 10404694 | Triggered | Generic High Entropy Secret | 954ca451f949a4924578bb7e3e93c97ad4ba1dd5 | test/oai/test_utils.py | View secret |
| 10404694 | Triggered | Generic High Entropy Secret | bdb40d77d7be9ea42e5fa28f6e851edf549ef0af | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | abad9ff4487444324d1916a6b94c8049b4cab9e7 | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | 954ca451f949a4924578bb7e3e93c97ad4ba1dd5 | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | c7bb588a684a038dbee7f9dc9afd6d44ce35ac3a | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | b97b99d4b2cfe735a7aa46258508d4a7cda9cad5 | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | e43a86c78f3f947b6e142b3aaf36e7a9852f7078 | test/oai/test_utils.py | View secret |
| 12853600 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 12853601 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 10493810 | Triggered | Generic Password | 49e8053dd1e5456d3758b4a85f5721e9c9b12e16 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 501610b4fc0c649fa2b1cbf0fd72fa6f14f026d0 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 49e8053dd1e5456d3758b4a85f5721e9c9b12e16 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 501610b4fc0c649fa2b1cbf0fd72fa6f14f026d0 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | d422c63596fce7b84e0ef8a7bd6518d5f4336eaf | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 97fa339ac749b3c7d51f1b0fae156d41c02b214e | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 49e8053dd1e5456d3758b4a85f5721e9c9b12e16 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | d422c63596fce7b84e0ef8a7bd6518d5f4336eaf | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 97fa339ac749b3c7d51f1b0fae156d41c02b214e | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | d422c63596fce7b84e0ef8a7bd6518d5f4336eaf | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 97fa339ac749b3c7d51f1b0fae156d41c02b214e | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 501610b4fc0c649fa2b1cbf0fd72fa6f14f026d0 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | 954ca451f949a4924578bb7e3e93c97ad4ba1dd5 | test/oai/test_utils.py | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | bdb40d77d7be9ea42e5fa28f6e851edf549ef0af | test/oai/test_utils.py | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | e43a86c78f3f947b6e142b3aaf36e7a9852f7078 | test/oai/test_utils.py | View secret |
| 10422482 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 10422482 | Triggered | Generic High Entropy Secret | bdb40d77d7be9ea42e5fa28f6e851edf549ef0af | test/oai/test_utils.py | View secret |
| 12853602 | Triggered | Generic High Entropy Secret | 79dbb7bc2561713bc11225849e408dc74db1228f | test/oai/test_utils.py | View secret |
| 11616921 | Triggered | Generic High Entropy Secret | a86d0fde2e667f9177eea55da17312b770c9d76b | notebook/agentchat_agentops.ipynb | View secret |
| 11616921 | Triggered | Generic High Entropy Secret | 394561b4629222c19d8bb3bc58222fc8813a5833 | notebook/agentchat_agentops.ipynb | View secret |
| 11616921 | Triggered | Generic High Entropy Secret | 3eac646b8974e1d1be3fde557b055563f56f2f5f | notebook/agentchat_agentops.ipynb | View secret |
| 11616921 | Triggered | Generic High Entropy Secret | f45b55337aa7f9d6151f21f2c55ba5dc83f95b79 | notebook/agentchat_agentops.ipynb | View secret |
| 11616921 | Triggered | Generic High Entropy Secret | 65632487224aae2c7faca67de40fd2bda3ad3905 | notebook/agentchat_agentops.ipynb | View secret |
| 12853598 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 12853598 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | 0a3c6c49834b4f68c688c1d2e76a5ebb8f7d91e2 | test/oai/test_utils.py | View secret |
| 10404693 | Triggered | Generic High Entropy Secret | 76f5f5a66532a3b95d03fe0ae8a56a59e43012e1 | test/oai/test_utils.py | View secret |
| 10404662 | Triggered | Generic CLI Secret | 954ca451f949a4924578bb7e3e93c97ad4ba1dd5 | .github/workflows/dotnet-build.yml | View secret |
| 12853599 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 12853599 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
| 10404694 | Triggered | Generic High Entropy Secret | 76f5f5a66532a3b95d03fe0ae8a56a59e43012e1 | test/oai/test_utils.py | View secret |
| 10404694 | Triggered | Generic High Entropy Secret | 0a3c6c49834b4f68c688c1d2e76a5ebb8f7d91e2 | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | 3b79cc6fdfa485026262ec44aa5f1f0238bf7c3d | test/oai/test_utils.py | View secret |
| 10404695 | Triggered | Generic High Entropy Secret | 11baa52155c3846299d39ed0b5a814b33b0eb671 | test/oai/test_utils.py | View secret |
| 12853600 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
| 12853600 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 12853601 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
| 12853601 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 10493810 | Triggered | Generic Password | 3b79cc6fdfa485026262ec44aa5f1f0238bf7c3d | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 11baa52155c3846299d39ed0b5a814b33b0eb671 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 11baa52155c3846299d39ed0b5a814b33b0eb671 | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10493810 | Triggered | Generic Password | 3b79cc6fdfa485026262ec44aa5f1f0238bf7c3d | notebook/agentchat_pgvector_RetrieveChat.ipynb | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | 0a3c6c49834b4f68c688c1d2e76a5ebb8f7d91e2 | test/oai/test_utils.py | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | 76f5f5a66532a3b95d03fe0ae8a56a59e43012e1 | test/oai/test_utils.py | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
| 10404696 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 10422482 | Triggered | Generic High Entropy Secret | 2b3a9ae05569d38cfc89d9daa4b1612b8406d178 | test/oai/test_utils.py | View secret |
| 10422482 | Triggered | Generic High Entropy Secret | c03558f5b2708c31df36666486f54b2714435162 | test/oai/test_utils.py | View secret |
and 16 others.
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Closed as this PR is outdated. Latest ones in #3042