Skip to content
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

Add further installation guidance and files for CaptainAgent #76

Merged
merged 10 commits into from
Nov 28, 2024
Merged
6 changes: 3 additions & 3 deletions notebook/agentchat_captainagent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"\n",
"````{=mdx}\n",
":::info Requirements\n",
"Install `ag2`:\n",
"Install `ag2` with CaptainAgent:\n",
"```bash\n",
"pip install ag2[autobuild]\n",
"pip install ag2[captainagent]\n",
"```\n",
"\n",
"For more information, please refer to the [installation guide](/docs/installation/).\n",
Expand Down Expand Up @@ -522,7 +522,7 @@
"\n",
"For agent library, refer to [`captainagent_expert_library.json`](https://github.com/ag2ai/ag2/blob/main/notebook/captainagent_expert_library.json) for samples. You can refer to [docs](https://ag2ai.github.io/ag2/docs/topics/captainagent/agent_library) on how to customize your own expert library.\n",
"\n",
"For tool library, we provide a set of tools [here](https://github.com/ag2ai/ag2/tree/main/autogen/agentchat/contrib/captainagent/tools/README.md), the tools are categorized into three types: data analysis, information_retrieval, math."
"For tool library, we provide a set of tools [here](https://github.com/ag2ai/ag2/tree/main/autogen/agentchat/contrib/captainagent/tools/README.md), the tools are categorized into three types: data analysis, information_retrieval, math. If you are using the tools, you should [install the requirements](https://github.com/ag2ai/ag2/tree/main/autogen/agentchat/contrib/captainagent/tools/README.md#how-to-use) for them."
marklysze marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
Expand Down
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@
long_description_content_type="text/markdown",
url="https://github.com/ag2ai/ag2",
packages=setuptools.find_packages(include=["autogen*"], exclude=["test"]),
package_data={
"autogen.agentchat.contrib.captainagent": [
"tools/**/*.py", # CaptainAgent tools
"tools/tool_description.tsv",
"tools/requirements.txt",
]
marklysze marked this conversation as resolved.
Show resolved Hide resolved
},
include_package_data=True,
install_requires=install_requires,
extras_require=extra_require,
classifiers=[
Expand Down
4 changes: 4 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ docs/reference
docs/tutorial/*.mdx
docs/tutorial/**/*.png
!docs/tutorial/assets/*.png
docs/topics/swarm.mdx
docs/topics/llm_configuration.mdx
docs/topics/code-execution/*.mdx
docs/topics/task_decomposition.mdx
Expand All @@ -23,6 +24,9 @@ docs/topics/non-openai-models/**/*.py
docs/topics/non-openai-models/**/*.svg
docs/topics/code-execution/*.mdx
docs/topics/groupchat/customized_speaker_selection.mdx
docs/topics/groupchat/resuming_groupchat.mdx
docs/topics/groupchat/transform_messages_speaker_selection.mdx
docs/topics/groupchat/using_custom_model_client_classes.mdx
cell-*-output-*.png

# Misc
Expand Down
16 changes: 11 additions & 5 deletions website/blog/2024-11-15-CaptainAgent/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ CaptainAgent iterates over the following two steps until the problem is successf

The design of CaptainAgent allows it to leverage agents and tools from a pre-specified agent library and tool library. In the following section, we demonstrate how to use CaptainAgent with or without the provided library.

To install AG2 with CaptainAgent:

```bash
pip install ag2[captainagent]
```

# Using CaptainAgent without pre-specified agent/tool libraries
CaptainAgent can serve as a drop-in replacement for the general `AssistantAgent` class in AG2. To do that we just need to add a few lines of configurations for the group chat involved.
Without the agent library and tool library, CaptainAgent will automatically generate a set of agents into a group chat.
CaptainAgent can serve as a drop-in replacement for the general `AssistantAgent` class in AG2. It also allows customization such as agent/tool libraries. When the libraries are provided, CaptainAgent will try to leverage them when solving a task.
Without them, CaptainAgent will automatically generate new agents.

```python
from autogen.agentchat.contrib.captain_agent import CaptainAgent
from autogen.agentchat.contrib.captainagent import CaptainAgent
from autogen import UserProxyAgent

llm_config = {
Expand Down Expand Up @@ -58,7 +64,7 @@ The tool library we provide requires subscribing to specific APIs, please refer
To use agents from an agent library, you just need to specify a `library_path` sub-field or a `autobuild_tool_config` field in CaptainAgent's configuration.

```python
from autogen.agentchat.contrib.captain_agent import CaptainAgent
from autogen.agentchat.contrib.captainagent import CaptainAgent
from autogen import UserProxyAgent

llm_config = {
Expand All @@ -70,7 +76,7 @@ llm_config = {
captain_agent = CaptainAgent(
name="captain_agent",
llm_config=llm_config,
nested_mode_config=nested_mode_config,
nested_config=nested_mode_config,
agent_lib="captainagent_expert_library.json",
tool_lib="default",
code_execution_config={"use_docker": False, "work_dir": "groupchat"},
Expand Down
2 changes: 1 addition & 1 deletion website/docs/topics/captainagent/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Captain Agent",
"label": "CaptainAgent",
"collapsible": true
}
15 changes: 12 additions & 3 deletions website/docs/topics/captainagent/configurations.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Configurations in `nested_config`
Captain Agent requires `nested_config` for configuration. Below is an example, we will break it down and provide a detailed explanation.
CaptainAgent requires `nested_config` for configuration. Below is an example, we will break it down and provide a detailed explanation.

```
nested_config = {
Expand All @@ -23,6 +23,15 @@ nested_config = {
}
```

:::info Requirements
If you run CaptainAgent without specifying a `nested_config`, a default is used and this **requires an OAI_CONFIG_LIST**.

**The default model used is OpenAI's GPT-4o**.

To see the default configuration and the OpenAI model used, see the [captainagent.py](https://github.com/ag2ai/ag2/blob/ceb75d865d0a7eb2b7c0bc51776e093681e0970e/autogen/agentchat/contrib/captainagent.py) file.

For advice on using OAI_CONFIG_LIST, [see the documentation](https://ag2ai.github.io/ag2/docs/topics/llm_configuration#oai_config_list-pattern).
:::

## `autobuild_init_config`
This section is used to configure the initial setup of autobuild. `autobuild_init_config` takes in arguments from `AgentBuilder.__init__()`. Check the full list of arguments [here](https://github.com/ag2ai/ag2/blob/main/autogen/agentchat/contrib/agent_builder.py#L181).
Expand All @@ -31,10 +40,10 @@ This section is used to configure the initial setup of autobuild. `autobuild_ini
Configures the path to API key config. Defaults to `OAI_CONFIG_LIST`.
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved

### `builder_model`
Configures the backbone of agent builder. The builder is used for agent selection from the library. Defaults to `gpt-4o-mini`.
Configures the backbone of agent builder. The builder is used for agent selection from the library. Defaults to `gpt-4o`.
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved

### `agent_model`
Configures the backbone of agents in the group chat. Defaults to `gpt-4o-mini`.
Configures the backbone of agents in the group chat. Defaults to `gpt-4o`.

### Other `kwargs`
`autobuild_init_config` takes in arguments from `AgentBuilder.__init__()`. Check the full list of arguments [here](https://github.com/ag2ai/ag2/blob/main/autogen/agentchat/contrib/agent_builder.py#L181).
Expand Down
2 changes: 1 addition & 1 deletion website/docs/topics/llm_configuration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"\n",
"### `OAI_CONFIG_LIST` pattern\n",
"\n",
"A common, useful pattern used is to define this `config_list` is via JSON (specified as a file or an environment variable set to a JSON-formatted string) and then use the [`config_list_from_json`](/docs/reference/oai/openai_utils#config_list_from_json) helper function to load it:"
"A common, useful pattern used is to define this `config_list` via JSON (specified as a file or an environment variable set to a JSON-formatted string) and then use the [`config_list_from_json`](/docs/reference/oai/openai_utils#config_list_from_json) helper function to load it:"
]
},
{
Expand Down
Loading