You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Examples
  2. This directory contains examples of how to use AutoGen core.
  3. See [user guide](../docs/src/core-user-guide/guides/) and
  4. [cookbooks](../docs/src/core-user-guide/cookbook/) for more examples.
  5. See [Running the examples](#running-the-examples) for instructions on how to run the examples.
  6. - [`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.
  7. - [`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.
  8. ## Running the examples
  9. ### Prerequisites
  10. First, you need a shell with AutoGen core and required dependencies installed.
  11. ### Using Azure OpenAI API
  12. For Azure OpenAI API, you need to set the following environment variables:
  13. ```bash
  14. export OPENAI_API_TYPE=azure
  15. export AZURE_OPENAI_API_ENDPOINT=your_azure_openai_endpoint
  16. export AZURE_OPENAI_API_VERSION=your_azure_openai_api_version
  17. ```
  18. By default, we use Azure Active Directory (AAD) for authentication.
  19. You need to run `az login` first to authenticate with Azure.
  20. You can also
  21. use API key authentication by setting the following environment variables:
  22. ```bash
  23. export AZURE_OPENAI_API_KEY=your_azure_openai_api_key
  24. ```
  25. This requires azure-identity installation:
  26. ```bash
  27. pip install azure-identity
  28. ```
  29. ### Using OpenAI API
  30. For OpenAI API, you need to set the following environment variables.
  31. ```bash
  32. export OPENAI_API_TYPE=openai
  33. export OPENAI_API_KEY=your_openai_api_key
  34. ```
  35. ### Running
  36. To run an example, just run the corresponding Python script. For example:
  37. ```bash
  38. hatch shell
  39. python core/one_agent_direct.py
  40. ```
  41. Or simply:
  42. ```bash
  43. hatch run python core/one_agent_direct.py
  44. ```