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 details to AutoBuild's blog and fix test error. This PR is related to #846 #865

Merged
merged 12 commits into from
Dec 5, 2023
32 changes: 24 additions & 8 deletions test/agentchat/contrib/test_agent_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ def test_build():
builder.build(
building_task=building_task,
default_llm_config={"temperature": 0},
user_proxy_work_dir=f"{here}/test_agent_scripts",
docker="python:3",
code_execution_config={
"last_n_messages": 2,
"work_dir": f"{here}/test_agent_scripts",
"timeout": 60,
"use_docker": "python:3",
},
)

# check number of agents
Expand All @@ -67,8 +71,12 @@ def test_save():
builder.build(
building_task=building_task,
default_llm_config={"temperature": 0},
user_proxy_work_dir=f"{here}/test_agent_scripts",
docker="python:3",
code_execution_config={
"last_n_messages": 2,
"work_dir": f"{here}/test_agent_scripts",
"timeout": 60,
"use_docker": "python:3",
},
)
saved_files = builder.save(f"{here}/example_save_agent_builder_config.json")

Expand Down Expand Up @@ -99,8 +107,12 @@ def test_load():

agent_list, loaded_agent_configs = builder.load(
config_save_path,
user_proxy_work_dir=f"{here}/test_agent_scripts",
docker="python:3",
code_execution_config={
"last_n_messages": 2,
"work_dir": f"{here}/test_agent_scripts",
"timeout": 60,
"use_docker": "python:3",
},
)

# check config loading
Expand All @@ -125,8 +137,12 @@ def test_clear_agent():
config_save_path = f"{here}/example_test_agent_builder_config.json"
builder.load(
config_save_path,
user_proxy_work_dir=f"{here}/test_agent_scripts",
docker="python:3",
code_execution_config={
"last_n_messages": 2,
"work_dir": f"{here}/test_agent_scripts",
"timeout": 60,
"use_docker": "python:3",
},
)
builder.clear_all_agents()

Expand Down
19 changes: 17 additions & 2 deletions website/blog/2023-11-26-Agent-AutoBuild/index.mdx
LinxinS97 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ up an endpoint server automatically without any user participant.
## Installation
- AutoGen:
```bash
pip install pyautogen==0.2.0b5
pip install pyautogen==0.2.0
JieyuZ2 marked this conversation as resolved.
Show resolved Hide resolved
```
- (Optional: if you want to use open-source LLMs) vLLM and FastChat
```bash
Expand Down Expand Up @@ -72,6 +72,21 @@ If you think coding is necessary in your task, you can use `coding=True` to add
agent_list, agent_configs = builder.build(building_task, default_llm_config, coding=True)
```
If `coding` is not specified, AgentBuilder will determine on its own whether the user proxy should be added or not according to the task.
The generated `agent_list` is a list of `AssistantAgent` instances.
If `coding` is true, a user proxy (a `UserProxyAssistant` instance) will be added as the first element to the `agent_list`.
`agent_configs` is a list of agent configurations including agent name, backbone LLM model, and system message.
For example
```
// an example of agent_configs. AgentBuilder will generate agents with the following configurations.
[
{
"name": "Data_scientist",
"model": "gpt-4-1106-preview",
"system_message": "As a Data Scientist, you are tasked with automating the retrieval and analysis of academic papers from arXiv. Utilize your Python programming acumen to develop scripts for gathering necessary information such as searching for relevant papers, downloading them, and processing their contents. Apply your analytical and language skills to interpret the data and deduce the applications of the research within specific domains.\n\n1. To compile information, write and implement Python scripts that search and interact with online resources, download and read files, extract content from documents, and perform other information-gathering tasks. Use the printed output as the foundation for your subsequent analysis.\n\n2. Execute tasks programmatically with Python scripts when possible, ensuring results are directly displayed. Approach each task with efficiency and strategic thinking.\n\nProgress through tasks systematically. In instances where a strategy is not provided, outline your plan before executing. Clearly distinguish between tasks handled via code and those utilizing your analytical expertise.\n\nWhen providing code, include only Python scripts meant to be run without user alterations. Users should execute your script as is, without modifications:\n\n```python\n# filename: <filename>\n# Python script\nprint(\"Your output\")\n```\n\nUsers should not perform any actions other than running the scripts you provide. Avoid presenting partial or incomplete scripts that require user adjustments. Refrain from requesting users to copy-paste results; instead, use the 'print' function when suitable to display outputs. Monitor the execution results they share.\n\nIf an error surfaces, supply corrected scripts for a re-run. If the strategy fails to resolve the issue, reassess your assumptions, gather additional details as needed, and explore alternative approaches.\n\nUpon successful completion of a task and verification of the results, confirm the achievement of the stated objective. Ensuring accuracy and validity of the findings is paramount. Evidence supporting your conclusions should be provided when feasible.\n\nUpon satisfying the user's needs and ensuring all tasks are finalized, conclude your assistance with \"TERMINATE\"."
},
...
]
```

### Step 5: execute the task
Let agents generated in `build()` to complete the task collaboratively in a group chat.
Expand Down Expand Up @@ -107,7 +122,7 @@ You can save all necessary information of the built group chat agents by
```python
saved_path = builder.save()
```
Configs will be saved in the JSON format with following content:
Configurations will be saved in JSON format with following content:
```json
// FILENAME: save_config_TASK_MD5.json
{
Expand Down
Loading