Skip to content
Search

AutoGen

lastmod 2025-04-11created 2025-04-113 edits

AutoGen is a framework for creating multi-agent AI applications that can act autonomously or work alongside humans.

Features

  • Multi-Agent conversation framework: integrates LLMs, tools, and humans through automated conversations between multiple agents
  • Supports various conversation patterns for complex workflows: static/dynamic conversations. Registered auto-replies, LLM-based function calling
  • Implementation examples: math problem solving, multi-agent coding, online decision-making, Retrieval-Augemented Chat, dynamic group chat, conversational chess

Ollama Coding Example

from autogen import AssistantAgent, UserProxyAgent

config_list = [
  {
    "model": "codellama",
    "base_url": "http://localhost:11434/v1",
    "api_key": "ollama",
  }
]

assistant = AssistantAgent("assistant", llm_config={"config_list": config_list})

user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding", "use_docker": False})
user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.")
  • AssistantAgent is the main actor in the conversation and provides the knowledge or information needed to perform a specific task. For example, it may be asked to visualize changes in stock prices. Through its LLM configuration, this agent can extract and process information from various data sources or APIs.
  • UserProxyAgent acts as the user's proxy, passing the user's requests or commands to the AssistantAgent. It also passes the information or results provided by the AssistantAgent back to the user. Through its code execution configuration, this agent can run actual code, or run code in a safe environment using Docker. At the user's request, it starts a conversation with the AssistantAgent and the two cooperate to perform the required tasks.
    • code_execution_config: this parameter is a dictionary containing settings related to code execution. It can include settings such as the following:
      • "work_dir": "coding": specifies the working directory for code execution. In this example, it means a directory named "coding" is used as the working directory. This directory can be used to store code files or hold execution results.
      • "use_docker": False: specifies whether to use Docker when running code. When set to False, code runs directly in the local environment without Docker. Using Docker isolates the execution environment and can improve security and compatibility, but here Docker usage is disabled.

See also

Favorite site

author Zer0 sitemap