Creating Agents
Agents are the core building blocks of Flo AI. They represent AI-powered entities that can process inputs, use tools, and generate responses.AgentBuilder Methods
TheAgentBuilder class provides a fluent interface for configuring agents. All methods return self for method chaining. Here’s a complete reference:
Note:
with_llm() is required before calling build(). All other methods are optional.
Basic Agent Creation
Create a simple conversational agent:Agent Configuration
Configure agents with various options:Agent Types
Conversational Agents
Basic agents for chat and Q&A:Tool-Using Agents
Agents that can use external tools:Structured Output Agents
Agents that return structured data:Agent Capabilities
Variable Resolution
Use dynamic variables in agent prompts:Document Processing
Process PDF and text documents:Error Handling
Built-in retry mechanisms and error recovery:Conversation History
Agents automatically maintain conversation history across multiple interactions. Therun() method returns the complete conversation history as a list of messages.
Accessing Conversation History
The conversation history is stored in theconversation_history attribute:
Clearing History
Clear the conversation history to start a new conversation:Manual History Management
You can manually add messages to the conversation history:Best Practices
Prompt Engineering
- Be specific: Clearly define the agent’s role and capabilities
- Use examples: Provide examples of expected inputs and outputs
- Set boundaries: Define what the agent should and shouldn’t do
Model Selection
Choose the right model for your use case:- GPT-4o: Best for complex reasoning and analysis
- GPT-4o-mini: Good balance of performance and cost
- Claude-3.5-Sonnet: Excellent for creative tasks
- Gemini: Good for multilingual applications

