CoolFace
Apppublic

ruDra2916/KnowSphere

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
planner_agent.py23 linesDownload Raw Back to root
1from pydantic import BaseModel, Field
2from agents import Agent
3
4HOW_MANY_SEARCHES = 3
5
6INSTRUCTIONS = f"You are a helpful research assistant. Given a query, come up with a set of web searches \
7to perform to best answer the query. Output {HOW_MANY_SEARCHES} terms to query for."
8
9
10class WebSearchItem(BaseModel):
11    reason: str = Field(description="Your reasoning for why this search is important to the query.")
12    query: str = Field(description="The search term to use for the web search.")
13
14
15class WebSearchPlan(BaseModel):
16    searches: list[WebSearchItem] = Field(description="A list of web searches to perform to best answer the query.")
17    
18planner_agent = Agent(
19    name="PlannerAgent",
20    instructions=INSTRUCTIONS,
21    model="gpt-4o-mini",
22    output_type=WebSearchPlan,
23)