merged old agent goal in with keynote goal

This commit is contained in:
Steve Androulakis
2025-02-20 15:30:54 -08:00
parent ed069d9521
commit 08672d79e3
10 changed files with 500 additions and 103 deletions

View File

@@ -3,6 +3,7 @@ from .search_flights import search_flights
from .search_trains import search_trains
from .search_trains import book_trains
from .create_invoice import create_invoice
from .find_events import find_events
def get_handler(tool_name: str):
@@ -16,5 +17,7 @@ def get_handler(tool_name: str):
return book_trains
if tool_name == "CreateInvoice":
return create_invoice
if tool_name == "FindEvents":
return find_events
raise ValueError(f"Unknown tool: {tool_name}")

View File

@@ -0,0 +1,252 @@
{
"Melbourne": [
{
"eventName": "Australian Open",
"dateFrom": "2025-01-13",
"dateTo": "2025-01-26",
"description": "A two-week Grand Slam tennis tournament featuring the world's top players, accompanied by various entertainment options including live music and family-friendly activities."
},
{
"eventName": "Melbourne International Comedy Festival",
"dateFrom": "2025-03-26",
"dateTo": "2025-04-20",
"description": "One of the world's largest comedy festivals, showcasing stand-up, cabaret, theatre, and street performances across numerous city venues."
},
{
"eventName": "Melbourne International Film Festival (MIFF)",
"dateFrom": "2025-08-07",
"dateTo": "2025-08-23",
"description": "Established in 1952, MIFF presents a diverse selection of Australian and international films, including features, documentaries, and shorts."
},
{
"eventName": "Melbourne Fringe Festival",
"dateFrom": "2025-09-17",
"dateTo": "2025-10-04",
"description": "An open-access arts festival featuring a wide array of art forms such as theatre, comedy, music, and digital art across various venues."
},
{
"eventName": "Moomba Festival",
"dateFrom": "2025-03-07",
"dateTo": "2025-03-10",
"description": "Australia's largest free community festival, celebrated over four days during the Labour Day long weekend, including a parade, live music, fireworks, and the famous Birdman Rally along the Yarra River."
},
{
"eventName": "White Night Melbourne",
"dateFrom": "2025-08-22",
"dateTo": "2025-08-24",
"description": "A dusk-to-dawn arts and cultural festival transforming the city with light installations, projections, music, and performances."
},
{
"eventName": "Melbourne Food and Wine Festival",
"dateFrom": "2025-03-19",
"dateTo": "2025-03-29",
"description": "A celebration of Victoria's culinary scene, featuring food and wine events, masterclasses, and dining experiences."
}
],
"Sydney": [
{
"eventName": "Sydney Gay and Lesbian Mardi Gras",
"dateFrom": "2025-02-14",
"dateTo": "2025-03-01",
"description": "One of the largest LGBTQ+ festivals globally, featuring a vibrant parade, parties, and cultural events celebrating diversity and inclusion."
},
{
"eventName": "Vivid Sydney",
"dateFrom": "2025-05-22",
"dateTo": "2025-06-13",
"description": "An annual festival of light, music, and ideas, transforming the city with mesmerizing light installations and projections."
},
{
"eventName": "Sydney Festival",
"dateFrom": "2025-01-08",
"dateTo": "2025-01-26",
"description": "A major arts festival presenting a diverse program of theatre, dance, music, and visual arts across the city."
},
{
"eventName": "Sculpture by the Sea, Bondi",
"dateFrom": "2025-10-23",
"dateTo": "2025-11-09",
"description": "An outdoor sculpture exhibition along the Bondi to Tamarama coastal walk, showcasing works by Australian and international artists."
},
{
"eventName": "Sydney Writers' Festival",
"dateFrom": "2025-04-27",
"dateTo": "2025-05-03",
"description": "An annual literary festival featuring talks, panel discussions, and workshops with acclaimed authors and thinkers."
},
{
"eventName": "Sydney Film Festival",
"dateFrom": "2025-06-04",
"dateTo": "2025-06-15",
"description": "One of the longest-running film festivals in the world, showcasing a diverse selection of local and international films."
}
],
"Auckland": [
{
"eventName": "Pasifika Festival",
"dateFrom": "2025-03-08",
"dateTo": "2025-03-09",
"description": "The largest Pacific Islands-themed festival globally, celebrating the diverse cultures of the Pacific with traditional cuisine, performances, and arts."
},
{
"eventName": "Auckland Arts Festival",
"dateFrom": "2025-03-11",
"dateTo": "2025-03-29",
"description": "A biennial multi-arts festival showcasing local and international artists in theatre, dance, music, and visual arts."
},
{
"eventName": "Auckland Writers Festival",
"dateFrom": "2025-05-13",
"dateTo": "2025-05-18",
"description": "An annual event bringing together international and local writers for discussions, readings, and workshops."
},
{
"eventName": "Auckland Diwali Festival",
"dateFrom": "2025-10-26",
"dateTo": "2025-10-27",
"description": "A vibrant celebration of Indian culture and the Hindu festival of Diwali, featuring performances, food stalls, and traditional activities."
}
],
"Brisbane": [
{
"eventName": "Brisbane Festival",
"dateFrom": "2025-09-05",
"dateTo": "2025-09-26",
"description": "A major international arts festival featuring theatre, music, dance, and visual arts, culminating in the Riverfire fireworks display."
},
{
"eventName": "NRL Magic Round",
"dateFrom": "2025-05-02",
"dateTo": "2025-05-04",
"description": "A rugby league extravaganza where all NRL matches for the round are played at Suncorp Stadium, attracting fans nationwide."
},
{
"eventName": "Brisbane International Film Festival",
"dateFrom": "2025-10-01",
"dateTo": "2025-10-11",
"description": "Showcasing a curated selection of films from around the world, including premieres and special events."
},
{
"eventName": "Brisbane Comedy Festival",
"dateFrom": "2025-02-22",
"dateTo": "2025-03-24",
"description": "A month-long comedy festival featuring local and international comedians in stand-up, sketch, and improv performances."
},
{
"eventName": "Brisbane Writers Festival",
"dateFrom": "2025-09-05",
"dateTo": "2025-09-08",
"description": "An annual literary festival celebrating books, writing, and ideas with author talks, panel discussions, and workshops."
},
{
"eventName": "Brisbane Asia Pacific Film Festival",
"dateFrom": "2025-11-29",
"dateTo": "2025-12-08",
"description": "Showcasing the best cinema from the Asia Pacific region, including features, documentaries, and short films."
}
],
"Perth": [
{
"eventName": "Perth Festival",
"dateFrom": "2025-02-07",
"dateTo": "2025-03-01",
"description": "Australia's longest-running cultural festival, offering a diverse program of music, theatre, dance, literature, and visual arts."
},
{
"eventName": "Fringe World Festival",
"dateFrom": "2025-01-16",
"dateTo": "2025-02-15",
"description": "One of the largest fringe festivals globally, featuring a vast array of performances including comedy, cabaret, theatre, and street arts."
},
{
"eventName": "Sculpture by the Sea",
"dateFrom": "2025-03-06",
"dateTo": "2025-03-23",
"description": "An annual outdoor sculpture exhibition along Cottesloe Beach, showcasing works from Australian and international artists."
},
{
"eventName": "Revelation Perth International Film Festival",
"dateFrom": "2025-07-03",
"dateTo": "2025-07-13",
"description": "A showcase of independent cinema, featuring a diverse selection of films, documentaries, and short films."
},
{
"eventName": "Perth Comedy Festival",
"dateFrom": "2025-04-22",
"dateTo": "2025-05-19",
"description": "A month-long comedy festival featuring local and international comedians in stand-up, sketch, and improv performances."
}
],
"Adelaide": [
{
"eventName": "Adelaide Festival",
"dateFrom": "2025-02-28",
"dateTo": "2025-03-15",
"description": "A premier arts festival offering a rich program of theatre, music, dance, and visual arts from renowned international and local artists."
},
{
"eventName": "Adelaide Fringe",
"dateFrom": "2025-02-14",
"dateTo": "2025-03-15",
"description": "The largest open-access arts festival in the Southern Hemisphere, featuring thousands of performances across various genres and venues."
},
{
"eventName": "SALA Festival",
"dateFrom": "2025-08-01",
"dateTo": "2025-08-31",
"description": "South Australia's largest visual arts festival, showcasing the work of local artists in exhibitions, workshops, and events."
},
{
"eventName": "OzAsia Festival",
"dateFrom": "2025-09-25",
"dateTo": "2025-10-11",
"description": "A celebration of Asian arts and culture, featuring performances, exhibitions, and events from across the region."
},
{
"eventName": "Adelaide Film Festival",
"dateFrom": "2025-10-16",
"dateTo": "2025-10-26",
"description": "Showcasing a diverse selection of Australian and international films, including features, documentaries, and shorts."
},
{
"eventName": "Adelaide Writers' Week",
"dateFrom": "2025-03-01",
"dateTo": "2025-03-06",
"description": "An annual literary festival featuring talks, panel discussions, and readings by acclaimed authors and thinkers."
}
],
"Wellington": [
{
"eventName": "New Zealand Festival of the Arts",
"dateFrom": "2025-02-21",
"dateTo": "2025-03-15",
"description": "The nation's largest celebration of contemporary arts and culture, featuring a diverse range of performances and exhibitions across various venues in Wellington.",
"url": "https://www.festival.nz/"
},
{
"eventName": "Wellington Jazz Festival",
"dateFrom": "2025-06-05",
"dateTo": "2025-06-09",
"description": "A five-day festival showcasing local and international jazz musicians in concerts, workshops, and community events.",
"url": "https://www.jazzfestival.co.nz/"
},
{
"eventName": "Wellington on a Plate",
"dateFrom": "2025-08-01",
"dateTo": "2025-08-16",
"description": "A culinary festival celebrating the city's food and beverage industry with special menus, events, and culinary experiences."
},
{
"eventName": "CubaDupa",
"dateFrom": "2025-03-28",
"dateTo": "2025-03-29",
"description": "A vibrant street festival in Wellington's Cuba Street, featuring music, dance, street performers, and food stalls."
},
{
"eventName": "Wellington Pasifika Festival",
"dateFrom": "2025-01-18",
"dateTo": "2025-01-19",
"description": "A celebration of Pacific Island culture with traditional performances, food stalls, and arts and crafts."
}
]
}

64
tools/find_events.py Normal file
View File

@@ -0,0 +1,64 @@
from datetime import datetime
from pathlib import Path
import json
def find_events(args: dict) -> dict:
search_city = args.get("city", "").lower()
search_month = args.get("month", "").capitalize()
file_path = Path(__file__).resolve().parent / "data" / "find_events_data.json"
if not file_path.exists():
return {"error": "Data file not found."}
try:
month_number = datetime.strptime(search_month, "%B").month
except ValueError:
return {"error": "Invalid month provided."}
# Helper to wrap months into [1..12]
def get_adjacent_months(m):
prev_m = 12 if m == 1 else (m - 1)
next_m = 1 if m == 12 else (m + 1)
return [prev_m, m, next_m]
valid_months = get_adjacent_months(month_number)
matching_events = []
for city_name, events in json.load(open(file_path)).items():
if search_city and search_city not in city_name.lower():
continue
for event in events:
date_from = datetime.strptime(event["dateFrom"], "%Y-%m-%d")
date_to = datetime.strptime(event["dateTo"], "%Y-%m-%d")
# If the event's start or end month is in our valid months
if date_from.month in valid_months or date_to.month in valid_months:
# Add metadata explaining how it matches
if date_from.month == month_number or date_to.month == month_number:
month_context = "requested month"
elif (
date_from.month == valid_months[0]
or date_to.month == valid_months[0]
):
month_context = "previous month"
else:
month_context = "next month"
matching_events.append(
{
"city": city_name,
"eventName": event["eventName"],
"dateFrom": event["dateFrom"],
"dateTo": event["dateTo"],
"description": event["description"],
"month": month_context,
}
)
# Add top-level metadata if you wish
return {
"note": f"Returning events from {search_month} plus one month either side (i.e., {', '.join(datetime(2025, m, 1).strftime('%B') for m in valid_months)}).",
"events": matching_events,
}

View File

@@ -5,6 +5,7 @@ from tools.tool_registry import (
search_trains_tool,
book_trains_tool,
create_invoice_tool,
find_events_tool,
)
goal_match_train_invoice = AgentGoal(
@@ -53,46 +54,31 @@ goal_match_train_invoice = AgentGoal(
# unused
goal_event_flight_invoice = AgentGoal(
tools=[
search_fixtures_tool,
find_events_tool,
search_flights_tool,
search_trains_tool,
create_invoice_tool,
],
description="Help the user gather args for these tools in order: "
"1. SearchFixtures: Search for fixtures for a team in a given month"
"2. SearchFlights: Search for a flight around the match dates"
"3. SearchTrains: Search for trains to visit somewhere before or after the match"
"4. BookTrain: Book the train tickets"
"5. CreateInvoice: Create a simple invoice for the cost of the flights and train tickets",
"1. FindEvents: Find an event to travel to "
"2. SearchFlights: search for a flight around the event dates "
"3. CreateInvoice: Create a simple invoice for the cost of that flight ",
starter_prompt="Welcome me, give me a description of what you can do, then ask me for the details you need to do your job",
example_conversation_history="\n ".join(
[
"user: I'd like to travel to a football match",
"agent: Sure! Let's start by finding an match you'd like to attend. I know about Premier League fixtures in the UK. Could you tell me which team and month you're interested in?",
"user: Wolves in May please",
"agent: Great! Let's find a match for Wolverhampton Wanderers FC in May.",
"user_confirmed_tool_run: <user clicks confirm on SearchFixtures tool, passing the full team name as an input>",
'tool_result: results including {"homeTeam": "Wolverhampton Wanderers FC", "awayTeam": "Manchester United", "date": "2025-05-04"}',
"agent: Found a match! There's an away game against Manchester United on May 4 2025. Would you like to search for flights around this date?",
"user: I'd like to travel to an event",
"agent: Sure! Let's start by finding an event you'd like to attend. I know about events in Australia and New Zealand cities. Could you tell me which city and month you're interested in?",
"user: sydney in may please",
"agent: Great! Let's find an events in Sydney in May.",
"user_confirmed_tool_run: <user clicks confirm on FindEvents tool>",
"tool_result: { 'event_name': 'Vivid Sydney', 'event_date': '2023-05-01' }",
"agent: Found an event! There's Vivid Sydney on May 1 2025, ending on May 14 2025. Would you like to search for flights around these dates?",
"user: Yes, please",
"agent: Let's search for flights around this date. Could you provide your departure city?",
"agent: Let's search for flights around these dates. Could you provide your departure city?",
"user: San Francisco",
"agent: Thanks, searching for flights from San Francisco to the Manchester around 2025-05-03 to 2025-05-05.",
"agent: Thanks, searching for flights from San Francisco to Sydney around 2023-02-25 to 2023-02-28.",
"user_confirmed_tool_run: <user clicks confirm on SearchFlights tool>"
'tool_result: results including {"flight_number": "CX101", "return_flight_number": "CX102", "price": 850.0}',
"agent: Found some flights! The cheapest is CX101 for $850. Would you like to go for this one?",
"user: Yes, please",
"agent: Great! So you're flying to the city the match is in, anywhere else you'd like to visit while you're there?",
"user: I'd like to visit my friend in Edinburgh after the match",
"agent: Got it! Let's search for trains from Manchester to Edinburgh and back.",
"user_confirmed_tool_run: <user clicks confirm on SearchTrains tool>",
'tool_result: results including {"train_number": "T1234", "price": 30.0}',
"agent: Found these train options! The cheapest is T1234 for $30. Would you like to go for this one?",
"user: Yes, please",
"agent: Great, lets book the train tickets",
"user_confirmed_tool_run: <user clicks confirm on BookTrain tool>",
'tool_result: results including {"status": "success"}',
"agent: Train tickets booked! Would you like me to create an invoice for the flights and train tickets?",
"agent: Found some flights! The cheapest is CX101 for $850. Would you like to generate an invoice for this flight?",
"user_confirmed_tool_run: <user clicks confirm on CreateInvoice tool>",
'tool_result: { "status": "success", "invoice": { "flight_number": "CX101", "amount": 850.0 }, invoiceURL: "https://example.com/invoice" }',
"agent: Invoice generated! Here's the link: https://example.com/invoice",

View File

@@ -37,10 +37,14 @@ def search_airport(query: str) -> list:
try:
return json.loads(data).get("data", [])
except json.JSONDecodeError:
print("Error: Failed to decode JSON response")
print(f"Response: {data.decode('utf-8')}")
return []
def search_flights(args: dict) -> dict: # _realapi
def search_flights_real_api(
args: dict,
) -> dict: # rename to search_flights to use the real API
"""
1) Looks up airport/city codes via search_airport.
2) Finds the first matching skyId/entityId for both origin & destination.
@@ -169,7 +173,7 @@ def search_flights(args: dict) -> dict: # _realapi
}
def search_flights_example(args: dict) -> dict:
def search_flights(args: dict) -> dict:
"""
Returns example flight search results in the requested JSON format.
"""
@@ -195,5 +199,19 @@ def search_flights_example(args: dict) -> dict:
"return_flight_code": "NZ527",
"return_operating_carrier": "Air New Zealand",
},
{
"operating_carrier": "United Airlines",
"outbound_flight_code": "UA100",
"price": 1500.00,
"return_flight_code": "UA101",
"return_operating_carrier": "United Airlines",
},
{
"operating_carrier": "Delta Airlines",
"outbound_flight_code": "DL200",
"price": 1600.00,
"return_flight_code": "DL201",
"return_operating_carrier": "Delta Airlines",
},
],
}

View File

@@ -104,3 +104,23 @@ search_fixtures_tool = ToolDefinition(
),
],
)
find_events_tool = ToolDefinition(
name="FindEvents",
description="Find upcoming events to travel to a given city (e.g., 'Melbourne') and a date or month. "
"It knows about events in Oceania only (e.g. major Australian and New Zealand cities). "
"It will search 1 month either side of the month provided. "
"Returns a list of events. ",
arguments=[
ToolArgument(
name="city",
type="string",
description="Which city to search for events",
),
ToolArgument(
name="month",
type="string",
description="The month to search for events (will search 1 month either side of the month provided)",
),
],
)