Few-Shot Examples
Guide agent responses using few-shot prompting.
Few-shot prompting is a powerful technique where you provide a small number of sample interactions (typically 2 to 5) to guide your agent’s behavior. This method helps the agent understand the desired output format and task requirements by learning from the given examples, thereby improving performance without writing extensive instructions.
Crafting Effective Examples
- Provide Task Demonstrations: Use examples that clearly illustrate the tasks that your agents will perform.
- Use Realistic Scenarios: Include interactions that mirror actual conversations that your agent will handle.
- Use Preferred Tone and Style: Ensure the agent’s replies in your examples match your desired brand voice.
Defining Few-Shot Examples
In the Agency Swarm framework, few-shot examples are structured using the OpenAI message object format, including the role
and content
fields.
Example: Technical Support Agent:
The optional fields attachments
and metadata
can be included if needed but are not required for basic examples.
Using Few-Shot Examples
You can add few-shot examples to your agent either during initialization or afterward:
See more advanced features in Agent Class