autogen/python/packages/autogen-core/samples
Jack Gerrits b09e6777a4
Restructure extensions, update corresponding docs (#3826)
* Restructure extensions, update corresponding docs

* update tests, add deprecation messages

* fix tests

* update lockfile

---------
2024-10-17 15:06:16 -07:00
..
common Move tool use with intervention to cookbook; remove duplicated examples (#658) 2024-09-28 03:57:44 +00:00
worker Update pyright extends for core (#562) 2024-09-20 15:51:38 -04:00
README.md Correcting Typo in README.md (#3770) 2024-10-12 08:10:31 -07:00
chess_game.py Remove samples that have duplicates in documentation (#631) 2024-09-25 11:26:26 +00:00
coding_pub_sub.py Restructure extensions, update corresponding docs (#3826) 2024-10-17 15:06:16 -07:00
slow_human_in_loop.py Remove samples that have duplicates in documentation (#631) 2024-09-25 11:26:26 +00:00

README.md

Examples

This directory contains examples of how to use AutoGen core. See user guide and cookbooks for more examples.

See Running the examples for instructions on how to run the examples.

  • chess_game.py: an example with two chess player agents that executes its own tools to demonstrate tool use and reflection on tool use.
  • slow_human_in_loop.py: an example showing human-in-the-loop which waits for human input before making the tool call.

Running the examples

Prerequisites

First, you need a shell with AutoGen core and required dependencies installed.

Using Azure OpenAI API

For Azure OpenAI API, you need to set the following environment variables:

export OPENAI_API_TYPE=azure
export AZURE_OPENAI_API_ENDPOINT=your_azure_openai_endpoint
export AZURE_OPENAI_API_VERSION=your_azure_openai_api_version

By default, we use Azure Active Directory (AAD) for authentication. You need to run az login first to authenticate with Azure. You can also use API key authentication by setting the following environment variables:

export AZURE_OPENAI_API_KEY=your_azure_openai_api_key

This requires azure-identity installation:

pip install azure-identity

Using OpenAI API

For OpenAI API, you need to set the following environment variables.

export OPENAI_API_TYPE=openai
export OPENAI_API_KEY=your_openai_api_key

Running

To run an example, just run the corresponding Python script. For example:

hatch shell
python core/one_agent_direct.py

Or simply:

hatch run python core/one_agent_direct.py