"Welcome! AutoGen is an open-source framework that leverages multiple _agents_ to enable complex workflows. This tutorial introduces basic concepts and building blocks of AutoGen."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Why AutoGen?\n",
"\n",
"> _The whole is greater than the sum of its parts._<br/>\n",
"While there are many definitions of agents, in AutoGen, an agent is an entity that can send messages, receive messages and generate reply using models, tools, human inputs or a mixture of them.\n",
"This abstraction not only allows agents to model real-world and abstract entities, such as people and algorithms, but it also simplifies implementation of complex workflows as collaboration among agents.\n",
"Further, AutoGen is extensible and composable: you can extend a simple agent with customizable components and create workflows that can combine these agents and power a more sophisticated agent, resulting in implementations that are modular and easy to maintain.\n",
" code_execution_config=False, # Turn off code execution, by default it is off.\n",
" function_map=None, # No registered functions, by default it is None.\n",
" human_input_mode=\"NEVER\", # Never ask for human input.\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `llm_config` argument contains a list of configurations for the LLMs.\n",
"See [LLM Configuration](/docs/topics/llm_configuration) for more details."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can ask this agent to generate a response to a question using the `generate_reply` method:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sure, here's one for you:\n",
"\n",
"Why don't scientists trust atoms? \n",
"\n",
"Because they make up everything!\n"
]
}
],
"source": [
"reply = agent.generate_reply(messages=[{\"content\": \"Tell me a joke.\", \"role\": \"user\"}])\n",
"print(reply)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Roles and Conversations\n",
"\n",
"In AutoGen, you can assign roles to agents and have them participate in conversations or chat with each other. A conversation is a sequence of messages exchanged between agents. You can then use these conversations to make progress on a task. For example, in the example below, we assign different roles to two agents by setting their\n",
"`system_message`."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"cathy = ConversableAgent(\n",
" \"cathy\",\n",
" system_message=\"Your name is Cathy and you are a part of a duo of comedians.\",\n",