This folder contains basic examples demonstrating core Swarm capabilities. These examples show the simplest implementations of Swarm, with one input message, and a corresponding output. The simple_loop_no_helpers
has a while loop to demonstrate how to create an interactive Swarm session.
-
agent_handoff.py
- Demonstrates how to transfer a conversation from one agent to another.
- Usage: Transfers Spanish-speaking users from an English agent to a Spanish agent.
-
bare_minimum.py
- A bare minimum example showing the basic setup of an agent.
- Usage: Sets up an agent that responds to a simple user message.
-
context_variables.py
- Shows how to use context variables within an agent.
- Usage: Uses context variables to greet a user by name and print account details.
-
function_calling.py
- Demonstrates how to define and call functions from an agent.
- Usage: Sets up an agent that can respond with weather information for a given location.
-
simple_loop_no_helpers.py
- An example of a simple interaction loop without using helper functions.
- Usage: Sets up a loop where the user can continuously interact with the agent, printing the conversation.
To run any of the examples, use the following command:
python3 <example_name>.py