mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 05:58:08 +01:00
Default to dummy data for tracking package
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
"status": "shipped",
|
||||
"order_date": "2025-04-01",
|
||||
"last_order_update": "2025-04-01",
|
||||
"tracking_id": "1Z111111"
|
||||
"tracking_id": "UPS67890"
|
||||
},
|
||||
{
|
||||
"id": "200",
|
||||
@@ -32,7 +32,7 @@
|
||||
"status": "shipped",
|
||||
"order_date": "2025-04-03",
|
||||
"last_update": "2025-04-06",
|
||||
"tracking_id": "991111"
|
||||
"tracking_id": "USPS12345"
|
||||
},
|
||||
{
|
||||
"id": "300",
|
||||
@@ -41,7 +41,7 @@
|
||||
"status": "shipped",
|
||||
"order_date": "2025-03-30",
|
||||
"last_update": "2025-04-06",
|
||||
"tracking_id": "991111"
|
||||
"tracking_id": "USPS12345"
|
||||
},
|
||||
{
|
||||
"id": "301",
|
||||
@@ -58,7 +58,7 @@
|
||||
"status": "delivered",
|
||||
"order_date": "2025-04-01",
|
||||
"last_update": "2025-04-06",
|
||||
"tracking_id": "1Z11111"
|
||||
"tracking_id": "UPS67890"
|
||||
},
|
||||
{
|
||||
"id": "400",
|
||||
@@ -67,7 +67,7 @@
|
||||
"status": "shipped",
|
||||
"order_date": "2025-04-03",
|
||||
"last_update": "2025-04-09",
|
||||
"tracking_id": "1Z111111"
|
||||
"tracking_id": "UPS67890"
|
||||
},
|
||||
{
|
||||
"id": "401",
|
||||
@@ -76,6 +76,6 @@
|
||||
"status": "processing",
|
||||
"order_date": "2025-04-03",
|
||||
"last_update": "2025-04-09"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
158
tools/data/dummy_tracking_data.json
Normal file
158
tools/data/dummy_tracking_data.json
Normal file
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"TrackingNumber": "USPS12345",
|
||||
"Delivered": false,
|
||||
"Carrier": "USPS",
|
||||
"ServiceType": "USPS Ground Advantage<SUP>™</SUP>",
|
||||
"PickupDate": "",
|
||||
"ScheduledDeliveryDate": "April 14, 2025",
|
||||
"ScheduledDeliveryDateInDateTimeFromat": "2025-04-14T00:00:00",
|
||||
"StatusCode": "In Transit from Origin Processing",
|
||||
"Status": "Departed Post Office",
|
||||
"StatusSummary": "Your item has left our acceptance facility and is in transit to a sorting facility on April 10, 2025 at 7:06 am in IRON RIDGE, WI 53035.",
|
||||
"Message": "",
|
||||
"DeliveredDateTime": "",
|
||||
"DeliveredDateTimeInDateTimeFormat": null,
|
||||
"SignatureName": "",
|
||||
"DestinationCity": "CITY",
|
||||
"DestinationState": "ST",
|
||||
"DestinationZip": "12345",
|
||||
"DestinationCountry": null,
|
||||
"EventDate": "2025-04-10T07:06:00",
|
||||
"TrackingDetails": [
|
||||
{
|
||||
"EventDateTime": "April 10, 2025 7:06 am",
|
||||
"Event": "Departed Post Office",
|
||||
"EventAddress": "IRON RIDGE WI 53035",
|
||||
"State": "WI",
|
||||
"City": "IRON RIDGE",
|
||||
"Zip": "53035",
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-10T07:06:00"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "April 9, 2025 11:29 am",
|
||||
"Event": "USPS picked up item",
|
||||
"EventAddress": "IRON RIDGE WI 53035",
|
||||
"State": "WI",
|
||||
"City": "IRON RIDGE",
|
||||
"Zip": "53035",
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-09T11:29:00"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "April 7, 2025 6:29 am",
|
||||
"Event": "Shipping Label Created, USPS Awaiting Item",
|
||||
"EventAddress": "IRON RIDGE WI 53035",
|
||||
"State": "WI",
|
||||
"City": "IRON RIDGE",
|
||||
"Zip": "53035",
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-07T06:29:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"TrackingNumber": "UPS67890",
|
||||
"Delivered": true,
|
||||
"Carrier": "UPS",
|
||||
"ServiceType": "UPS Ground Saver®",
|
||||
"PickupDate": "",
|
||||
"ScheduledDeliveryDate": "",
|
||||
"ScheduledDeliveryDateInDateTimeFromat": null,
|
||||
"StatusCode": "D",
|
||||
"Status": "DELIVERED",
|
||||
"StatusSummary": "DELIVERED",
|
||||
"Message": "",
|
||||
"DeliveredDateTime": "20250415 154315",
|
||||
"DeliveredDateTimeInDateTimeFormat": "2025-04-15T15:43:15",
|
||||
"SignatureName": "",
|
||||
"DestinationCity": "CHICAGO",
|
||||
"DestinationState": "IL",
|
||||
"DestinationZip": "",
|
||||
"DestinationCountry": "US",
|
||||
"EventDate": "2025-04-15T15:43:15",
|
||||
"TrackingDetails": [
|
||||
{
|
||||
"EventDateTime": "20250415 154315",
|
||||
"Event": "DELIVERED ",
|
||||
"EventAddress": "CHICAGO IL US",
|
||||
"State": "IL",
|
||||
"City": "CHICAGO",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-15T15:43:15"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250415 090938",
|
||||
"Event": "Out For Delivery Today",
|
||||
"EventAddress": "Chicago IL US",
|
||||
"State": "IL",
|
||||
"City": "Chicago",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-15T09:09:38"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250415 074141",
|
||||
"Event": "Loaded on Delivery Vehicle ",
|
||||
"EventAddress": "Chicago IL US",
|
||||
"State": "IL",
|
||||
"City": "Chicago",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-15T07:41:41"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250415 032200",
|
||||
"Event": "Arrived at Facility",
|
||||
"EventAddress": "Chicago IL US",
|
||||
"State": "IL",
|
||||
"City": "Chicago",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-15T03:22:00"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250414 223000",
|
||||
"Event": "Departed from Facility",
|
||||
"EventAddress": "Hodgkins IL US",
|
||||
"State": "IL",
|
||||
"City": "Hodgkins",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-14T22:30:00"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250414 002700",
|
||||
"Event": "Arrived at Facility",
|
||||
"EventAddress": "Hodgkins IL US",
|
||||
"State": "IL",
|
||||
"City": "Hodgkins",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-14T00:27:00"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250410 211700",
|
||||
"Event": "Departed from Facility",
|
||||
"EventAddress": "Las Vegas NV US",
|
||||
"State": "NV",
|
||||
"City": "Las Vegas",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-10T21:17:00"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250410 132625",
|
||||
"Event": "Arrived at Facility",
|
||||
"EventAddress": "Las Vegas NV US",
|
||||
"State": "NV",
|
||||
"City": "Las Vegas",
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-10T13:26:25"
|
||||
},
|
||||
{
|
||||
"EventDateTime": "20250409 100659",
|
||||
"Event": "Shipper created a label, UPS has not received the package yet. ",
|
||||
"EventAddress": " US",
|
||||
"State": null,
|
||||
"City": null,
|
||||
"Zip": null,
|
||||
"EventDateTimeInDateTimeFormat": "2025-04-09T10:06:59"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,10 +18,6 @@ def get_order(args: dict) -> dict:
|
||||
for order in order_list:
|
||||
if order["id"] == order_id:
|
||||
return order
|
||||
# if order["status"] == "shipped":
|
||||
# return{"status": order["status"], "tracking_id": order["tracking_id"]}
|
||||
# else:
|
||||
# return{"status": order["status"]}
|
||||
|
||||
return_msg = "Order " + order_id + " not found."
|
||||
return {"error": return_msg}
|
||||
@@ -2,12 +2,46 @@ import http
|
||||
import os
|
||||
import json
|
||||
|
||||
def track_package_faked(args: dict) -> dict:
|
||||
from pathlib import Path
|
||||
|
||||
#Send back dummy data in the correct format - to use the real API, 1) change this to be track_package_fake and 2) change the below track_package_real to be track_package
|
||||
def track_package(args: dict) -> dict:
|
||||
|
||||
tracking_id = args.get("tracking_id")
|
||||
file_path = Path(__file__).resolve().parent.parent / "data" / "dummy_tracking_data.json"
|
||||
if not file_path.exists():
|
||||
return {"error": "Data file not found."}
|
||||
|
||||
with open(file_path, "r") as file:
|
||||
data = json.load(file)
|
||||
package_list = data["packages"]
|
||||
|
||||
for package in package_list:
|
||||
if package["TrackingNumber"] == tracking_id:
|
||||
scheduled_delivery_date = package["ScheduledDeliveryDate"]
|
||||
carrier = package["Carrier"]
|
||||
status_summary = package["StatusSummary"]
|
||||
tracking_details = package.get("TrackingDetails", [])
|
||||
last_tracking_update = ""
|
||||
if tracking_details and tracking_details is not None and tracking_details[0] is not None:
|
||||
last_tracking_update = tracking_details[0]["EventDateTimeInDateTimeFormat"]
|
||||
|
||||
tracking_link = ""
|
||||
if carrier == "USPS":
|
||||
tracking_link = f"https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1={tracking_id}"
|
||||
elif carrier == "UPS":
|
||||
tracking_link = f"https://www.ups.com/track?track=yes&trackNums={tracking_id}"
|
||||
|
||||
return {
|
||||
"scheduled_delivery_date": scheduled_delivery_date,
|
||||
"carrier": carrier,
|
||||
"status_summary": status_summary,
|
||||
"tracking_link": tracking_link,
|
||||
"last_tracking_update": last_tracking_update
|
||||
}
|
||||
|
||||
#return_msg = "Account not found with email address " + email + " or account ID: " + account_id
|
||||
return {"tracking_info": "delivered, probably"}
|
||||
return_msg = "Package not found with tracking info " + tracking_id
|
||||
return {"error": return_msg}
|
||||
|
||||
'''Format of response:
|
||||
{
|
||||
@@ -61,7 +95,7 @@ def track_package_faked(args: dict) -> dict:
|
||||
]
|
||||
}
|
||||
'''
|
||||
def track_package(args: dict) -> dict:
|
||||
def track_package_real(args: dict) -> dict:
|
||||
|
||||
tracking_id = args.get("tracking_id")
|
||||
|
||||
|
||||
@@ -371,7 +371,9 @@ goal_fin_loan_application = AgentGoal(
|
||||
"user_confirmed_tool_run: <user clicks confirm on FinCheckAccountSubmitLoanApproval tool>",
|
||||
"tool_result: { 'status': submitted, 'detailed_status': loan application is submitted and initial validation is complete, 'confirmation id': 333421, 'next_step': You'll receive a confirmation for final approval in three business days }",
|
||||
"agent: I have submitted your loan application process and the initial validation is successful. Your application ID is 333421. You'll receive a notification for final approval from us in three business days. "
|
||||
|
||||
]
|
||||
),
|
||||
)
|
||||
# ----- E-Commerce Goals ---
|
||||
#todo: add goal to list all orders for last X amount of time?
|
||||
# this tool checks account balances, and uses ./data/customer_account_data.json as dummy data
|
||||
|
||||
@@ -333,6 +333,9 @@ financial_submit_loan_approval = ToolDefinition(
|
||||
name="amount",
|
||||
type="string",
|
||||
description="amount requested for the loan",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# ----- ECommerce Use Case Tools -----
|
||||
ecomm_list_orders = ToolDefinition(
|
||||
|
||||
Reference in New Issue
Block a user