Skip to main content

A programming framework for agentic AI

Project description

PyPI version Build Python Version Discord Twitter

AG2

📚 Cite paper.

[!IMPORTANT]

:fire: :tada: Nov 11, 2024: We are evolving AutoGen into AG2! A new organization ag2ai is created to host the development of AG2 and related projects with open governance. We invite collaborators from all organizations and individuals to join the development.

:fire: :tada: AG2 is available via ag2 (or its alias autogen or pyautogen) on PyPI! Starting with version 0.3.2, you can now install AG2 using:

pip install ag2

or

pip install pyautogen

or

pip install autogen

📄 License: We adopt the Apache 2.0 license from v0.3. This enhances our commitment to open-source collaboration while providing additional protections for contributors and users alike.

:tada: May 29, 2024: DeepLearning.ai launched a new short course AI Agentic Design Patterns with AutoGen, made in collaboration with Microsoft and Penn State University, and taught by AutoGen creators Chi Wang and Qingyun Wu.

:tada: May 24, 2024: Foundation Capital published an article on Forbes: The Promise of Multi-Agent AI and a video AI in the Real World Episode 2: Exploring Multi-Agent AI and AutoGen with Chi Wang.

:tada: May 13, 2024: The Economist published an article about multi-agent systems (MAS) following a January 2024 interview with Chi Wang.

:tada: May 11, 2024: AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation received the best paper award at the ICLR 2024 LLM Agents Workshop.

:tada: Apr 17, 2024: Andrew Ng cited AutoGen in The Batch newsletter and What's next for AI agentic workflows at Sequoia Capital's AI Ascent (Mar 26).

:tada: Mar 3, 2024: What's new in AutoGen? 📰Blog; 📺Youtube.

:tada: Dec 31, 2023: AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation Framework is selected by TheSequence: My Five Favorite AI Papers of 2023.

:tada: Nov 8, 2023: AutoGen is selected into Open100: Top 100 Open Source achievements 35 days after spinoff from FLAML.

:tada: Mar 29, 2023: AutoGen is first created in FLAML.

What is AG2

AG2 (formally AutoGen) is an open-source programming framework for building AI agents and facilitating cooperation among multiple agents to solve tasks. AG2 aims to streamline the development and research of agentic AI, much like PyTorch does for Deep Learning. It offers features such as agents capable of interacting with each other, facilitates the use of various large language models (LLMs) and tool use support, autonomous and human-in-the-loop workflows, and multi-agent conversation patterns.

Open Source Statement: The project welcomes contributions from developers and organizations worldwide. Our goal is to foster a collaborative and inclusive community where diverse perspectives and expertise can drive innovation and enhance the project's capabilities. Whether you are an individual contributor or represent an organization, we invite you to join us in shaping the future of this project. Together, we can build something truly remarkable.

The project is currently maintained by a dynamic group of volunteers from several organizations. Contact project administrators Chi Wang and Qingyun Wu via support@ag2.ai if you are interested in becoming a maintainer.

AutoGen Overview

↑ Back to Top ↑

Quickstart

The easiest way to start playing is

  1. Click below to use the GitHub Codespace

    Open in GitHub Codespaces

  2. Copy OAI_CONFIG_LIST_sample to ./notebook folder, name to OAI_CONFIG_LIST, and set the correct configuration.

  3. Start playing with the notebooks!

NOTE: OAI_CONFIG_LIST_sample lists gpt-4o as the default model. If you use a different model, you may need to revise various system prompts (especially if using weaker models like gpt-4o-mini). Proceed with caution when updating this default and be aware of additional risks related to alignment and safety.

↑ Back to Top ↑

Installation

Option 1. Install and Run AG2 in Docker

Find detailed instructions for users here, and for developers here.

Option 2. Install AG2 Locally

AG2 requires Python version >= 3.8, < 3.13. It can be installed from pip:

pip install ag2

Minimal dependencies are installed without extra options. You can install extra options based on the feature you need.

Find more options in Installation.

Even if you are installing and running AG2 locally outside of docker, the recommendation and default behavior of agents is to perform code execution in docker. Find more instructions and how to change the default behaviour here.

For LLM inference configurations, check the FAQs.

↑ Back to Top ↑

Multi-Agent Conversation Framework

AG2 enables the next-gen LLM applications with a generic multi-agent conversation framework. It offers customizable and conversable agents that integrate LLMs, tools, and humans. By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code.

Features of this use case include:

  • Multi-agent conversations: AG2 agents can communicate with each other to solve tasks. This allows for more complex and sophisticated applications than would be possible with a single LLM.
  • Customization: AG2 agents can be customized to meet the specific needs of an application. This includes the ability to choose the LLMs to use, the types of human input to allow, and the tools to employ.
  • Human participation: AG2 seamlessly allows human participation. This means that humans can provide input and feedback to the agents as needed.

For example,

from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
# Load LLM inference endpoints from an env variable or a file
# See https://ag2ai.github.io/ag2/docs/FAQ#set-your-api-endpoints
# and OAI_CONFIG_LIST_sample
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
# You can also set config_list directly as a list, for example, config_list = [{'model': 'gpt-4o', 'api_key': '<your OpenAI API key here>'},]
assistant = AssistantAgent("assistant", llm_config={"config_list": config_list})
user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding", "use_docker": False}) # IMPORTANT: set to True to run code in docker, recommended
user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.")
# This initiates an automated chat between the two agents to solve the task

This example can be run with

python test/twoagent.py

After the repo is cloned. The figure below shows an example conversation flow with AG2.

Agent Chat Example

Alternatively, the sample code here allows a user to chat with an AG2 agent in ChatGPT style. Please find more code examples for this feature.

↑ Back to Top ↑

Enhanced LLM Inferences

AG2 also helps maximize the utility out of the expensive LLMs such as gpt-4o. It offers enhanced LLM inference with powerful functionalities like caching, error handling, multi-config inference and templating.

↑ Back to Top ↑

Documentation

You can find detailed documentation about AG2 here.

In addition, you can find:

↑ Back to Top ↑

CookBook

Explore detailed implementations with sample code and applications to help you get started with AG2. Cookbook

Related Papers

AG2

@inproceedings{wu2023autogen,
      title={AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation Framework},
      author={Qingyun Wu and Gagan Bansal and Jieyu Zhang and Yiran Wu and Beibin Li and Erkang Zhu and Li Jiang and Xiaoyun Zhang and Shaokun Zhang and Jiale Liu and Ahmed Hassan Awadallah and Ryen W White and Doug Burger and Chi Wang},
      year={2023},
      eprint={2308.08155},
      archivePrefix={arXiv},
      primaryClass={cs.AI}
}

EcoOptiGen

@inproceedings{wang2023EcoOptiGen,
    title={Cost-Effective Hyperparameter Optimization for Large Language Model Generation Inference},
    author={Chi Wang and Susan Xueqing Liu and Ahmed H. Awadallah},
    year={2023},
    booktitle={AutoML'23},
}

MathChat

@inproceedings{wu2023empirical,
    title={An Empirical Study on Challenging Math Problem Solving with GPT-4},
    author={Yiran Wu and Feiran Jia and Shaokun Zhang and Hangyu Li and Erkang Zhu and Yue Wang and Yin Tat Lee and Richard Peng and Qingyun Wu and Chi Wang},
    year={2023},
    booktitle={ArXiv preprint arXiv:2306.01337},
}

AgentOptimizer

@article{zhang2024training,
  title={Training Language Model Agents without Modifying Language Models},
  author={Zhang, Shaokun and Zhang, Jieyu and Liu, Jiale and Song, Linxin and Wang, Chi and Krishna, Ranjay and Wu, Qingyun},
  journal={ICML'24},
  year={2024}
}

StateFlow

@article{wu2024stateflow,
  title={StateFlow: Enhancing LLM Task-Solving through State-Driven Workflows},
  author={Wu, Yiran and Yue, Tianwei and Zhang, Shaokun and Wang, Chi and Wu, Qingyun},
  journal={arXiv preprint arXiv:2403.11322},
  year={2024}
}

↑ Back to Top ↑

Contributors Wall

↑ Back to Top ↑

License

This project is licensed under the Apache License, Version 2.0 (Apache-2.0).

This project is a spin-off of https://github.com/microsoft/autogen and contains code under two licenses:

We have documented these changes for clarity and to ensure transparency with our user and contributor community. For more details, please see the NOTICE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyautogen-0.3.2b2.tar.gz (306.4 kB view details)

Uploaded Source

Built Distribution

pyautogen-0.3.2b2-py3-none-any.whl (352.1 kB view details)

Uploaded Python 3

File details

Details for the file pyautogen-0.3.2b2.tar.gz.

File metadata

  • Download URL: pyautogen-0.3.2b2.tar.gz
  • Upload date:
  • Size: 306.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pyautogen-0.3.2b2.tar.gz
Algorithm Hash digest
SHA256 908b1e1ef9eaae6567ccd19c1351bfff89d198a278a60a047beef9e43a4fd7d5
MD5 91f02bd96dba3caf4adff3539596eb43
BLAKE2b-256 509c160a7eb9056377975a311b29403e00fded9a71023e45f838751a9cf21d58

See more details on using hashes here.

File details

Details for the file pyautogen-0.3.2b2-py3-none-any.whl.

File metadata

  • Download URL: pyautogen-0.3.2b2-py3-none-any.whl
  • Upload date:
  • Size: 352.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pyautogen-0.3.2b2-py3-none-any.whl
Algorithm Hash digest
SHA256 96bba9f9bc17af4500d3d059b0babc1c96f69fb91f4f74bb7bbd01f1c961fa58
MD5 ef85d82291c8b0b381124720f2ca801c
BLAKE2b-256 48dd6b5ac97f8073465306467578c1aad42f8058979e7f5cf7e481243968f732

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page