From cec4407b9486ddb000d890128c5fbc32f5492b3d Mon Sep 17 00:00:00 2001 From: Mark Sze Date: Wed, 18 Dec 2024 07:47:46 +0000 Subject: [PATCH 1/5] Initial commit of notebook Signed-off-by: Mark Sze --- notebook/agentchat_swarm_enhanced.ipynb | 470 ++++++++++++++++++++++++ 1 file changed, 470 insertions(+) create mode 100644 notebook/agentchat_swarm_enhanced.ipynb diff --git a/notebook/agentchat_swarm_enhanced.ipynb b/notebook/agentchat_swarm_enhanced.ipynb new file mode 100644 index 0000000000..3a0a20e249 --- /dev/null +++ b/notebook/agentchat_swarm_enhanced.ipynb @@ -0,0 +1,470 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Enhanced Swarm Orchestration with AG2 \n", + "\n", + "AG2's swarm orchestration provides a flexible and powerful method of managing a conversation with multiple agents, tools, and transitions.\n", + "\n", + "In this notebook, we look at more advanced features of the swarm orchestration.\n", + "\n", + "If you are new to swarm, check out [this notebook](https://ag2ai.github.io/ag2/docs/notebooks/agentchat_swarm), where we introduce the core features of swarms including global context variables, hand offs, and initiating a swarm chat.\n", + "\n", + "In this notebook we're going to demonstrate these features AG2's swarm orchestration:\n", + "\n", + "- Updating an agent's state\n", + "- Conditional handoffs\n", + "- Nested chats" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "````{=mdx}\n", + ":::info Requirements\n", + "Install `ag2`:\n", + "```bash\n", + "pip install ag2\n", + "```\n", + "\n", + "For more information, please refer to the [installation guide](/docs/installation/).\n", + ":::\n", + "````" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set your API Endpoint\n", + "\n", + "The [`config_list_from_json`](https://ag2ai.github.io/ag2/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import autogen\n", + "\n", + "config_list = autogen.config_list_from_json(\n", + " \"OAI_CONFIG_LIST\",\n", + " filter_dict={\n", + " \"model\": [\"gpt-4o\"],\n", + " },\n", + ")\n", + "\n", + "llm_config = {\n", + " \"cache_seed\": 42, # change the cache_seed for different trials\n", + " \"temperature\": 1,\n", + " \"config_list\": config_list,\n", + " \"timeout\": 120,\n", + " \"tools\": [],\n", + "}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Demonstration\n", + "\n", + "We're creating this customer service workflow for an e-commerce platform. Customers can ask about the status of their orders, but they must be authenticated to do so.\n", + "\n", + "![](swarm_enhanced_01.png)\n", + "\n", + "Key aspects of this swarm are:\n", + "\n", + "1. System messages are customised, incorporating the context of the workflow\n", + "2. Handoffs are conditional, only being available when they are relevant\n", + "3. A nested chat handles the order retrieval and summarisation" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from typing import Any, Dict, List\n", + "\n", + "from autogen import (\n", + " AFTER_WORK,\n", + " ON_CONDITION,\n", + " UPDATE_SYSTEM_MESSAGE,\n", + " AfterWorkOption,\n", + " ConversableAgent,\n", + " SwarmAgent,\n", + " SwarmResult,\n", + " UserProxyAgent,\n", + " config_list_from_json,\n", + " initiate_swarm_chat,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "config_list = config_list_from_json(\n", + " \"/home/autogen/ag2/ms_code/OAI_CONFIG_LIST\",\n", + " filter_dict={\n", + " \"model\": [\"gpt-4o-mini\"],\n", + " },\n", + ")\n", + "\n", + "llm_config = {\n", + " \"config_list\": config_list,\n", + " \"cache_seed\": None, # Disables the cache\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "workflow_context = {\n", + " # customer details\n", + " \"customer_name\": None,\n", + " # workflow status\n", + " \"logged_in\": False,\n", + " \"requires_login\": True,\n", + " # order enquiry details\n", + " \"has_order_id\": False,\n", + " \"order_id\": None,\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Databases\n", + "\n", + "USER_DATABASE = {\n", + " \"mark\": {\n", + " \"full_name\": \"Mark Sze\",\n", + " },\n", + " \"kevin\": {\n", + " \"full_name\": \"Yiran Wu\",\n", + " },\n", + "}\n", + "\n", + "ORDER_DATABASE = {\n", + " \"TR13845\": {\n", + " \"order_number\": \"TR13845\",\n", + " \"status\": \"shipped\", # order status: order_received, shipped, delivered, return_started, returned\n", + " \"return_status\": \"N/A\", # return status: N/A, return_started, return_shipped, return_delivered, refund_issued\n", + " \"product\": \"matress\",\n", + " \"link\": \"https://www.example.com/TR13845\",\n", + " \"shipping_address\": \"123 Main St, State College, PA 12345\",\n", + " },\n", + " \"TR14234\": {\n", + " \"order_number\": \"TR14234\",\n", + " \"status\": \"delivered\",\n", + " \"return_status\": \"N/A\",\n", + " \"product\": \"pillow\",\n", + " \"link\": \"https://www.example.com/TR14234\",\n", + " \"shipping_address\": \"123 Main St, State College, PA 12345\",\n", + " },\n", + " \"TR29384\": {\n", + " \"order_number\": \"TR29384\",\n", + " \"status\": \"delivered\",\n", + " \"return_status\": \"N/A\",\n", + " \"product\": \"bed frame\",\n", + " \"link\": \"https://www.example.com/TR29384\",\n", + " \"shipping_address\": \"123 Main St, State College, PA 12345\",\n", + " },\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# ORDER FUNCTIONS\n", + "def check_order_id(order_id: str, context_variables: dict) -> SwarmResult:\n", + " \"\"\"Check if the order ID is valid\"\"\"\n", + " if order_id in ORDER_DATABASE:\n", + " return SwarmResult(\n", + " context_variables=context_variables, values=f\"Order ID {order_id} is valid.\", agent=order_triage_agent\n", + " )\n", + " else:\n", + " return SwarmResult(\n", + " context_variables=context_variables,\n", + " values=f\"Order ID {order_id} is invalid. Please ask for the correct order ID.\",\n", + " agent=order_triage_agent,\n", + " )\n", + "\n", + "\n", + "def record_order_id(order_id: str, context_variables: dict) -> SwarmResult:\n", + " \"\"\"Record the order ID in the workflow context\"\"\"\n", + "\n", + " if order_id not in ORDER_DATABASE:\n", + " return SwarmResult(\n", + " context_variables=context_variables,\n", + " values=f\"Order ID {order_id} not found. Please ask for the correct order ID.\",\n", + " agent=order_triage_agent,\n", + " )\n", + "\n", + " context_variables[\"order_id\"] = order_id\n", + " context_variables[\"has_order_id\"] = True\n", + " return SwarmResult(\n", + " context_variables=context_variables, values=f\"Order ID Recorded: {order_id}\", agent=order_mgmt_agent\n", + " )\n", + "\n", + "\n", + "# AUTHENTICATION FUNCTIONS\n", + "def login_customer_by_username(username: str, context_variables: dict) -> SwarmResult:\n", + " \"\"\"Get and log the customer in by their username\"\"\"\n", + " if username in USER_DATABASE:\n", + " context_variables[\"customer_name\"] = USER_DATABASE[username][\"full_name\"]\n", + " context_variables[\"logged_in\"] = True\n", + " context_variables[\"requires_login\"] = False\n", + " return SwarmResult(\n", + " context_variables=context_variables,\n", + " values=f\"Welcome back our customer, {context_variables['customer_name']}! Please continue helping them.\",\n", + " agent=order_triage_agent,\n", + " )\n", + " else:\n", + " return SwarmResult(\n", + " context_variables=context_variables,\n", + " values=f\"User {username} not found. Please ask for the correct username.\",\n", + " agent=authentication_agent,\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# AGENTS\n", + "\n", + "# Human customer\n", + "user = UserProxyAgent(\n", + " name=\"customer\",\n", + " code_execution_config=False,\n", + ")\n", + "\n", + "order_triage_prompt = \"\"\"You are an order triage agent, working with a customer and a group of agents to provide support for your e-commerce platform.\n", + "\n", + "An agent needs to be logged in to be able to access their order. The authentication_agent will work with the customer to verify their identity, transfer to them to start with.\n", + "The order_mgmt_agent will manage all order related tasks, such as tracking orders, managing orders, etc. Be sure to check the order as one step. Then if it's valid you can record it in the context.\n", + "\n", + "Ask the customer for further information when necessary.\n", + "\n", + "The current status of this workflow is:\n", + "Customer name: {customer_name}\n", + "Logged in: {logged_in}\n", + "Enquiring for Order ID: {order_id}\n", + "\"\"\"\n", + "\n", + "order_triage_agent = SwarmAgent(\n", + " name=\"order_triage_agent\",\n", + " update_agent_state_before_reply=[\n", + " UPDATE_SYSTEM_MESSAGE(order_triage_prompt),\n", + " ],\n", + " functions=[check_order_id, record_order_id],\n", + " llm_config=llm_config,\n", + ")\n", + "\n", + "authentication_prompt = \"You are an authentication agent that verifies the identity of the customer.\"\n", + "\n", + "authentication_agent = SwarmAgent(\n", + " name=\"authentication_agent\",\n", + " system_message=authentication_prompt,\n", + " functions=[login_customer_by_username],\n", + " llm_config=llm_config,\n", + ")\n", + "\n", + "order_management_prompt = \"\"\"You are an order management agent that manages inquiries related to e-commerce orders.\n", + "\n", + "The order must be logged in to access their order.\n", + "\n", + "Use your available tools to get the status of the details from the customer. Ask the customer questions as needed.\n", + "\n", + "The current status of this workflow is:\n", + "Customer name: {customer_name}\n", + "Logged in: {logged_in}\n", + "Enquiring for Order ID: {order_id}\n", + "\"\"\"\n", + "\n", + "order_mgmt_agent = SwarmAgent(\n", + " name=\"order_mgmt_agent\",\n", + " update_agent_state_before_reply=[\n", + " UPDATE_SYSTEM_MESSAGE(order_management_prompt),\n", + " ],\n", + " functions=[check_order_id, record_order_id],\n", + " llm_config=llm_config,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# NESTED CHAT - Delivery Status\n", + "order_retrieval_agent = ConversableAgent(\n", + " name=\"order_retrieval_agent\",\n", + " system_message=\"You are an order retrieval agent that gets details about an order.\",\n", + " llm_config=llm_config,\n", + ")\n", + "\n", + "order_summariser_agent = ConversableAgent(\n", + " name=\"order_summariser_agent\",\n", + " system_message=\"You are an order summariser agent that provides a summary of the order details.\",\n", + " llm_config=llm_config,\n", + ")\n", + "\n", + "\n", + "def extract_order_summary(recipient: ConversableAgent, messages, sender: ConversableAgent, config):\n", + " \"\"\"Extracts the order summary based on the OrderID in the context variables\"\"\"\n", + " order_id = sender.get_context(\"order_id\")\n", + " if order_id in ORDER_DATABASE:\n", + " order = ORDER_DATABASE[order_id]\n", + " return f\"Order {order['order_number']} for {order['product']} is currently {order['status']}. The shipping address is {order['shipping_address']}.\"\n", + " else:\n", + " return f\"Order {order_id} not found.\"\n", + "\n", + "\n", + "nested_chat_one = {\n", + " \"carryover_config\": {\"summary_method\": \"last_msg\"},\n", + " \"recipient\": order_retrieval_agent,\n", + " \"message\": extract_order_summary, # \"Retrieve the status details of the order using the order id\",\n", + " \"max_turns\": 1,\n", + "}\n", + "\n", + "nested_chat_two = {\n", + " \"recipient\": order_summariser_agent,\n", + " \"message\": \"Summarise the order details provided in a tabulated, text-based, order sheet format\",\n", + " \"max_turns\": 1,\n", + " \"summary_method\": \"last_msg\",\n", + "}\n", + "\n", + "chat_queue = [nested_chat_one, nested_chat_two]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# HANDOFFS\n", + "order_triage_agent.register_hand_off(\n", + " [\n", + " ON_CONDITION(\n", + " target=authentication_agent,\n", + " condition=\"The customer is not logged in, authenticate the customer.\",\n", + " available=\"requires_login\",\n", + " ),\n", + " ON_CONDITION(\n", + " target=order_mgmt_agent,\n", + " condition=\"The customer is logged in, continue with the order triage.\",\n", + " available=\"logged_in\",\n", + " ),\n", + " AFTER_WORK(AfterWorkOption.REVERT_TO_USER),\n", + " ]\n", + ")\n", + "\n", + "authentication_agent.register_hand_off(\n", + " [\n", + " ON_CONDITION(\n", + " target=order_triage_agent,\n", + " condition=\"The customer is logged in, continue with the order triage.\",\n", + " available=\"logged_in\",\n", + " ),\n", + " AFTER_WORK(AfterWorkOption.REVERT_TO_USER),\n", + " ]\n", + ")\n", + "\n", + "\n", + "def has_order_in_context(agent: SwarmAgent, messages: List[Dict[str, Any]]) -> bool:\n", + " return agent.get_context(\"has_order_id\")\n", + "\n", + "\n", + "order_mgmt_agent.register_hand_off(\n", + " [\n", + " ON_CONDITION(\n", + " target={\n", + " \"chat_queue\": chat_queue,\n", + " },\n", + " condition=\"Retrieve the status of the order\",\n", + " available=has_order_in_context,\n", + " ),\n", + " ON_CONDITION(\n", + " target=authentication_agent,\n", + " condition=\"The customer is not logged in, authenticate the customer.\",\n", + " available=\"requires_login\",\n", + " ),\n", + " ON_CONDITION(target=order_triage_agent, condition=\"The customer has no more enquiries about this order.\"),\n", + " AFTER_WORK(AfterWorkOption.REVERT_TO_USER),\n", + " ]\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "chat_history = initiate_swarm_chat(\n", + " initial_agent=order_triage_agent,\n", + " agents=[order_triage_agent, authentication_agent, order_mgmt_agent],\n", + " context_variables=workflow_context,\n", + " messages=\"Can you help me with my order.\",\n", + " user_agent=user,\n", + " max_rounds=40,\n", + " after_work=AfterWorkOption.TERMINATE,\n", + ")" + ] + } + ], + "metadata": { + "front_matter": { + "description": "Swarm Ochestration", + "tags": [ + "orchestration", + "group chat", + "swarm" + ] + }, + "kernelspec": { + "display_name": "autodev", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.19" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b56eebeff3071144399b5625c41c85308a186b2f Mon Sep 17 00:00:00 2001 From: Mark Sze Date: Thu, 19 Dec 2024 06:43:13 +0000 Subject: [PATCH 2/5] Working notebook with images --- notebook/agentchat_swarm_enhanced.ipynb | 655 ++++++++++++++++++++++-- notebook/swarm_enhanced_01.png | 3 + notebook/swarm_enhanced_02.png | 3 + notebook/swarm_enhanced_03.png | 3 + notebook/swarm_enhanced_04.png | 3 + notebook/swarm_enhanced_05.png | 3 + 6 files changed, 639 insertions(+), 31 deletions(-) create mode 100755 notebook/swarm_enhanced_01.png create mode 100755 notebook/swarm_enhanced_02.png create mode 100755 notebook/swarm_enhanced_03.png create mode 100755 notebook/swarm_enhanced_04.png create mode 100755 notebook/swarm_enhanced_05.png diff --git a/notebook/agentchat_swarm_enhanced.ipynb b/notebook/agentchat_swarm_enhanced.ipynb index 3a0a20e249..4af5dd7671 100644 --- a/notebook/agentchat_swarm_enhanced.ipynb +++ b/notebook/agentchat_swarm_enhanced.ipynb @@ -46,9 +46,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n", + "/usr/local/lib/python3.11/site-packages/flaml/__init__.py:20: UserWarning: flaml.automl is not available. Please install flaml[automl] to enable AutoML functionalities.\n", + " warnings.warn(\"flaml.automl is not available. Please install flaml[automl] to enable AutoML functionalities.\")\n" + ] + } + ], "source": [ "import autogen\n", "\n", @@ -64,7 +75,6 @@ " \"temperature\": 1,\n", " \"config_list\": config_list,\n", " \"timeout\": 120,\n", - " \"tools\": [],\n", "}" ] }, @@ -76,7 +86,7 @@ "\n", "We're creating this customer service workflow for an e-commerce platform. Customers can ask about the status of their orders, but they must be authenticated to do so.\n", "\n", - "![](swarm_enhanced_01.png)\n", + "![Swarm Enhanced Demonstration](swarm_enhanced_01.png)\n", "\n", "Key aspects of this swarm are:\n", "\n", @@ -87,7 +97,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -102,39 +112,27 @@ " SwarmAgent,\n", " SwarmResult,\n", " UserProxyAgent,\n", - " config_list_from_json,\n", " initiate_swarm_chat,\n", ")" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "config_list = config_list_from_json(\n", - " \"/home/autogen/ag2/ms_code/OAI_CONFIG_LIST\",\n", - " filter_dict={\n", - " \"model\": [\"gpt-4o-mini\"],\n", - " },\n", - ")\n", - "\n", - "llm_config = {\n", - " \"config_list\": config_list,\n", - " \"cache_seed\": None, # Disables the cache\n", - "}" + "### Context" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "workflow_context = {\n", " # customer details\n", " \"customer_name\": None,\n", + " \"logged_in_username\": None,\n", " # workflow status\n", " \"logged_in\": False,\n", " \"requires_login\": True,\n", @@ -144,9 +142,16 @@ "}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Databases" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -163,6 +168,7 @@ "\n", "ORDER_DATABASE = {\n", " \"TR13845\": {\n", + " \"user\": \"mark\",\n", " \"order_number\": \"TR13845\",\n", " \"status\": \"shipped\", # order status: order_received, shipped, delivered, return_started, returned\n", " \"return_status\": \"N/A\", # return status: N/A, return_started, return_shipped, return_delivered, refund_issued\n", @@ -171,6 +177,7 @@ " \"shipping_address\": \"123 Main St, State College, PA 12345\",\n", " },\n", " \"TR14234\": {\n", + " \"user\": \"kevin\",\n", " \"order_number\": \"TR14234\",\n", " \"status\": \"delivered\",\n", " \"return_status\": \"N/A\",\n", @@ -179,6 +186,7 @@ " \"shipping_address\": \"123 Main St, State College, PA 12345\",\n", " },\n", " \"TR29384\": {\n", + " \"user\": \"mark\",\n", " \"order_number\": \"TR29384\",\n", " \"status\": \"delivered\",\n", " \"return_status\": \"N/A\",\n", @@ -189,16 +197,29 @@ "}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Agent's Functions" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# ORDER FUNCTIONS\n", "def check_order_id(order_id: str, context_variables: dict) -> SwarmResult:\n", " \"\"\"Check if the order ID is valid\"\"\"\n", - " if order_id in ORDER_DATABASE:\n", + "\n", + " # Restricts order to checking to the logged in user\n", + " if (\n", + " context_variables[\"logged_in_username\"]\n", + " and order_id in ORDER_DATABASE\n", + " and ORDER_DATABASE[order_id][\"user\"] == context_variables[\"logged_in_username\"]\n", + " ):\n", " return SwarmResult(\n", " context_variables=context_variables, values=f\"Order ID {order_id} is valid.\", agent=order_triage_agent\n", " )\n", @@ -232,6 +253,7 @@ " \"\"\"Get and log the customer in by their username\"\"\"\n", " if username in USER_DATABASE:\n", " context_variables[\"customer_name\"] = USER_DATABASE[username][\"full_name\"]\n", + " context_variables[\"logged_in_username\"] = username\n", " context_variables[\"logged_in\"] = True\n", " context_variables[\"requires_login\"] = False\n", " return SwarmResult(\n", @@ -247,9 +269,16 @@ " )" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Agents" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -314,9 +343,16 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Nested Chats" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -361,9 +397,16 @@ "chat_queue = [nested_chat_one, nested_chat_two]" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Handoffs (ON_CONDITIONS and AFTER_WORKS)" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -420,11 +463,540 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Let's go!" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "Can you help me with my order.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_8lz3Ubuex13DBRd86IFJsm68): transfer_order_triage_agent_to_authentication_agent *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m********************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_triage_agent_to_authentication_agent...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_8lz3Ubuex13DBRd86IFJsm68) *****\u001b[0m\n", + "SwarmAgent --> authentication_agent\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "I can help you with that. Could you please provide your username so that I can verify your identity and assist you further?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "My username is barry\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_s9isTmnZHTHgRgHBirpgSp7x): login_customer_by_username *****\u001b[0m\n", + "Arguments: \n", + "{\"username\":\"barry\"}\n", + "\u001b[32m*******************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION login_customer_by_username...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_s9isTmnZHTHgRgHBirpgSp7x) *****\u001b[0m\n", + "User barry not found. Please ask for the correct username.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "It seems like I couldn't find an account with the username \"barry.\" Could you please double-check your username and provide it again?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "mark\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_BS7BeG0X0c0oaIM45RfX34rh): login_customer_by_username *****\u001b[0m\n", + "Arguments: \n", + "{\"username\":\"mark\"}\n", + "\u001b[32m*******************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION login_customer_by_username...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_BS7BeG0X0c0oaIM45RfX34rh) *****\u001b[0m\n", + "Welcome back our customer, Mark Sze! Please continue helping them.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_ojZerGyuA9VzWM8yKRk2NqZZ): transfer_order_triage_agent_to_order_mgmt_agent *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_triage_agent_to_order_mgmt_agent...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_ojZerGyuA9VzWM8yKRk2NqZZ) *****\u001b[0m\n", + "SwarmAgent --> order_mgmt_agent\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_3hWx7pZ6Klo6yAovWeab10OY): transfer_order_mgmt_agent_to_order_triage_agent *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_order_triage_agent...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_3hWx7pZ6Klo6yAovWeab10OY) *****\u001b[0m\n", + "SwarmAgent --> order_triage_agent\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "Can you please provide the order ID that you need help with?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "TR13840\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_xTT0iz9pIc5ii6ukXLHjMvLO): check_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR13840\"}\n", + "\u001b[32m*******************************************************************************\u001b[0m\n", + "\u001b[32m***** Suggested tool call (call_fuKuduzgZtf9o9DCfWcv5jTl): record_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR13840\"}\n", + "\u001b[32m********************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_xTT0iz9pIc5ii6ukXLHjMvLO) *****\u001b[0m\n", + "Order ID TR13840 is invalid. Please ask for the correct order ID.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m***** Response from calling tool (call_fuKuduzgZtf9o9DCfWcv5jTl) *****\u001b[0m\n", + "Order ID TR13840 not found. Please ask for the correct order ID.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "It seems like the Order ID \"TR13840\" is invalid or not found in our system. Could you please double-check the order ID and provide it again?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "TR13845\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_rhf4Rcn6WP3zaJ1j6uhuuFBG): check_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR13845\"}\n", + "\u001b[32m*******************************************************************************\u001b[0m\n", + "\u001b[32m***** Suggested tool call (call_nwnWpDKQbm8cUBxmv5LovoE8): record_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR13845\"}\n", + "\u001b[32m********************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_rhf4Rcn6WP3zaJ1j6uhuuFBG) *****\u001b[0m\n", + "Order ID TR13845 is valid.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m***** Response from calling tool (call_nwnWpDKQbm8cUBxmv5LovoE8) *****\u001b[0m\n", + "Order ID Recorded: TR13845\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_ZXd07TkL7Xk8gvhqCrpHLADQ): transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1 *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_ZXd07TkL7Xk8gvhqCrpHLADQ) *****\u001b[0m\n", + "SwarmAgent --> nested_chat_order_mgmt_agent_1\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: nested_chat_order_mgmt_agent_1\n", + "\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[34mStarting a new chat....\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_retrieval_agent):\n", + "\n", + "Order TR13845 for matress is currently shipped. The shipping address is 123 Main St, State College, PA 12345.\n", + "Context:\n", + "Order ID TR13845 is valid.\n", + "Order ID Recorded: TR13845\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33morder_retrieval_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", + "\n", + "Order TR13845, which is for a mattress, has been shipped. The shipping address for this order is 123 Main St, State College, PA 12345.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[34mStarting a new chat....\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_summariser_agent):\n", + "\n", + "Summarise the order details provided in a tabulated, text-based, order sheet format\n", + "Context: \n", + "Order TR13845, which is for a mattress, has been shipped. The shipping address for this order is 123 Main St, State College, PA 12345.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33morder_summariser_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", + "\n", + "```\n", + "Order Summary:\n", + "\n", + "| Order Number | Product | Status | Shipping Address |\n", + "|--------------|-----------|--------|-----------------------------------|\n", + "| TR13845 | Mattress | Shipped| 123 Main St, State College, PA 12345 |\n", + "\n", + "```\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to chat_manager):\n", + "\n", + "```\n", + "Order Summary:\n", + "\n", + "| Order Number | Product | Status | Shipping Address |\n", + "|--------------|-----------|--------|-----------------------------------|\n", + "| TR13845 | Mattress | Shipped| 123 Main St, State College, PA 12345 |\n", + "\n", + "```\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "Your order with the ID \"TR13845\" is for a Mattress and it has already been shipped to the following address: \n", + "123 Main St, State College, PA 12345.\n", + "\n", + "If there's anything else you need help with, feel free to ask!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "TR29384\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_YQHOPgkKrQorMtZnuuSNVUHO): check_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\":\"TR29384\"}\n", + "\u001b[32m*******************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_YQHOPgkKrQorMtZnuuSNVUHO) *****\u001b[0m\n", + "Order ID TR29384 is valid.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_fVZMv1T3jyDiXJO0lvToaQWS): record_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\":\"TR29384\"}\n", + "\u001b[32m********************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_fVZMv1T3jyDiXJO0lvToaQWS) *****\u001b[0m\n", + "Order ID Recorded: TR29384\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_S8M1HEKdTnw80oUIUoLyIXZa): transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1 *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_S8M1HEKdTnw80oUIUoLyIXZa) *****\u001b[0m\n", + "SwarmAgent --> nested_chat_order_mgmt_agent_1\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: nested_chat_order_mgmt_agent_1\n", + "\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[34mStarting a new chat....\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_retrieval_agent):\n", + "\n", + "Order TR29384 for bed frame is currently delivered. The shipping address is 123 Main St, State College, PA 12345.\n", + "Context:\n", + "Order ID Recorded: TR29384\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33morder_retrieval_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", + "\n", + "Here are the details for Order TR29384:\n", + "\n", + "- **Item**: Bed Frame\n", + "- **Status**: Delivered\n", + "- **Shipping Address**: 123 Main St, State College, PA 12345\n", + "\n", + "Let me know if there is anything else you need related to this order!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[34mStarting a new chat....\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_summariser_agent):\n", + "\n", + "Summarise the order details provided in a tabulated, text-based, order sheet format\n", + "Context: \n", + "Here are the details for Order TR29384:\n", + "\n", + "- **Item**: Bed Frame\n", + "- **Status**: Delivered\n", + "- **Shipping Address**: 123 Main St, State College, PA 12345\n", + "\n", + "Let me know if there is anything else you need related to this order!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33morder_summariser_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", + "\n", + "```\n", + "Order Summary\n", + "-------------------------\n", + "Order ID: TR29384\n", + "\n", + "| Item | Status | Shipping Address |\n", + "|-----------|-----------|---------------------------------|\n", + "| Bed Frame | Delivered | 123 Main St, State College, PA 12345 |\n", + "\n", + "Thank you for your order!\n", + "```\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to chat_manager):\n", + "\n", + "```\n", + "Order Summary\n", + "-------------------------\n", + "Order ID: TR29384\n", + "\n", + "| Item | Status | Shipping Address |\n", + "|-----------|-----------|---------------------------------|\n", + "| Bed Frame | Delivered | 123 Main St, State College, PA 12345 |\n", + "\n", + "Thank you for your order!\n", + "```\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "Your order with the ID \"TR29384\" for a Bed Frame has been delivered. The shipping address is 123 Main St, State College, PA 12345.\n", + "\n", + "If there's anything else you need assistance with, please let me know!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n" + ] + } + ], "source": [ "chat_history = initiate_swarm_chat(\n", " initial_agent=order_triage_agent,\n", @@ -436,6 +1008,27 @@ " after_work=AfterWorkOption.TERMINATE,\n", ")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Controlling flow\n", + "\n", + "### When not logged in\n", + "![Swarm Enhanced Demonstration](swarm_enhanced_02.png)\n", + "\n", + "### When logged in but no order id\n", + "![Swarm Enhanced Demonstration](swarm_enhanced_03.png)\n", + "\n", + "### When logged in with order id\n", + "![Swarm Enhanced Demonstration](swarm_enhanced_04.png)\n", + "\n", + "# Agent state\n", + "\n", + "### Agent System Messages with context\n", + "![Swarm Enhanced Demonstration](swarm_enhanced_05.png)" + ] } ], "metadata": { @@ -448,7 +1041,7 @@ ] }, "kernelspec": { - "display_name": "autodev", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -462,7 +1055,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.19" + "version": "3.11.11" } }, "nbformat": 4, diff --git a/notebook/swarm_enhanced_01.png b/notebook/swarm_enhanced_01.png new file mode 100755 index 0000000000..5d10323fac --- /dev/null +++ b/notebook/swarm_enhanced_01.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42da3597edc45639b3bb1e49eef4c1c0c1734769513e6f0e0672ccf2076227aa +size 413112 diff --git a/notebook/swarm_enhanced_02.png b/notebook/swarm_enhanced_02.png new file mode 100755 index 0000000000..4f5c92fd85 --- /dev/null +++ b/notebook/swarm_enhanced_02.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbe5b53aca883d4807d6768d6e8101bc720b00f6549b5765f4d0a20cdffbe59a +size 363568 diff --git a/notebook/swarm_enhanced_03.png b/notebook/swarm_enhanced_03.png new file mode 100755 index 0000000000..64ff7e3997 --- /dev/null +++ b/notebook/swarm_enhanced_03.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a2d5e2568aacad23c4e0a720220c06d5396894a41cb1ff543566ce424d4d3aa +size 357923 diff --git a/notebook/swarm_enhanced_04.png b/notebook/swarm_enhanced_04.png new file mode 100755 index 0000000000..052c4c2fd8 --- /dev/null +++ b/notebook/swarm_enhanced_04.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:356c2cbfb3f030d335e698d970effe23408c1e5d88a03a61cdc51129463c492f +size 377896 diff --git a/notebook/swarm_enhanced_05.png b/notebook/swarm_enhanced_05.png new file mode 100755 index 0000000000..d50b0fb44a --- /dev/null +++ b/notebook/swarm_enhanced_05.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42cdd3ce308a95fc6e9627424eba3d8b21bf5810f34f902d07079861fd3dc500 +size 428372 From 1028fb664c15761a785e293a7c93ea771bf86cc5 Mon Sep 17 00:00:00 2001 From: Mark Sze Date: Thu, 19 Dec 2024 06:46:28 +0000 Subject: [PATCH 3/5] Added notebook to examples --- notebook/agentchat_swarm_enhanced.ipynb | 555 +----------------------- website/docs/Examples.md | 1 + 2 files changed, 12 insertions(+), 544 deletions(-) diff --git a/notebook/agentchat_swarm_enhanced.ipynb b/notebook/agentchat_swarm_enhanced.ipynb index 4af5dd7671..101737f87a 100644 --- a/notebook/agentchat_swarm_enhanced.ipynb +++ b/notebook/agentchat_swarm_enhanced.ipynb @@ -46,20 +46,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 10, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/local/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n", - "/usr/local/lib/python3.11/site-packages/flaml/__init__.py:20: UserWarning: flaml.automl is not available. Please install flaml[automl] to enable AutoML functionalities.\n", - " warnings.warn(\"flaml.automl is not available. Please install flaml[automl] to enable AutoML functionalities.\")\n" - ] - } - ], + "outputs": [], "source": [ "import autogen\n", "\n", @@ -97,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -125,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -151,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -206,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -278,7 +267,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -352,7 +341,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -406,7 +395,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -472,531 +461,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", - "\n", - "Can you help me with my order.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_8lz3Ubuex13DBRd86IFJsm68): transfer_order_triage_agent_to_authentication_agent *****\u001b[0m\n", - "Arguments: \n", - "{}\n", - "\u001b[32m********************************************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION transfer_order_triage_agent_to_authentication_agent...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_8lz3Ubuex13DBRd86IFJsm68) *****\u001b[0m\n", - "SwarmAgent --> authentication_agent\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: authentication_agent\n", - "\u001b[0m\n", - "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", - "\n", - "I can help you with that. Could you please provide your username so that I can verify your identity and assist you further?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: customer\n", - "\u001b[0m\n", - "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", - "\n", - "My username is barry\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: authentication_agent\n", - "\u001b[0m\n", - "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_s9isTmnZHTHgRgHBirpgSp7x): login_customer_by_username *****\u001b[0m\n", - "Arguments: \n", - "{\"username\":\"barry\"}\n", - "\u001b[32m*******************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION login_customer_by_username...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_s9isTmnZHTHgRgHBirpgSp7x) *****\u001b[0m\n", - "User barry not found. Please ask for the correct username.\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: authentication_agent\n", - "\u001b[0m\n", - "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", - "\n", - "It seems like I couldn't find an account with the username \"barry.\" Could you please double-check your username and provide it again?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: customer\n", - "\u001b[0m\n", - "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", - "\n", - "mark\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: authentication_agent\n", - "\u001b[0m\n", - "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_BS7BeG0X0c0oaIM45RfX34rh): login_customer_by_username *****\u001b[0m\n", - "Arguments: \n", - "{\"username\":\"mark\"}\n", - "\u001b[32m*******************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION login_customer_by_username...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_BS7BeG0X0c0oaIM45RfX34rh) *****\u001b[0m\n", - "Welcome back our customer, Mark Sze! Please continue helping them.\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_ojZerGyuA9VzWM8yKRk2NqZZ): transfer_order_triage_agent_to_order_mgmt_agent *****\u001b[0m\n", - "Arguments: \n", - "{}\n", - "\u001b[32m****************************************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION transfer_order_triage_agent_to_order_mgmt_agent...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_ojZerGyuA9VzWM8yKRk2NqZZ) *****\u001b[0m\n", - "SwarmAgent --> order_mgmt_agent\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_mgmt_agent\n", - "\u001b[0m\n", - "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_3hWx7pZ6Klo6yAovWeab10OY): transfer_order_mgmt_agent_to_order_triage_agent *****\u001b[0m\n", - "Arguments: \n", - "{}\n", - "\u001b[32m****************************************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_order_triage_agent...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_3hWx7pZ6Klo6yAovWeab10OY) *****\u001b[0m\n", - "SwarmAgent --> order_triage_agent\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "Can you please provide the order ID that you need help with?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: customer\n", - "\u001b[0m\n", - "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", - "\n", - "TR13840\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_xTT0iz9pIc5ii6ukXLHjMvLO): check_order_id *****\u001b[0m\n", - "Arguments: \n", - "{\"order_id\": \"TR13840\"}\n", - "\u001b[32m*******************************************************************************\u001b[0m\n", - "\u001b[32m***** Suggested tool call (call_fuKuduzgZtf9o9DCfWcv5jTl): record_order_id *****\u001b[0m\n", - "Arguments: \n", - "{\"order_id\": \"TR13840\"}\n", - "\u001b[32m********************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_xTT0iz9pIc5ii6ukXLHjMvLO) *****\u001b[0m\n", - "Order ID TR13840 is invalid. Please ask for the correct order ID.\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m***** Response from calling tool (call_fuKuduzgZtf9o9DCfWcv5jTl) *****\u001b[0m\n", - "Order ID TR13840 not found. Please ask for the correct order ID.\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "It seems like the Order ID \"TR13840\" is invalid or not found in our system. Could you please double-check the order ID and provide it again?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: customer\n", - "\u001b[0m\n", - "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", - "\n", - "TR13845\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_rhf4Rcn6WP3zaJ1j6uhuuFBG): check_order_id *****\u001b[0m\n", - "Arguments: \n", - "{\"order_id\": \"TR13845\"}\n", - "\u001b[32m*******************************************************************************\u001b[0m\n", - "\u001b[32m***** Suggested tool call (call_nwnWpDKQbm8cUBxmv5LovoE8): record_order_id *****\u001b[0m\n", - "Arguments: \n", - "{\"order_id\": \"TR13845\"}\n", - "\u001b[32m********************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_rhf4Rcn6WP3zaJ1j6uhuuFBG) *****\u001b[0m\n", - "Order ID TR13845 is valid.\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m***** Response from calling tool (call_nwnWpDKQbm8cUBxmv5LovoE8) *****\u001b[0m\n", - "Order ID Recorded: TR13845\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_mgmt_agent\n", - "\u001b[0m\n", - "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_ZXd07TkL7Xk8gvhqCrpHLADQ): transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1 *****\u001b[0m\n", - "Arguments: \n", - "{}\n", - "\u001b[32m****************************************************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_ZXd07TkL7Xk8gvhqCrpHLADQ) *****\u001b[0m\n", - "SwarmAgent --> nested_chat_order_mgmt_agent_1\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: nested_chat_order_mgmt_agent_1\n", - "\u001b[0m\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[34mStarting a new chat....\u001b[0m\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_retrieval_agent):\n", - "\n", - "Order TR13845 for matress is currently shipped. The shipping address is 123 Main St, State College, PA 12345.\n", - "Context:\n", - "Order ID TR13845 is valid.\n", - "Order ID Recorded: TR13845\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33morder_retrieval_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", - "\n", - "Order TR13845, which is for a mattress, has been shipped. The shipping address for this order is 123 Main St, State College, PA 12345.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[34mStarting a new chat....\u001b[0m\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_summariser_agent):\n", - "\n", - "Summarise the order details provided in a tabulated, text-based, order sheet format\n", - "Context: \n", - "Order TR13845, which is for a mattress, has been shipped. The shipping address for this order is 123 Main St, State College, PA 12345.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33morder_summariser_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", - "\n", - "```\n", - "Order Summary:\n", - "\n", - "| Order Number | Product | Status | Shipping Address |\n", - "|--------------|-----------|--------|-----------------------------------|\n", - "| TR13845 | Mattress | Shipped| 123 Main St, State College, PA 12345 |\n", - "\n", - "```\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to chat_manager):\n", - "\n", - "```\n", - "Order Summary:\n", - "\n", - "| Order Number | Product | Status | Shipping Address |\n", - "|--------------|-----------|--------|-----------------------------------|\n", - "| TR13845 | Mattress | Shipped| 123 Main St, State College, PA 12345 |\n", - "\n", - "```\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_mgmt_agent\n", - "\u001b[0m\n", - "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", - "\n", - "Your order with the ID \"TR13845\" is for a Mattress and it has already been shipped to the following address: \n", - "123 Main St, State College, PA 12345.\n", - "\n", - "If there's anything else you need help with, feel free to ask!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: customer\n", - "\u001b[0m\n", - "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", - "\n", - "TR29384\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_mgmt_agent\n", - "\u001b[0m\n", - "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_YQHOPgkKrQorMtZnuuSNVUHO): check_order_id *****\u001b[0m\n", - "Arguments: \n", - "{\"order_id\":\"TR29384\"}\n", - "\u001b[32m*******************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_YQHOPgkKrQorMtZnuuSNVUHO) *****\u001b[0m\n", - "Order ID TR29384 is valid.\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_triage_agent\n", - "\u001b[0m\n", - "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_fVZMv1T3jyDiXJO0lvToaQWS): record_order_id *****\u001b[0m\n", - "Arguments: \n", - "{\"order_id\":\"TR29384\"}\n", - "\u001b[32m********************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_fVZMv1T3jyDiXJO0lvToaQWS) *****\u001b[0m\n", - "Order ID Recorded: TR29384\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_mgmt_agent\n", - "\u001b[0m\n", - "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Suggested tool call (call_S8M1HEKdTnw80oUIUoLyIXZa): transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1 *****\u001b[0m\n", - "Arguments: \n", - "{}\n", - "\u001b[32m****************************************************************************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: Tool_Execution\n", - "\u001b[0m\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1...\u001b[0m\n", - "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", - "\n", - "\u001b[32m***** Response from calling tool (call_S8M1HEKdTnw80oUIUoLyIXZa) *****\u001b[0m\n", - "SwarmAgent --> nested_chat_order_mgmt_agent_1\n", - "\u001b[32m**********************************************************************\u001b[0m\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: nested_chat_order_mgmt_agent_1\n", - "\u001b[0m\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[34mStarting a new chat....\u001b[0m\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_retrieval_agent):\n", - "\n", - "Order TR29384 for bed frame is currently delivered. The shipping address is 123 Main St, State College, PA 12345.\n", - "Context:\n", - "Order ID Recorded: TR29384\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33morder_retrieval_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", - "\n", - "Here are the details for Order TR29384:\n", - "\n", - "- **Item**: Bed Frame\n", - "- **Status**: Delivered\n", - "- **Shipping Address**: 123 Main St, State College, PA 12345\n", - "\n", - "Let me know if there is anything else you need related to this order!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[34mStarting a new chat....\u001b[0m\n", - "\u001b[34m\n", - "********************************************************************************\u001b[0m\n", - "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_summariser_agent):\n", - "\n", - "Summarise the order details provided in a tabulated, text-based, order sheet format\n", - "Context: \n", - "Here are the details for Order TR29384:\n", - "\n", - "- **Item**: Bed Frame\n", - "- **Status**: Delivered\n", - "- **Shipping Address**: 123 Main St, State College, PA 12345\n", - "\n", - "Let me know if there is anything else you need related to this order!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33morder_summariser_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", - "\n", - "```\n", - "Order Summary\n", - "-------------------------\n", - "Order ID: TR29384\n", - "\n", - "| Item | Status | Shipping Address |\n", - "|-----------|-----------|---------------------------------|\n", - "| Bed Frame | Delivered | 123 Main St, State College, PA 12345 |\n", - "\n", - "Thank you for your order!\n", - "```\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to chat_manager):\n", - "\n", - "```\n", - "Order Summary\n", - "-------------------------\n", - "Order ID: TR29384\n", - "\n", - "| Item | Status | Shipping Address |\n", - "|-----------|-----------|---------------------------------|\n", - "| Bed Frame | Delivered | 123 Main St, State College, PA 12345 |\n", - "\n", - "Thank you for your order!\n", - "```\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: order_mgmt_agent\n", - "\u001b[0m\n", - "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", - "\n", - "Your order with the ID \"TR29384\" for a Bed Frame has been delivered. The shipping address is 123 Main St, State College, PA 12345.\n", - "\n", - "If there's anything else you need assistance with, please let me know!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[32m\n", - "Next speaker: customer\n", - "\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "chat_history = initiate_swarm_chat(\n", " initial_agent=order_triage_agent,\n", diff --git a/website/docs/Examples.md b/website/docs/Examples.md index c4e0bce998..e7084d1284 100644 --- a/website/docs/Examples.md +++ b/website/docs/Examples.md @@ -38,6 +38,7 @@ Links to notebook examples: ### Swarms - Orchestrating agents in a Swarm - [View Notebook](/docs/notebooks/agentchat_swarm) +- Orchestrating agents in a Swarm (Enhanced) - [View Notebook](/docs/notebooks/agentchat_swarm_enhanced) ### Applications From a1753e806e2298c779b4e7b99a638ef8e6217edd Mon Sep 17 00:00:00 2001 From: Mark Sze Date: Thu, 19 Dec 2024 17:56:27 +0000 Subject: [PATCH 4/5] Added reference to new notebook from previous Signed-off-by: Mark Sze --- notebook/agentchat_swarm.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notebook/agentchat_swarm.ipynb b/notebook/agentchat_swarm.ipynb index c4635ab881..8e891bb826 100644 --- a/notebook/agentchat_swarm.ipynb +++ b/notebook/agentchat_swarm.ipynb @@ -9,7 +9,9 @@ "\n", "AG2 offers conversable agents, powered by LLMs, tools or a human, that can perform tasks collectively via an automated chat. Recently, OpenAI released a [Swarm](https://github.com/openai/swarm) framework that focuses on making agent coordination and execution lightweight. \n", "\n", - "Now, AG2 offers a simple programming interface to build and orchestrate a swarm of agents. Please check the [Documentation](https://ag2ai.github.io/ag2/docs/topics/swarm) and [Blog](https://ag2ai.github.io/ag2/blog/2024/11/17/Swarm) for more details.\n", + "In AG2 we offer a simple programming interface to build and orchestrate a swarm of agents. Please check the [Documentation](https://ag2ai.github.io/ag2/docs/topics/swarm) and [Blog](https://ag2ai.github.io/ag2/blog/2024/11/17/Swarm) for more details.\n", + "\n", + "After learning the fundamentals of AG2's swarm in this notebook, check out [this notebook](https://ag2ai.github.io/ag2/docs/notebooks/agentchat_swarm) where we take on some more advanced techniques that provide greater control and predicability for your swarms.\n", "\n", "In this notebook, we implement OpenAI's [airline customer service example](https://github.com/openai/swarm/tree/main/examples/airline) in AG2." ] From 8560d202c5fae2a9a58ce05af6f2636238d6dbb6 Mon Sep 17 00:00:00 2001 From: Mark Sze Date: Thu, 19 Dec 2024 18:00:06 +0000 Subject: [PATCH 5/5] Include run results in notebook Signed-off-by: Mark Sze --- notebook/agentchat_swarm_enhanced.ipynb | 446 +++++++++++++++++++++++- 1 file changed, 435 insertions(+), 11 deletions(-) diff --git a/notebook/agentchat_swarm_enhanced.ipynb b/notebook/agentchat_swarm_enhanced.ipynb index 101737f87a..2a368f621a 100644 --- a/notebook/agentchat_swarm_enhanced.ipynb +++ b/notebook/agentchat_swarm_enhanced.ipynb @@ -46,9 +46,18 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + } + ], "source": [ "import autogen\n", "\n", @@ -86,7 +95,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -114,7 +123,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -140,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -195,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -267,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -341,7 +350,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -395,7 +404,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -461,9 +470,424 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "Can you help me with my order.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_RhIdaMav5FoXxvXiYhyDoivV): transfer_order_triage_agent_to_authentication_agent *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m********************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_triage_agent_to_authentication_agent...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_RhIdaMav5FoXxvXiYhyDoivV) *****\u001b[0m\n", + "SwarmAgent --> authentication_agent\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "I can assist you with your order, but first, I'll need to verify your identity. Please provide your username.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "barry\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_gEx5FZ86W62p1vXCVNAkue7t): login_customer_by_username *****\u001b[0m\n", + "Arguments: \n", + "{\"username\":\"barry\"}\n", + "\u001b[32m*******************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION login_customer_by_username...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_gEx5FZ86W62p1vXCVNAkue7t) *****\u001b[0m\n", + "User barry not found. Please ask for the correct username.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "It seems that there is no account associated with the username \"barry.\" Could you please double-check and provide the correct username?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "mark\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: authentication_agent\n", + "\u001b[0m\n", + "\u001b[33mauthentication_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_XmbzzNw7PsYFYsTSVKoylATA): login_customer_by_username *****\u001b[0m\n", + "Arguments: \n", + "{\"username\":\"mark\"}\n", + "\u001b[32m*******************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION login_customer_by_username...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_XmbzzNw7PsYFYsTSVKoylATA) *****\u001b[0m\n", + "Welcome back our customer, Mark Sze! Please continue helping them.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_mXHJHDzVPTXWDhll0UH7w3QI): transfer_order_triage_agent_to_order_mgmt_agent *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_triage_agent_to_order_mgmt_agent...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_mXHJHDzVPTXWDhll0UH7w3QI) *****\u001b[0m\n", + "SwarmAgent --> order_mgmt_agent\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "Sure, Mark! Could you please provide me with the Order ID you are enquiring about?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "TR14234\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_UMS0fVQEAW9Hkqo3paa6ZDp5): check_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR14234\"}\n", + "\u001b[32m*******************************************************************************\u001b[0m\n", + "\u001b[32m***** Suggested tool call (call_ERAQ8vgnCagMuvCthkZ6E5l7): record_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR14234\"}\n", + "\u001b[32m********************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_UMS0fVQEAW9Hkqo3paa6ZDp5) *****\u001b[0m\n", + "Order ID TR14234 is invalid. Please ask for the correct order ID.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m***** Response from calling tool (call_ERAQ8vgnCagMuvCthkZ6E5l7) *****\u001b[0m\n", + "Order ID Recorded: TR14234\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "It seems that the Order ID \"TR14234\" is invalid. Could you please double-check and provide the correct Order ID?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "TR14234\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_DqbSSNveiHpMydYE7pOyfkaP): check_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\":\"TR14234\"}\n", + "\u001b[32m*******************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_DqbSSNveiHpMydYE7pOyfkaP) *****\u001b[0m\n", + "Order ID TR14234 is invalid. Please ask for the correct order ID.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "The Order ID \"TR14234\" still appears to be invalid. Could you please verify and provide the correct Order ID or any additional information that might help us find your order?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "TR13845\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_miEIpNwDd1FFGLenwUB3oPMq): check_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR13845\"}\n", + "\u001b[32m*******************************************************************************\u001b[0m\n", + "\u001b[32m***** Suggested tool call (call_uHRdFcp41PIp4KWCuHUdWQxo): record_order_id *****\u001b[0m\n", + "Arguments: \n", + "{\"order_id\": \"TR13845\"}\n", + "\u001b[32m********************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION check_order_id...\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION record_order_id...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_miEIpNwDd1FFGLenwUB3oPMq) *****\u001b[0m\n", + "Order ID TR13845 is valid.\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m***** Response from calling tool (call_uHRdFcp41PIp4KWCuHUdWQxo) *****\u001b[0m\n", + "Order ID Recorded: TR13845\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_sYsVS1U3k3Cf2KbqKJ4hhyRa): transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1 *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_nested_chat_order_mgmt_agent_1...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_sYsVS1U3k3Cf2KbqKJ4hhyRa) *****\u001b[0m\n", + "SwarmAgent --> nested_chat_order_mgmt_agent_1\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: nested_chat_order_mgmt_agent_1\n", + "\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[34mStarting a new chat....\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_retrieval_agent):\n", + "\n", + "Order TR13845 for matress is currently shipped. The shipping address is 123 Main St, State College, PA 12345.\n", + "Context:\n", + "Order ID TR13845 is valid.\n", + "Order ID Recorded: TR13845\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33morder_retrieval_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", + "\n", + "It looks like order TR13845 for a mattress has been shipped. The shipping address for this order is 123 Main St, State College, PA 12345. If you need further details about this order, just let me know!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[34mStarting a new chat....\u001b[0m\n", + "\u001b[34m\n", + "********************************************************************************\u001b[0m\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to order_summariser_agent):\n", + "\n", + "Summarise the order details provided in a tabulated, text-based, order sheet format\n", + "Context: \n", + "It looks like order TR13845 for a mattress has been shipped. The shipping address for this order is 123 Main St, State College, PA 12345. If you need further details about this order, just let me know!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[31m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + "\u001b[33morder_summariser_agent\u001b[0m (to nested_chat_order_mgmt_agent_1):\n", + "\n", + "```\n", + "Order Summary:\n", + "----------------------------------------------------\n", + "Order Number : TR13845\n", + "Product : Mattress\n", + "Status : Shipped\n", + "Shipping Address : 123 Main St, \n", + " State College, PA 12345\n", + "----------------------------------------------------\n", + "```\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mnested_chat_order_mgmt_agent_1\u001b[0m (to chat_manager):\n", + "\n", + "```\n", + "Order Summary:\n", + "----------------------------------------------------\n", + "Order Number : TR13845\n", + "Product : Mattress\n", + "Status : Shipped\n", + "Shipping Address : 123 Main St, \n", + " State College, PA 12345\n", + "----------------------------------------------------\n", + "```\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "Your order with the Order Number TR13845, which involves a \"Mattress,\" has already been shipped. It is on its way to 123 Main St, State College, PA 12345. \n", + "\n", + "If you have any more questions or need further assistance, feel free to ask!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n", + "\u001b[33mcustomer\u001b[0m (to chat_manager):\n", + "\n", + "All good\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_mgmt_agent\n", + "\u001b[0m\n", + "\u001b[33morder_mgmt_agent\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested tool call (call_VtBmcKhDAhh7JUz9aXyPq9Aj): transfer_order_mgmt_agent_to_order_triage_agent *****\u001b[0m\n", + "Arguments: \n", + "{}\n", + "\u001b[32m****************************************************************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: Tool_Execution\n", + "\u001b[0m\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION transfer_order_mgmt_agent_to_order_triage_agent...\u001b[0m\n", + "\u001b[33mTool_Execution\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling tool (call_VtBmcKhDAhh7JUz9aXyPq9Aj) *****\u001b[0m\n", + "SwarmAgent --> order_triage_agent\n", + "\u001b[32m**********************************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: order_triage_agent\n", + "\u001b[0m\n", + "\u001b[33morder_triage_agent\u001b[0m (to chat_manager):\n", + "\n", + "I'm glad we could assist you, Mark! If you have any more inquiries in the future or need further support, feel free to reach out. Have a great day!\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[32m\n", + "Next speaker: customer\n", + "\u001b[0m\n" + ] + } + ], "source": [ "chat_history = initiate_swarm_chat(\n", " initial_agent=order_triage_agent,\n",