-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_agent.py
More file actions
38 lines (31 loc) · 1.59 KB
/
search_agent.py
File metadata and controls
38 lines (31 loc) · 1.59 KB
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
34
35
36
37
38
"""
Agent definition for searching events in a city.
"""
from pydantic import BaseModel, Field
from typing import List
from agents import Agent, WebSearchTool
class EventDetails(BaseModel):
"""Structured data model for event details."""
name: str = Field(..., description="The official name of the event.")
location: str = Field(..., description="The venue or address where the event takes place.")
date: str = Field(..., description="The date(s) or date range of the event.")
popularity: int = Field(
...,
description="An estimated popularity score (integer, should be non-negative), higher means more popular.",
# ge=0, # Removed: Causes schema validation error with some models
)
# Define the Search Agent
search_agent = Agent(
name="City Event Search Agent",
instructions=(
"You are an expert event finder. Your task is to search the web for public events "
"(like exhibitions, sports events, concerts, festivals, etc.) happening in the city "
"specified by the user. Use the web search tool provided. "
"Return a list of found events, extracting the required information for each event. "
"Assign a popularity score based on factors like expected attendance, media coverage, or general public interest, "
"where a higher number indicates greater popularity. If popularity is unknown, estimate reasonably or use 0."
),
tools=[WebSearchTool()], # Use the web search tool
output_type=List[EventDetails], # Expect a list of structured event data
model="gpt-4.1", # Or specify another suitable model
)