1
Define the tool
2
Using the Agent class (Recommended)
The Agent class provides a more convenient interface with persistent state and better organization:
The Agent class is the recommended approach for most use cases. It provides persistent state,
better error handling, and a cleaner interface for multi-turn conversations.
3
Low-level approach (Advanced)
For advanced use cases, you can use the lower-level
generate_text function directly: