refactors and ui enhancements

This commit is contained in:
Steve Androulakis
2025-01-04 11:27:59 -08:00
parent 43904650dd
commit 010518c16e
11 changed files with 90 additions and 77 deletions

35
tools/goal_registry.py Normal file
View File

@@ -0,0 +1,35 @@
from models.tool_definitions import AgentGoal
from tools.tool_registry import (
find_events_tool,
search_flights_tool,
create_invoice_tool,
)
goal_event_flight_invoice = AgentGoal(
tools=[find_events_tool, search_flights_tool, create_invoice_tool],
description="Help the user gather args for these tools in order: "
"1. FindEvents: Find an event to travel to "
"2. SearchFlights: search for a flight around the event dates "
"3. GenerateInvoice: Create a simple invoice for the cost of that flight ",
example_conversation_history="\n ".join(
[
"user: I'd like to travel to an event",
"agent: Sure! Let's start by finding an event you'd like to attend. Could you tell me which city and month you're interested in?",
"user: In Sao Paulo, Brazil, in February",
"agent: Great! Let's find an events in Sao Paulo, Brazil in February.",
"user_confirmed_tool_run: <user clicks confirm on FindEvents tool>",
"tool_result: { 'event_name': 'Carnival', 'event_date': '2023-02-25' }",
"agent: Found an event! There's Carnival on 2023-02-25, ending on 2023-02-28. Would you like to search for flights around these dates?",
"user: Yes, please",
"agent: Let's search for flights around these dates. Could you provide your departure city?",
"user: New York",
"agent: Thanks, searching for flights from New York to Sao Paulo 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 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

@@ -40,7 +40,7 @@ def search_airport(query: str) -> list:
return []
def search_flights(args: dict) -> dict:
def search_flights_realapi(args: dict) -> dict:
"""
1) Looks up airport/city codes via search_airport.
2) Finds the first matching skyId/entityId for both origin & destination.
@@ -169,26 +169,31 @@ def search_flights(args: dict) -> dict:
}
def search_flights_example(args: dict) -> dict:
def search_flights(args: dict) -> dict:
"""
Example function for searching flights.
Currently just prints/returns the passed args,
but you can add real flight search logic later.
Returns example flight search results in the requested JSON format.
"""
# date_depart = args.get("dateDepart")
# date_return = args.get("dateReturn")
origin = args.get("origin")
destination = args.get("destination")
flight_search_results = {
"origin": f"{origin}",
"destination": f"{destination}",
return {
"currency": "USD",
"destination": f"{destination}",
"origin": f"{origin}",
"results": [
{"flight_number": "CX101", "return_flight_number": "CX102", "price": 850.0},
{"flight_number": "QF30", "return_flight_number": "QF29", "price": 920.0},
{"flight_number": "MH129", "return_flight_number": "MH128", "price": 780.0},
{
"operating_carrier": "American Airlines",
"outbound_flight_code": "AA203",
"price": 1262.51,
"return_flight_code": "AA202",
"return_operating_carrier": "American Airlines",
},
{
"operating_carrier": "Air New Zealand",
"outbound_flight_code": "NZ488",
"price": 1396.00,
"return_flight_code": "NZ527",
"return_operating_carrier": "Air New Zealand",
},
],
}
return flight_search_results