Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gagb committed Dec 3, 2024
1 parent 47f7cda commit a4d04ba
Show file tree
Hide file tree
Showing 5 changed files with 337 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ For beginner users, AgentChat is the recommended starting point.
For advanced users, [`autogen-core`](../core-user-guide/index.md)'s event-driven
programming model provides more flexibility and control over the underlying components.

AgentChat aims to provide intuitive defaults, such as **Agents** with preset
AgentChat provides intuitive defaults, such as **Agents** with preset
behaviors and **Teams** with predefined [multi-agent design patterns](../core-user-guide/design-patterns/index.md).
to simplify building multi-agent applications.

```{include} warning.md
```

```{tip}
If you are interested in implementing complex agent interaction behaviours, defining custom messaging protocols, or orchestration mechanisms, consider using the [ `autogen-core`](../core-user-guide/index.md) package.
```

::::{grid} 2 2 2 2
:gutter: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ myst:

# Installation

## Create a virtual environment (optional)
## Create a Virtual Environment (optional)

When installing AgentChat locally, we recommend using a virtual environment for the installation. This will ensure that the dependencies for AgentChat are isolated from the rest of your system.

Expand Down Expand Up @@ -55,7 +55,7 @@ conda deactivate
``````

## Intall the AgentChat package using pip
## Install Using pip

Install the `autogen-agentchat` package using pip:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,160 +1,152 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quickstart"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{include} warning.md\n",
"\n",
"```\n",
"\n",
":::{note}\n",
"For installation instructions, please refer to the [installation guide](./installation).\n",
":::\n",
"\n",
"In AutoGen AgentChat, you can build applications quickly using preset agents.\n",
"To illustrate this, we will begin with creating a team of a single agent\n",
"that can use tools and respond to messages.\n",
"\n",
"The following code uses the OpenAI model. If you haven't already, you need to\n",
"install the following package and extension:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"pip install 'autogen-agentchat==0.4.0.dev8' 'autogen-ext[openai]==0.4.0.dev8'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To use Azure OpenAI models and AAD authentication,\n",
"you can follow the instructions [here](./tutorial/models.ipynb#azure-openai)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"---------- user ----------\n",
"What is the weather in New York?\n",
"---------- weather_agent ----------\n",
"[FunctionCall(id='call_AhTZ2q3TNL8x0qs00e3wIZ7y', arguments='{\"city\":\"New York\"}', name='get_weather')]\n",
"[Prompt tokens: 79, Completion tokens: 15]\n",
"---------- weather_agent ----------\n",
"[FunctionExecutionResult(content='The weather in New York is 73 degrees and Sunny.', call_id='call_AhTZ2q3TNL8x0qs00e3wIZ7y')]\n",
"---------- weather_agent ----------\n",
"The weather in New York is currently 73 degrees and sunny.\n",
"[Prompt tokens: 90, Completion tokens: 14]\n",
"---------- weather_agent ----------\n",
"TERMINATE\n",
"[Prompt tokens: 137, Completion tokens: 4]\n",
"---------- Summary ----------\n",
"Number of messages: 5\n",
"Finish reason: Text 'TERMINATE' mentioned\n",
"Total prompt tokens: 306\n",
"Total completion tokens: 33\n",
"Duration: 1.43 seconds\n"
]
}
],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
"from autogen_agentchat.task import Console, TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"\n",
"# Define a tool\n",
"async def get_weather(city: str) -> str:\n",
" return f\"The weather in {city} is 73 degrees and Sunny.\"\n",
"\n",
"\n",
"async def main() -> None:\n",
" # Define an agent\n",
" weather_agent = AssistantAgent(\n",
" name=\"weather_agent\",\n",
" model_client=OpenAIChatCompletionClient(\n",
" model=\"gpt-4o-2024-08-06\",\n",
" # api_key=\"YOUR_API_KEY\",\n",
" ),\n",
" tools=[get_weather],\n",
" )\n",
"\n",
" # Define termination condition\n",
" termination = TextMentionTermination(\"TERMINATE\")\n",
"\n",
" # Define a team\n",
" agent_team = RoundRobinGroupChat([weather_agent], termination_condition=termination)\n",
"\n",
" # Run the team and stream messages to the console\n",
" stream = agent_team.run_stream(task=\"What is the weather in New York?\")\n",
" await Console(stream)\n",
"\n",
"\n",
"# NOTE: if running this inside a Python script you'll need to use asyncio.run(main()).\n",
"await main()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The code snippet above introduces two high level concepts in AgentChat: *Agent* and *Team*. An Agent helps us define what actions are taken when a message is received. Specifically, we use the {py:class}`~autogen_agentchat.agents.AssistantAgent` preset - an agent that can be given access to a model (e.g., LLM) and tools (functions) that it can then use to address tasks. A Team helps us define the rules for how agents interact with each other. In the {py:class}`~autogen_agentchat.teams.RoundRobinGroupChat` team, agents respond in a sequential round-robin fashion.\n",
"In this case, we have a single agent, so the same agent is used for each round."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What's Next?\n",
"\n",
"Now that you have a basic understanding of how to define an agent and a team, consider following the [tutorial](./tutorial/index) for a walkthrough on other features of AgentChat.\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quickstart"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Via AgentChat, you can build applications quickly using preset agents.\n",
"To illustrate this, we will begin with creating a team of a single agent\n",
"that can use tools and respond to messages.\n",
"\n",
"The following code uses the OpenAI model. If you haven't already, you need to\n",
"install the following package and extension:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"pip install 'autogen-agentchat==0.4.0.dev8' 'autogen-ext[openai]==0.4.0.dev8'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To use Azure OpenAI models and AAD authentication,\n",
"you can follow the instructions [here](./tutorial/models.ipynb#azure-openai)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"---------- user ----------\n",
"What is the weather in New York?\n",
"---------- weather_agent ----------\n",
"[FunctionCall(id='call_AhTZ2q3TNL8x0qs00e3wIZ7y', arguments='{\"city\":\"New York\"}', name='get_weather')]\n",
"[Prompt tokens: 79, Completion tokens: 15]\n",
"---------- weather_agent ----------\n",
"[FunctionExecutionResult(content='The weather in New York is 73 degrees and Sunny.', call_id='call_AhTZ2q3TNL8x0qs00e3wIZ7y')]\n",
"---------- weather_agent ----------\n",
"The weather in New York is currently 73 degrees and sunny.\n",
"[Prompt tokens: 90, Completion tokens: 14]\n",
"---------- weather_agent ----------\n",
"TERMINATE\n",
"[Prompt tokens: 137, Completion tokens: 4]\n",
"---------- Summary ----------\n",
"Number of messages: 5\n",
"Finish reason: Text 'TERMINATE' mentioned\n",
"Total prompt tokens: 306\n",
"Total completion tokens: 33\n",
"Duration: 1.43 seconds\n"
]
}
],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
"from autogen_agentchat.task import Console, TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"\n",
"# Define a tool\n",
"async def get_weather(city: str) -> str:\n",
" return f\"The weather in {city} is 73 degrees and Sunny.\"\n",
"\n",
"\n",
"async def main() -> None:\n",
" # Define an agent\n",
" weather_agent = AssistantAgent(\n",
" name=\"weather_agent\",\n",
" model_client=OpenAIChatCompletionClient(\n",
" model=\"gpt-4o-2024-08-06\",\n",
" # api_key=\"YOUR_API_KEY\",\n",
" ),\n",
" tools=[get_weather],\n",
" )\n",
"\n",
" # Define termination condition\n",
" termination = TextMentionTermination(\"TERMINATE\")\n",
"\n",
" # Define a team\n",
" agent_team = RoundRobinGroupChat([weather_agent], termination_condition=termination)\n",
"\n",
" # Run the team and stream messages to the console\n",
" stream = agent_team.run_stream(task=\"What is the weather in New York?\")\n",
" await Console(stream)\n",
"\n",
"\n",
"# NOTE: if running this inside a Python script you'll need to use asyncio.run(main()).\n",
"await main()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The code snippet above introduces two high level concepts in AgentChat: *Agent* and *Team*. An Agent helps us define what actions are taken when a message is received. Specifically, we use the {py:class}`~autogen_agentchat.agents.AssistantAgent` preset - an agent that can be given access to a model (e.g., LLM) and tools (functions) that it can then use to address tasks. A Team helps us define the rules for how agents interact with each other. In the {py:class}`~autogen_agentchat.teams.RoundRobinGroupChat` team, agents respond in a sequential round-robin fashion.\n",
"In this case, we have a single agent, so the same agent is used for each round."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What's Next?\n",
"\n",
"Now that you have a basic understanding of how to define an agent and a team, consider following the [tutorial](./tutorial/index) for a walkthrough on other features of AgentChat.\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ myst:

# Tutorial

Tutorial to get started with AgentChat.

```{include} ../warning.md
```
Get started with AgentChat through this comprehensive tutorial.

::::{grid} 2 2 2 3
:gutter: 3
Expand Down
Loading

0 comments on commit a4d04ba

Please sign in to comment.