File size: 940 Bytes
26fe3e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab78f68
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from pydantic import BaseModel
from agents import Agent

HOW_MANY_SEARCHES = 3

INSTRUCTIONS = f"You are a helpful research assistant. Given a query, come up with a set of web searches \
to perform to best answer the query. Output {HOW_MANY_SEARCHES} terms to query for."


class WebSearchItem(BaseModel):
    reason: str
    "Your reasoning for why this search is important to the query."

    query: str
    "The search term to use for the web search."


class WebSearchPlan(BaseModel):
    searches: list[WebSearchItem]
    """A list of web searches to perform to best answer the query."""


def create_planner_agent(model: str = "gpt-4o-mini"):
    """Create a planner agent with configurable model"""
    return Agent(
        name="PlannerAgent",
        instructions=INSTRUCTIONS,
        model=model,
        output_type=WebSearchPlan,
    )

# Default planner agent for backward compatibility
planner_agent = create_planner_agent()