2024-10-18 16:41:30 +02:00
# Samples
2024-06-17 17:54:27 -07:00
2024-10-18 16:41:30 +02:00
This directory contains sample apps that use AutoGen Core API.
See [core user guide ](../docs/src/user-guide/core-user-guide/ ) for notebook examples.
2024-06-25 13:23:29 -07:00
2024-06-28 23:15:46 -07:00
See [Running the examples ](#running-the-examples ) for instructions on how to run the examples.
2024-10-12 20:40:31 +05:30
- [`chess_game.py` ](chess_game.py ): an example with two chess player agents that executes its own tools to demonstrate tool use and reflection on tool use.
2024-09-25 04:26:26 -07:00
- [`slow_human_in_loop.py` ](slow_human_in_loop.py ): an example showing human-in-the-loop which waits for human input before making the tool call.
2024-07-24 20:01:01 +01:00
2024-06-28 23:15:46 -07:00
## Running the examples
### Prerequisites
2024-06-21 05:05:54 -07:00
2024-09-23 10:46:05 -04:00
First, you need a shell with AutoGen core and required dependencies installed.
2024-06-17 17:54:27 -07:00
2024-08-02 09:58:15 -07:00
### Using Azure OpenAI API
For Azure OpenAI API, you need to set the following environment variables:
2024-06-28 23:15:46 -07:00
```bash
2024-08-02 09:58:15 -07:00
export OPENAI_API_TYPE=azure
2024-09-11 17:57:06 -04:00
export AZURE_OPENAI_API_ENDPOINT=your_azure_openai_endpoint
2024-08-02 09:58:15 -07:00
export AZURE_OPENAI_API_VERSION=your_azure_openai_api_version
2024-06-28 23:15:46 -07:00
```
2024-09-23 10:46:05 -04:00
By default, we use Azure Active Directory (AAD) for authentication.
2024-08-02 09:58:15 -07:00
You need to run `az login` first to authenticate with Azure.
You can also
use API key authentication by setting the following environment variables:
2024-06-28 23:15:46 -07:00
```bash
export AZURE_OPENAI_API_KEY=your_azure_openai_api_key
```
2024-09-11 17:57:06 -04:00
This requires azure-identity installation:
```bash
pip install azure-identity
```
2024-08-02 09:58:15 -07:00
### Using OpenAI API
For OpenAI API, you need to set the following environment variables.
2024-06-28 23:15:46 -07:00
```bash
2024-08-02 09:58:15 -07:00
export OPENAI_API_TYPE=openai
export OPENAI_API_KEY=your_openai_api_key
2024-06-28 23:15:46 -07:00
```