Spaces:
Sleeping
Sleeping
Download planner_agent.py from Nagaraj91/Deep_Research_Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/Nagaraj91/Deep_Research_Agent/resolve/main/planner_agent.py
- Command line
-
hf download hf://spaces/Nagaraj91/Deep_Research_Agent/planner_agent.py
-
curl -L -o planner_agent.py https://huggingface.co/spaces/Nagaraj91/Deep_Research_Agent/resolve/main/planner_agent.py
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, | |
| ) | |