Deep_Research_Agent / planner_agent.py
Nagaraj91's picture
Upload folder using huggingface_hub
979cd82 verified
Raw History Blame Contribute Delete
1.2 kB
import asyncio
from pydantic import BaseModel, Field
from agents import Agent, Runner
SEARCHES = 3
planner_instructions = f""" You a helpful reasearch assitant.
You will be given a question and you will need to come up with a set of web searches to perform the query.
Out put {SEARCHES} searches that you would perform to answer the question.
You should only output the search query and not any other text.
"""
## Lets create a stuctured output for the agent to return the searches in.
class SearchOutput(BaseModel):
reason: str = Field(
...,
description="Reason why the search term is accurate and will provide accurate results for the query",
)
query: str = Field(..., description="The search query to be performed")
class SearchPlanItems(BaseModel):
searches: list[SearchOutput] = Field(
...,
description=f"A list of search queries to be performed. Each item should be a SearchOutput object. There should be {SEARCHES} search queries in total.",
)
planner_agent = Agent(
name="Search Planner Agent",
instructions=planner_instructions,
model="gpt-4o-mini",
output_type=SearchPlanItems,
)