mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 14:08:08 +01:00
Merge pull request #16 from joshmsmith/ecommerce
Fixes coming in delivered by the ecommerce branch: new ecommerce scenarios fixes for multi-goal:post first real goal goal switch: duplicate listagents behavior from the toolplanner adding ecommerce initial guidance fixed new-goal guidance prompts for multi-goal mode (minor) fixed abug in money movement so it won't connect to temporal cloud if it's not doing a real workflow (minor) fixed abug in loan application so it won't connect to temporal cloud if it's not doing a real workflow some todo notes cleanup
This commit is contained in:
@@ -187,7 +187,7 @@ def generate_pick_new_goal_guidance()-> str:
|
|||||||
str: A prompt string prompting the LLM to when to go to pick-new-goal
|
str: A prompt string prompting the LLM to when to go to pick-new-goal
|
||||||
"""
|
"""
|
||||||
if is_multi_goal_mode():
|
if is_multi_goal_mode():
|
||||||
return 'Next should only be "pick-new-goal" if all tools have been run (use the system prompt to figure that out) or the user explicitly requested to pick a new goal.'
|
return 'Next should only be "pick-new-goal" if all tools have been run for the current goal (use the system prompt to figure that out) and the last successful tool was not ListAgents, or the user explicitly requested to pick a new goal.'
|
||||||
else:
|
else:
|
||||||
return 'Next should never be "pick-new-goal".'
|
return 'Next should never be "pick-new-goal".'
|
||||||
|
|
||||||
|
|||||||
3
setup.md
3
setup.md
@@ -210,6 +210,9 @@ FIN_START_REAL_WORKFLOW=FALSE #set this to true to start a real workflow
|
|||||||
#### Goals: HR/PTO
|
#### Goals: HR/PTO
|
||||||
Make sure you have the mock users you want in (such as yourself) in [the PTO mock data file](./tools/data/employee_pto_data.json).
|
Make sure you have the mock users you want in (such as yourself) in [the PTO mock data file](./tools/data/employee_pto_data.json).
|
||||||
|
|
||||||
|
#### Goals: Ecommerce
|
||||||
|
Make sure you have the mock orders you want in (such as those with real tracking numbers) in [the mock orders file](./tools/data/customer_order_data.json).
|
||||||
|
|
||||||
|
|
||||||
## Customizing the Agent Further
|
## Customizing the Agent Further
|
||||||
- `tool_registry.py` contains the mapping of tool names to tool definitions (so the AI understands how to use them)
|
- `tool_registry.py` contains the mapping of tool names to tool definitions (so the AI understands how to use them)
|
||||||
|
|||||||
6
todo.md
6
todo.md
@@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
[ ] for demo simulate failure - add utilities/simulated failures from pipeline demo <br />
|
[ ] for demo simulate failure - add utilities/simulated failures from pipeline demo <br />
|
||||||
|
|
||||||
[ ] ecommerce goals <br />
|
[x] ecommerce goals <br />
|
||||||
- [ ] add to docs <br />
|
- [x] add to docs <br />
|
||||||
- [ ] decide about api key names with Laine <br />
|
- [x] decide about api key names with Laine <br />
|
||||||
|
|
||||||
[ ] LLM failure->autoswitch: <br />
|
[ ] LLM failure->autoswitch: <br />
|
||||||
- detect failure in the activity using failurecount <br />
|
- detect failure in the activity using failurecount <br />
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"status": "shipped",
|
"status": "shipped",
|
||||||
"order_date": "2025-04-01",
|
"order_date": "2025-04-01",
|
||||||
"last_order_update": "2025-04-01",
|
"last_order_update": "2025-04-01",
|
||||||
"tracking_id": "1Z111111"
|
"tracking_id": "UPS67890"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "200",
|
"id": "200",
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"status": "shipped",
|
"status": "shipped",
|
||||||
"order_date": "2025-04-03",
|
"order_date": "2025-04-03",
|
||||||
"last_update": "2025-04-06",
|
"last_update": "2025-04-06",
|
||||||
"tracking_id": "991111"
|
"tracking_id": "USPS12345"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "300",
|
"id": "300",
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
"status": "shipped",
|
"status": "shipped",
|
||||||
"order_date": "2025-03-30",
|
"order_date": "2025-03-30",
|
||||||
"last_update": "2025-04-06",
|
"last_update": "2025-04-06",
|
||||||
"tracking_id": "991111"
|
"tracking_id": "USPS12345"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "301",
|
"id": "301",
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
"status": "delivered",
|
"status": "delivered",
|
||||||
"order_date": "2025-04-01",
|
"order_date": "2025-04-01",
|
||||||
"last_update": "2025-04-06",
|
"last_update": "2025-04-06",
|
||||||
"tracking_id": "1Z11111"
|
"tracking_id": "UPS67890"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "400",
|
"id": "400",
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
"status": "shipped",
|
"status": "shipped",
|
||||||
"order_date": "2025-04-03",
|
"order_date": "2025-04-03",
|
||||||
"last_update": "2025-04-09",
|
"last_update": "2025-04-09",
|
||||||
"tracking_id": "1Z111111"
|
"tracking_id": "UPS67890"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "401",
|
"id": "401",
|
||||||
@@ -76,6 +76,6 @@
|
|||||||
"status": "processing",
|
"status": "processing",
|
||||||
"order_date": "2025-04-03",
|
"order_date": "2025-04-03",
|
||||||
"last_update": "2025-04-09"
|
"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:
|
for order in order_list:
|
||||||
if order["id"] == order_id:
|
if order["id"] == order_id:
|
||||||
return order
|
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_msg = "Order " + order_id + " not found."
|
||||||
return {"error": return_msg}
|
return {"error": return_msg}
|
||||||
@@ -2,12 +2,46 @@ import http
|
|||||||
import os
|
import os
|
||||||
import json
|
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")
|
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_msg = "Package not found with tracking info " + tracking_id
|
||||||
return {"tracking_info": "delivered, probably"}
|
return {"error": return_msg}
|
||||||
|
|
||||||
'''Format of response:
|
'''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")
|
tracking_id = args.get("tracking_id")
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ async def move_money(args: dict) -> dict:
|
|||||||
# Async function to start workflow
|
# Async function to start workflow
|
||||||
async def start_workflow(amount_cents: int, from_account_name: str, to_account_name: str)-> str:
|
async def start_workflow(amount_cents: int, from_account_name: str, to_account_name: str)-> str:
|
||||||
|
|
||||||
# Connect to Temporal
|
|
||||||
client = await get_temporal_client()
|
|
||||||
start_real_workflow = os.getenv("FIN_START_REAL_WORKFLOW")
|
start_real_workflow = os.getenv("FIN_START_REAL_WORKFLOW")
|
||||||
if start_real_workflow is not None and start_real_workflow.lower() == "false":
|
if start_real_workflow is not None and start_real_workflow.lower() == "false":
|
||||||
START_REAL_WORKFLOW = False
|
START_REAL_WORKFLOW = False
|
||||||
@@ -86,6 +84,8 @@ async def start_workflow(amount_cents: int, from_account_name: str, to_account_n
|
|||||||
START_REAL_WORKFLOW = True
|
START_REAL_WORKFLOW = True
|
||||||
|
|
||||||
if START_REAL_WORKFLOW:
|
if START_REAL_WORKFLOW:
|
||||||
|
# Connect to Temporal
|
||||||
|
client = await get_temporal_client()
|
||||||
# Create the parameter object
|
# Create the parameter object
|
||||||
params = MoneyMovementWorkflowParameterObj(
|
params = MoneyMovementWorkflowParameterObj(
|
||||||
amount=amount_cents,
|
amount=amount_cents,
|
||||||
|
|||||||
@@ -46,14 +46,14 @@ async def submit_loan_application(args: dict) -> dict:
|
|||||||
# Async function to start workflow
|
# Async function to start workflow
|
||||||
async def start_workflow(amount: str, account_name: str, )-> dict:
|
async def start_workflow(amount: str, account_name: str, )-> dict:
|
||||||
|
|
||||||
# Connect to Temporal
|
|
||||||
client = await get_temporal_client()
|
|
||||||
start_real_workflow = os.getenv("FIN_START_REAL_WORKFLOW")
|
start_real_workflow = os.getenv("FIN_START_REAL_WORKFLOW")
|
||||||
if start_real_workflow is not None and start_real_workflow.lower() == "false":
|
if start_real_workflow is not None and start_real_workflow.lower() == "false":
|
||||||
START_REAL_WORKFLOW = False
|
START_REAL_WORKFLOW = False
|
||||||
return {'loan_application_status': "applied", 'application_details': "loan application is submitted and initial validation is complete",'transaction_id': "APPLICATION"+account_name, 'advisement': "You'll receive a confirmation for final approval in three business days", }
|
return {'loan_application_status': "applied", 'application_details': "loan application is submitted and initial validation is complete",'transaction_id': "APPLICATION"+account_name, 'advisement': "You'll receive a confirmation for final approval in three business days", }
|
||||||
else:
|
else:
|
||||||
START_REAL_WORKFLOW = True
|
START_REAL_WORKFLOW = True
|
||||||
|
# Connect to Temporal
|
||||||
|
client = await get_temporal_client()
|
||||||
|
|
||||||
# Define the workflow ID and task queue
|
# Define the workflow ID and task queue
|
||||||
workflow_id = "LOAN_APPLICATION-"+account_name+"-"+date.today().strftime('%Y-%m-%d')
|
workflow_id = "LOAN_APPLICATION-"+account_name+"-"+date.today().strftime('%Y-%m-%d')
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ goal_fin_move_money = AgentGoal(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# this starts a loan approval process
|
# this starts a loan approval process
|
||||||
# it also uses a separate workflow/tool, see ./setup.md for details #todo
|
# it also uses a separate workflow/tool, see ./setup.md for details
|
||||||
goal_fin_loan_application = AgentGoal(
|
goal_fin_loan_application = AgentGoal(
|
||||||
id = "goal_fin_loan_application",
|
id = "goal_fin_loan_application",
|
||||||
category_tag="fin",
|
category_tag="fin",
|
||||||
@@ -353,7 +353,7 @@ goal_fin_loan_application = AgentGoal(
|
|||||||
agent_friendly_description="Initiate loan application.",
|
agent_friendly_description="Initiate loan application.",
|
||||||
tools=[
|
tools=[
|
||||||
tool_registry.financial_check_account_is_valid,
|
tool_registry.financial_check_account_is_valid,
|
||||||
tool_registry.financial_submit_loan_approval, #todo
|
tool_registry.financial_submit_loan_approval,
|
||||||
],
|
],
|
||||||
description="The user wants to apply for a loan at the financial institution. To assist with that goal, help the user gather args for these tools in order: "
|
description="The user wants to apply for a loan at the financial institution. To assist with that goal, help the user gather args for these tools in order: "
|
||||||
"1. FinCheckAccountIsValid: validate the user's account is valid"
|
"1. FinCheckAccountIsValid: validate the user's account is valid"
|
||||||
@@ -376,7 +376,6 @@ goal_fin_loan_application = AgentGoal(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# ----- E-Commerce Goals ---
|
# ----- 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
|
# this tool checks account balances, and uses ./data/customer_account_data.json as dummy data
|
||||||
goal_ecomm_order_status = AgentGoal(
|
goal_ecomm_order_status = AgentGoal(
|
||||||
id = "goal_ecomm_order_status",
|
id = "goal_ecomm_order_status",
|
||||||
@@ -394,8 +393,8 @@ goal_ecomm_order_status = AgentGoal(
|
|||||||
example_conversation_history="\n ".join(
|
example_conversation_history="\n ".join(
|
||||||
[
|
[
|
||||||
"user: I'd like to know the status of my order",
|
"user: I'd like to know the status of my order",
|
||||||
"agent: Sure! I can help you out with that. May I have your email address or order number?",
|
"agent: Sure! I can help you out with that. May I have your order number?",
|
||||||
"user: email is bob.johnson@emailzzz.com ",
|
"user: 102 ",
|
||||||
"user_confirmed_tool_run: <user clicks confirm on GetOrderStatus tool>",
|
"user_confirmed_tool_run: <user clicks confirm on GetOrderStatus tool>",
|
||||||
"tool_result: { 'id': '102', 'summary': 'Red Sunglasses', 'email': 'matt.murdock@nelsonmurdock.com', 'status': 'shipped', 'order_date': '2025-04-01', 'last_order_update': '2025-04-06', 'tracking_id': '039813852990618' }",
|
"tool_result: { 'id': '102', 'summary': 'Red Sunglasses', 'email': 'matt.murdock@nelsonmurdock.com', 'status': 'shipped', 'order_date': '2025-04-01', 'last_order_update': '2025-04-06', 'tracking_id': '039813852990618' }",
|
||||||
"agent: Your order 'Red Sunglasses,' placed April 1, 2025, was shipped on April 6, 2025. Would you like to see the tracking inforation?",
|
"agent: Your order 'Red Sunglasses,' placed April 1, 2025, was shipped on April 6, 2025. Would you like to see the tracking inforation?",
|
||||||
|
|||||||
@@ -172,12 +172,33 @@ class AgentGoalWorkflow:
|
|||||||
|
|
||||||
# else if the next step is to pick a new goal, set the goal and tool to do it
|
# else if the next step is to pick a new goal, set the goal and tool to do it
|
||||||
elif next_step == "pick-new-goal":
|
elif next_step == "pick-new-goal":
|
||||||
workflow.logger.info("All steps completed. Resetting goal.")
|
if self.goal.id != "goal_choose_agent_type":
|
||||||
self.change_goal("goal_choose_agent_type")
|
self.add_message("agent", tool_data)
|
||||||
next_step = tool_data["next"] = "confirm"
|
workflow.logger.info("All tools completed and new Agent Goal recommended. Resetting goal.")
|
||||||
current_tool = tool_data["tool"] = "ListAgents"
|
self.change_goal("goal_choose_agent_type")
|
||||||
waiting_for_confirm = True
|
next_step = tool_data["next"] = "confirm"
|
||||||
self.confirmed = True
|
current_tool = tool_data["tool"] = "ListAgents"
|
||||||
|
waiting_for_confirm = True
|
||||||
|
self.tool_data = tool_data
|
||||||
|
if self.show_tool_args_confirmation:
|
||||||
|
self.confirmed = False
|
||||||
|
# if we have all needed arguments (handled above) and not holding for a debugging confirm, proceed:
|
||||||
|
else:
|
||||||
|
self.confirmed = True
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if not current_tool == "ListAgents":
|
||||||
|
current_tool = tool_data["tool"] = "ListAgents"
|
||||||
|
waiting_for_confirm = True
|
||||||
|
|
||||||
|
self.tool_data = tool_data
|
||||||
|
next_step = tool_data["next"] = "confirm"
|
||||||
|
if self.show_tool_args_confirmation:
|
||||||
|
self.confirmed = False
|
||||||
|
# if we have all needed arguments (handled above) and not holding for a debugging confirm, proceed:
|
||||||
|
else:
|
||||||
|
self.confirmed = True
|
||||||
|
|
||||||
|
|
||||||
# else if the next step is to be done with the conversation such as if the user requests it via asking to "end conversation"
|
# else if the next step is to be done with the conversation such as if the user requests it via asking to "end conversation"
|
||||||
elif next_step == "done":
|
elif next_step == "done":
|
||||||
@@ -348,14 +369,12 @@ class AgentGoalWorkflow:
|
|||||||
self.prompt_queue
|
self.prompt_queue
|
||||||
)
|
)
|
||||||
|
|
||||||
#set new goal if we should
|
# set new goal if we should
|
||||||
if len(self.tool_results) > 0:
|
if len(self.tool_results) > 0:
|
||||||
if "ChangeGoal" in self.tool_results[-1].values() and "new_goal" in self.tool_results[-1].keys():
|
if "ChangeGoal" in self.tool_results[-1].values() and "new_goal" in self.tool_results[-1].keys():
|
||||||
new_goal = self.tool_results[-1].get("new_goal")
|
new_goal = self.tool_results[-1].get("new_goal")
|
||||||
workflow.logger.info(f"Booya new goal!: {new_goal}")
|
|
||||||
self.change_goal(new_goal)
|
self.change_goal(new_goal)
|
||||||
elif "ListAgents" in self.tool_results[-1].values() and self.goal.id != "goal_choose_agent_type":
|
elif "ListAgents" in self.tool_results[-1].values() and self.goal.id != "goal_choose_agent_type":
|
||||||
workflow.logger.info("setting goal to goal_choose_agent_type")
|
|
||||||
self.change_goal("goal_choose_agent_type")
|
self.change_goal("goal_choose_agent_type")
|
||||||
return waiting_for_confirm
|
return waiting_for_confirm
|
||||||
|
|
||||||
@@ -363,6 +382,8 @@ class AgentGoalWorkflow:
|
|||||||
# also don't forget you can look at the workflow itself and do queries if you want
|
# also don't forget you can look at the workflow itself and do queries if you want
|
||||||
def print_useful_workflow_vars(self, status_or_step:str) -> None:
|
def print_useful_workflow_vars(self, status_or_step:str) -> None:
|
||||||
print(f"***{status_or_step}:***")
|
print(f"***{status_or_step}:***")
|
||||||
|
if self.goal:
|
||||||
|
print(f"current goal: {self.goal.id}")
|
||||||
if self.tool_data:
|
if self.tool_data:
|
||||||
print(f"force confirm? {self.tool_data['force_confirm']}")
|
print(f"force confirm? {self.tool_data['force_confirm']}")
|
||||||
print(f"next step: {self.tool_data.get('next')}")
|
print(f"next step: {self.tool_data.get('next')}")
|
||||||
|
|||||||
Reference in New Issue
Block a user