deep_research / planner_agent.py
Hafeefa's picture
Upload folder using huggingface_hub
5227ce9 verified
from pydantic import BaseModel, Field
from agents import Agent
import json
HOW_MANY_SEARCHES = 5
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.
Your output must be a valid JSON object with a 'searches' key containing a list of objects
with 'query' and 'reason' keys.
Example: {{"searches": [{{"query": "term", "reason": "why"}}]}}
Do not include markdown code blocks or extra text."""
class WebSearchItem(BaseModel):
reason: str = Field(description="Your reasoning for why this search is important to the query.")
query: str = Field(description="The search term to use for the web search.")
class WebSearchPlan(BaseModel):
searches: list[WebSearchItem] = Field(description="A list of web searches to perform to best answer the query.")
planner_agent = Agent(
name="PlannerAgent",
instructions=INSTRUCTIONS,
model="llama-3.3-70b-versatile",
)