" tool_call: str = Field(\"escalate_to_agent\", description=\"The tool call for escalating to an agent.\")\n",
" message: str = Field(..., description=\"The message to be escalated to the agent.\")\n",
"\n",
" \"\"\"Escalate to an agent for further assistance.\"\"\"\n",
" pass\n",
"\n",
"class OrderActionBase(FunctionCallBase):\n",
" pass\n",
"\n",
"\n",
"class ReplaceOrder(OrderActionBase):\n",
" tool_call: str = Field(\"replace_order\", description=\"The tool call for replacing the order.\")\n",
" \"\"\"Tool call to replace an order.\"\"\"\n",
" pass\n",
"\n",
"\n",
"class RefundOrder(OrderActionBase):\n",
" tool_call: str = Field(\"refund_order\", description=\"The tool call for refunding the order.\")\n",
" \"\"\"Tool call to refund an order.\"\"\"\n",
" pass"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-04-10T03:50:38.135826Z",
"start_time": "2024-04-10T03:50:38.122420Z"
}
},
"id": "115b5a0bf208b054",
"execution_count": 4
"execution_count": 46
},
{
"cell_type": "markdown",
@ -277,21 +282,18 @@
"Processing delivery exception support for different package images...\n",
"\n",
"===================== Simulating user message 1 =====================\n",
"Tool call identified: refund_order for provided img: damaged_package\n",
"Parameters: image_description='The package in the image appears heavily damaged. It is significantly crushed and torn on multiple sides, with visible creases and holes in the packaging material.' rationale='The package is clearly damaged, which likely compromised the contents. According to policy, a refund is processed for damaged packages.' tool_call='refund_order'\n",
"Processing action...\n",
"- Tool call: refund_order for provided img: damaged_package\n",
"- Parameters: rationale='The package is visibly damaged with significant tears and crushing, indicating potential harm to the contents.' image_description='The package in the image shows extensive damage, including deep creases and tears in the cardboard. The package is also wrapped with extra tape, suggesting prior attempts to secure it after damage.' action='refund_order' message=None\n",
">> Action result: Order 12345 has been refunded successfully.\n",
"\n",
"===================== Simulating user message 2 =====================\n",
"Tool call identified: escalate_to_agent for provided img: normal_package\n",
"Parameters: image_description='A normal, undamaged package on a wooden floor.' rationale='The package appears normal and not damaged, requiring further assistance.' tool_call='escalate_to_agent' message='Customer has submitted an image of a package that appears normal and undamaged. Please review and provide further instructions or assistance as needed.'\n",
"Processing action...\n",
">> Action result: Order 12345 has been escalated to an agent for further assistance.\n",
"- Tool call: escalate_to_agent for provided img: normal_package\n",
"- Parameters: rationale='The package appears normal and not damaged, requiring further assistance for any potential issues not visible in the image.' image_description='A cardboard box on a wooden floor, appearing intact and undamaged, with no visible signs of wear, tear, or wetness.' action='escalate_to_agent' message='Please review this package for any issues not visible in the image. The package appears normal and undamaged.'\n",
">> Action result: Order 12345 has been escalated to an agent with message: `Please review this package for any issues not visible in the image. The package appears normal and undamaged.`\n",
"\n",
"===================== Simulating user message 3 =====================\n",
"Tool call identified: replace_order for provided img: wet_package\n",
"Parameters: image_description=\"The package appears wet as indicated by the dark, damp patch on the cardboard. The box is labeled 'FRAGILE'.\" rationale='The package is wet, which could compromise the integrity of the contents, especially since it is marked as fragile. A replacement is necessary to ensure customer satisfaction and product safety.' tool_call='replace_order'\n",
"Processing action...\n",
"- Tool call: replace_order for provided img: wet_package\n",
"- Parameters: rationale='The package appears wet, which may have compromised the contents, especially since it is labeled as fragile.' image_description=\"The package in the image shows significant wetness on the top surface, indicating potential water damage. The box is labeled 'FRAGILE', which suggests that the contents are delicate and may be more susceptible to damage from moisture.\" action='replace_order' message=None\n",
">> Action result: Order 12345 has been replaced with a new order.\n"
]
}
@ -299,7 +301,7 @@
"source": [
"# extract the tool call from the response\n",
"ORDER_ID = \"12345\" # Placeholder order ID for testing\n",
"\n",
"INSTRUCTION_PROMPT = \"You are a customer service assistant for a delivery service, equipped to analyze images of packages. If a package appears damaged in the image, automatically process a refund according to policy. If the package looks wet, initiate a replacement. If the package appears normal and not damaged, escalate to agent. For any other issues or unclear images, escalate to agent. You must always use tools!\"\n",
" \"content\": 'You are a customer service assistant for a delivery service, equipped to analyze images of packages. If a package appears damaged in the image, automatically process a refund according to policy. If the package looks wet, initiate a replacement. If the package appears normal and not damaged, escalate to agent. For any other issues or unclear images, escalate to agent. You must always use tools',\n",
"text/plain": " employee_name role manager_name manager_role\n0 Juliana Silva CEO None None\n1 Kim Chun Hei CFO Juliana Silva CEO\n2 Chad Gibbons CTO Juliana Silva CEO\n3 Chiaki Sato COO Juliana Silva CEO\n4 Cahaya Dewi Manager Kim Chun Hei CFO\n5 Shawn Garcia Manager Chad Gibbons CTO\n6 Aaron Loeb Manager Chiaki Sato COO\n7 Drew Feig Employee Cahaya Dewi Manager\n8 Richard Sanchez Employee Cahaya Dewi Manager\n9 Olivia Wilson Employee Shawn Garcia Manager\n10 Avery Davis Employee Shawn Garcia Manager\n11 Harper Russo Employee Aaron Loeb Manager\n12 Sacha Dubois Intern Cahaya Dewi Manager\n13 Matt Zhang Intern Shawn Garcia Manager\n14 Taylor Alonso Intern Aaron Loeb Manager",
"text/plain": " employee_name role manager_name manager_role\n0 Juliana Silva CEO None None\n1 Kim Chun Hei CFO Juliana Silva CEO\n2 Chad Gibbons CTO Juliana Silva CEO\n3 Chiaki Sato COO Juliana Silva CEO\n4 Cahaya Dewi Manager Kim Chun Hei CFO\n5 Shawn Garcia Manager Chad Gibbons CTO\n6 Aaron Loeb Manager Chiaki Sato COO\n7 Drew Feig Employee Cahaya Dewi Manager\n8 Richard Sanchez Employee Cahaya Dewi Manager\n9 Sacha Dubois Intern Cahaya Dewi Manager\n10 Olivia Wilson Employee Shawn Garcia Manager\n11 Matt Zhang Intern Shawn Garcia Manager\n12 Avery Davis Employee Aaron Loeb Manager\n13 Harper Russo Employee Aaron Loeb Manager\n14 Taylor Alonso Intern Aaron Loeb Manager",