Skip to main content

PilottAI Agent Examples

This directory contains example implementations showing how to create and use different types of agents with the PilottAI framework.

Overview

The examples demonstrate how to:
  • Set up multiple specialized agents
  • Create and configure tools
  • Execute jobs across different agents
  • Use the PilottAI Serve orchestrator

Installation

  1. Install PilottAI:
pip install pilott
  1. Set up your OpenAI API key:
export OPENAI_API_KEY="your-api-key"

Included Examples

Agents

  • Customer Service Agent: Handles customer inquiries and support requests
  • Document Processor: Processes and analyzes documents
  • Research Analyst: Conducts research and provides insights

Tools

  • Email Sender: Tool for sending emails to customers
  • Document Processor: Tool for document analysis and processing

Usage

Run the examples:
from examples.agents import main

# Run the example
import asyncio
asyncio.run(main())

Example Output

Job: Handle refund request
Result: Customer refund request processed successfully

Job: Analyze quarterly report
Result: Document analysis complete: 3 key insights found

Job: Research competitor pricing
Result: Market research analysis completed

Creating Your Own Agents

  1. Configure the agent:
agent_config = AgentConfig(
    title="your_agent_title",
    goal="your_agent_goal",
    tools=["tool1", "tool2"]
)
  1. Add to PilottAI:
agent = await pilott.add_agent(
    title=agent_config.title,
    goal=agent_config.goal,
    tools=agent_config.tools,
    llm_config=llm_config
)

Best Practices

  1. Agent Design
    • Give each agent a clear, focused title
    • Provide specific goals and tools
    • Use appropriate LLM configurations
  2. Tool Management
    • Create reusable tools
    • Define clear tool interfaces
    • Handle tool errors gracefully
  3. Job Execution
    • Group related jobs
    • Set appropriate priorities
    • Monitor execution results

Configuration Options

LLM Configuration

llm_config = LLMConfig(
    model_name="gpt-4",  # or other models
    provider="openai",   # or other providers
    temperature=0.7     # adjust based on needs
)

Tool Configuration

tool = Tool(
    name="tool_name",
    description="tool_description",
    function=your_function,
    parameters={
        "param1": "type1",
        "param2": "type2"
    }
)

Error Handling

The examples include basic error handling. In production, you should:
  • Add comprehensive error handling
  • Implement retries for failed jobs
  • Log errors appropriately
  • Handle API rate limits

Contributing

Feel free to:
  • Add new agent examples
  • Create additional tools
  • Improve documentation
  • Report issues
  • Submit pull requests

Code

Ready to use code customer_service.py
I