CaptainAgent
Introducing CaptainAgent, a powerful agent that can manage and orchestrate other agents and tools to solve complex tasks.
By: Jiale Liu, Linxin Song, Jieyu Zhang, Shaokun Zhang
In this notebook, we introduce CaptainAgent, an agent enhanced with the capability to call AutoBuild to break down and solve complex tasks. AutoBuild can initiate a group chat between a group of experts and converse to solve the task. The experts in nested chat can be retrieved from agent library. The agents can be equipped with tools for advanced coding.
Install ag2
with CaptainAgent:
Note: If you have been using
autogen
orpyautogen
, all you need to do is upgrade it using:or
as
pyautogen
,autogen
, andag2
are aliases for the same PyPI package.
For more information, please refer to the installation guide.
Setup API endpoint
In order to setup API, you should create a OAI_CONFIG_LIST file. The config list should look like the following:
Learn more about configuring LLMs for agents here.
Using CaptainAgent without libraries
We begin with demonstrating how to use CaptainAgent without retrieving
from libraries. In this case, CaptainAgent will automatically generate a
set of experts according to its identified subtask and initiate the
group chat. By default, the backbone of the LLM is set to gpt-4o
. For
instructions on configuring the backbone, refer to docs on
nested_mode
.
Building Agents from library & Retrieve tools from tool library
One significant feature of CaptainAgent is that the agents and tools can be retrieved from a dedicated library. When CaptainAgent starts building experts for group chat, it will retrieve and select from agent library, then assign tools retrieved from tool library to the experts.
For agent library, refer to
captainagent_expert_library.json
for samples. You can refer to
docs on
how to customize your own expert library.
For tool library, we provide a set of tools here, the tools are categorized into three types: data analysis, information_retrieval, math. If you are using the tools, you should install the requirements for them.
Using Agent Library Only
Below is an example that retrieves experts from library and build nested chat accordingly.
Using Both Agent Library and Tool Library
Now let’s retrieve from both agent library and tool library while building experts for nested chat.
To run the following demo, it is required to install the dependencies from the tool library and obtain BING search api and Rapid API key for tools in library to fully function. Please follow the instructions here.
The ground truth answer to the question is ‘Extremely’, which the CaptainAgent answers correctly. Notably, with the assistance of tools, the agent can answer video-related questions. This shows the huge potential of what user customized tools can bring.
Further Reading
For a full list of the configurables and the functionalities in CaptainAgent, please refer here.
For how to customize your own agent library, check here.
For how to implement your own tool library that suits your need, check the documents here.