From 01cc0ae7c3dd0e30c59bd12ed4ff3e43d53414b1 Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Sat, 9 Mar 2024 21:36:34 -0800 Subject: [PATCH] Update tutorial examples, reference to register_reply. (#1941) * update tutorial examples, writings, reference to register_reply. * update * update --- .../docs/tutorial/conversation-patterns.ipynb | 10 + website/docs/tutorial/human-in-the-loop.ipynb | 287 ++++++------------ website/docs/tutorial/introduction.ipynb | 29 +- website/docs/tutorial/termination.ipynb | 76 +++-- 4 files changed, 170 insertions(+), 232 deletions(-) diff --git a/website/docs/tutorial/conversation-patterns.ipynb b/website/docs/tutorial/conversation-patterns.ipynb index 7fb32104b33..c3da6fda058 100644 --- a/website/docs/tutorial/conversation-patterns.ipynb +++ b/website/docs/tutorial/conversation-patterns.ipynb @@ -1519,6 +1519,16 @@ "from 3 to 7." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The implementation of the nested chats handler makes use of the\n", + "[`registered_reply`](../reference/agentchat/conversable_agent/#register_reply)\n", + "method, which allows you to make extensive customization to\n", + " `ConversableAgent`." + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/website/docs/tutorial/human-in-the-loop.ipynb b/website/docs/tutorial/human-in-the-loop.ipynb index 26c99b9a55f..cde9a57ade1 100644 --- a/website/docs/tutorial/human-in-the-loop.ipynb +++ b/website/docs/tutorial/human-in-the-loop.ipynb @@ -8,7 +8,19 @@ "\n", "In the last two chapters we introduced the `ConversableAgent` class and showed how you can use it to create autonomous (`human_input_mode=NEVER`) agents that can accomplish tasks. We also showed how to properly terminate a conversation between agents.\n", "\n", - "But many applications may require putting humans in-the-loop with agents. For example, to allow human feedback to steer agents in the right direction, specify goals, etc. In this chapter, we will show how AutoGen supports human intervention." + "But many applications may require putting humans in-the-loop with agents. For example, to allow human feedback to steer agents in the right direction, specify goals, etc. In this chapter, we will show how AutoGen supports human intervention.\n", + "\n", + "In AutoGen's `ConversableAgent`, the human-the-loop component sits in front\n", + "of the auto-reply components. It can intercept the incoming messages and\n", + "decide whether to pass them to the auto-reply components or to provide\n", + "human feedback. The figure below illustrates the design.\n", + "\n", + "```{=mdx}\n", + "![Human in the loop](./assets/human-in-the-loop.png)\n", + "```\n", + "\n", + "The human-in-the-loop component can be customized through the `human_input_mode` parameter.\n", + "We will show you how to use it in the following sections." ] }, { @@ -32,16 +44,6 @@ "Below we show one such example again and then show the differences when this mode is set to `ALWAYS` and `NEVER` instead." ] }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "from autogen import ConversableAgent" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -53,14 +55,13 @@ "This mode is useful when you want your agents to act fully autonomously.\n", "\n", "Here is an example of using this mode to run a simple guess-a-number game between\n", - "two agents, with the maximum number of guesses set to 5 through\n", - "`max_consecutive_auto_reply`, and the termination message set to check for the \n", + "two agents, the termination message is set to check for the \n", "number that is the correct guess." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -71,10 +72,16 @@ "\n", "I have a number between 1 and 100. Guess it!\n", "\n", - "--------------------------------------------------------------------------------\n", + "--------------------------------------------------------------------------------\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "50\n", + "Is it 50?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", @@ -84,7 +91,7 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "75\n", + "Is it 75?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", @@ -94,7 +101,7 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "62\n", + "Is it 63?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", @@ -104,7 +111,7 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "56\n", + "Is it 57?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", @@ -114,13 +121,36 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "53\n", + "Is it 54?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", + "\n", + "Too high.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", + "\n", + "Is it 52?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", + "\n", + "Too low.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", + "\n", + "Is it 53?\n", "\n", "--------------------------------------------------------------------------------\n" ] } ], "source": [ + "import os\n", + "from autogen import ConversableAgent\n", + "\n", "agent_with_number = ConversableAgent(\n", " \"agent_with_number\",\n", " system_message=\"You are playing a game of guess-my-number. You have the \"\n", @@ -150,10 +180,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Yay! The game is over. The guessing agent got the number correctly in exactly\n", - "5 guesses using binary search -- very efficient!\n", - "You can see that the conversation was terminated after the 5th guess which\n", - "triggered both the counter-based and message-based termination conditions." + "Yay! The game is over. The guessing agent got the number correctly \n", + "using binary search -- very efficient!\n", + "You can see that the conversation was terminated after the guessing agent\n", + "said the correct number, which triggered \n", + "the message-based termination condition." ] }, { @@ -172,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -191,7 +222,7 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mhuman_proxy\u001b[0m (to agent_with_number):\n", "\n", - "70\n", + "79\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_with_number\u001b[0m (to human_proxy):\n", @@ -201,17 +232,22 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mhuman_proxy\u001b[0m (to agent_with_number):\n", "\n", - "50\n", + "76\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_with_number\u001b[0m (to human_proxy):\n", "\n", - "Too low.\n", + "Too high.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mhuman_proxy\u001b[0m (to agent_with_number):\n", "\n", - "53\n", + "I give up\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33magent_with_number\u001b[0m (to human_proxy):\n", + "\n", + "That's okay! The number I was thinking of was 53.\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -253,12 +289,15 @@ "choose to terminate, the conversation will be terminated.\n", "\n", "Let us see this mode in action by playing the same game again, but this time\n", - "the agent with the number will choose a new number and the game will restart." + "the guessing agent will only have two chances to guess the number, and if it \n", + "fails, the human will be asked to provide feedback,\n", + "and the guessing agent gets two more chances.\n", + "If the correct number is guessed eventually, the conversation will be terminated." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -272,11 +311,17 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "50\n", + "Is it 50?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", + ">>>>>>>> USING AUTO REPLY...\u001b[0m\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", "\n", "Too low.\n", @@ -284,19 +329,17 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "75\n", + "Is it 75?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", "\n", - "Too high.\n", + "It is too high my friend. \n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "62\n", + "Is it 60?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[31m\n", @@ -308,171 +351,39 @@ "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "56\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Too high.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "53\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Correct! You've guessed my number.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "Great! This was a fun game. Let's play again sometime.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "10\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "Your guess is too high.\n", + "Is it 55?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Okay, let's try 5.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "Your guess is too high.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Okay, how about 2?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "Your guess is too low.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Alright, then it must be 3.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "Yes, correct! The number was 3. Good job guessing it!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Thank you! That was indeed a fun game. I look forward to playing again with you.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "I'm glad you enjoyed it! I'm always here for a good game. Don't hesitate to come back when you want to play again.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Surely, I will. This was fun. Thanks for playing with me. See you next time!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "You're welcome! I'm glad you had fun. Looking forward to our next game. See you next time!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Lets play again\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "Sure! I'll think of a number between 1 and 100. Let's start guessing!\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", "\n", - "I'll start with 50.\n", + "still too high, but you are very close.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "The guess is too low.\n", + "Is it 52?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[31m\n", ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", "\n", - "Okay, let's try 75.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "The guess is too high.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "How about 62?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", - "\n", - "The guess is too low.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", - "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", - "\n", - "Then, let's try 68.\n", + "Too low.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "The guess is too high.\n", + "Is it 54?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[31m\n", - ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", "\u001b[33magent_with_number\u001b[0m (to agent_guess_number):\n", "\n", - "Okay, how about 65?\n", + "Almost there! \n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33magent_guess_number\u001b[0m (to agent_with_number):\n", "\n", - "Yes, correct! The number was 65. Good job guessing it!\n", + "Is it 53?\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -486,7 +397,8 @@ " \"number 53 in your mind, and I will try to guess it. \"\n", " \"If I guess too high, say 'too high', if I guess too low, say 'too low'. \",\n", " llm_config={\"config_list\": [{\"model\": \"gpt-4\", \"api_key\": os.environ[\"OPENAI_API_KEY\"]}]},\n", - " max_consecutive_auto_reply=5,\n", + " max_consecutive_auto_reply=1, # maximum number of consecutive auto-replies before asking for human input\n", + " is_termination_msg=lambda msg: \"53\" in msg[\"content\"], # terminate if the number is guessed by the other agent\n", " human_input_mode=\"TERMINATE\", # ask for human input until the game is terminated\n", ")\n", "\n", @@ -509,13 +421,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In the previous conversation, we were asked to provide human input first time\n", - "when the counter-based termination condition was met. We intercepted the\n", - "message and replied \"Let's play again\". The conversation continued and the\n", - "counter was reset. The game continued until the counter-based termination\n", - "condition was met again, and this time we chose to skip. The conversation\n", - "continued again but human input was requested at every turn since, and we\n", - "chose to skip each time until the game was over." + "In the previous conversation,\n", + "\n", + "1. When the agent guessed \"74\", the human said \"It is too high my friend.\"\n", + "2. When the agent guessed \"55\", the human said \"still too high, but you are very close.\"\n", + "3. When the agent guessed \"54\", the human said \"Almost there!\"\n", + "\n", + "Each time after one auto-reply from the agent with the number,\n", + "the human was asked to provide feedback.\n", + "Once the human provided feedback, the counter was reset.\n", + "The conversation was terminated after the agent correctly guessed \"53\"." ] }, { @@ -550,7 +465,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/website/docs/tutorial/introduction.ipynb b/website/docs/tutorial/introduction.ipynb index 8f7d48e79a9..ef40ce7e0c0 100644 --- a/website/docs/tutorial/introduction.ipynb +++ b/website/docs/tutorial/introduction.ipynb @@ -64,7 +64,8 @@ "4. A component for keeping human-in-the-loop\n", "\n", "You can switch each component on or off and customize it to suit the need of \n", - "your application. You even can add additional components to the agent's capabilities." + "your application. For advanced users, you can add additional components to the agent\n", + "by using [`registered_reply`](../reference/agentchat/conversable_agent/#register_reply). " ] }, { @@ -118,9 +119,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Sure, here's one for you:\n", + "Sure, here's a light-hearted joke for you:\n", "\n", - "Why don't scientists trust atoms? \n", + "Why don't scientists trust atoms?\n", "\n", "Because they make up everything!\n" ] @@ -173,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -182,12 +183,12 @@ "text": [ "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Tell me a joke.\n", + "Cathy, tell me a joke.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", - "Sure, here's a classic one for you:\n", + "Sure, here's one for you:\n", "\n", "Why don't scientists trust atoms?\n", "\n", @@ -196,27 +197,27 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "That's a great one, Joe! Here's my turn:\n", + "Haha, that's a good one, Cathy! Okay, my turn. \n", "\n", - "Why don't some fish play piano?\n", + "Why don't we ever tell secrets on a farm?\n", "\n", - "Because you can't tuna fish!\n", + "Because the potatoes have eyes, the corn has ears, and the beans stalk.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", - "Haha, good one, Cathy! I have another:\n", + "Haha, that's a great one! A farm is definitely not the place for secrets. Okay, my turn again. \n", "\n", - "Why was the math book sad?\n", + "Why couldn't the bicycle stand up by itself?\n", "\n", - "Because it had too many problems!\n", + "Because it was two-tired!\n", "\n", "--------------------------------------------------------------------------------\n" ] } ], "source": [ - "result = joe.initiate_chat(cathy, message=\"Tell me a joke.\", max_turns=2)" + "result = joe.initiate_chat(cathy, message=\"Cathy, tell me a joke.\", max_turns=2)" ] }, { @@ -255,7 +256,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/website/docs/tutorial/termination.ipynb b/website/docs/tutorial/termination.ipynb index 994f7daff24..97758dc1e47 100644 --- a/website/docs/tutorial/termination.ipynb +++ b/website/docs/tutorial/termination.ipynb @@ -69,11 +69,13 @@ "text": [ "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Tell me a joke.\n", + "Cathy, tell me a joke.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", + "Sure, here's one for you:\n", + "\n", "Why don't scientists trust atoms?\n", "\n", "Because they make up everything!\n", @@ -81,30 +83,32 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Great one, Joe! Here's one to add to our routine. Why don't we ever tell secrets on a farm?\n", + "Haha, that's a good one, Cathy! Okay, my turn. \n", + "\n", + "Why don't we ever tell secrets on a farm?\n", "\n", - "Because the potatoes have eyes, the corn has ears, and the beans stalk!\n", + "Because the potatoes have eyes, the corn has ears, and the beans stalk.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", - "Oh, Cathy, that's a good one! I love it. Let's keep the comedy rolling. How about this one? \n", + "Haha, that's a great one! A farm is definitely not the place for secrets. Okay, my turn again. \n", "\n", - "Why don't some fish play piano?\n", + "Why couldn't the bicycle stand up by itself?\n", "\n", - "Because you can't tuna fish!\n", + "Because it was two-tired!\n", "\n", "--------------------------------------------------------------------------------\n" ] } ], "source": [ - "result = joe.initiate_chat(cathy, message=\"Tell me a joke.\", max_turns=2)" + "result = joe.initiate_chat(cathy, message=\"Cathy, tell me a joke.\", max_turns=2)" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -113,11 +117,13 @@ "text": [ "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Tell me a joke.\n", + "Cathy, tell me a joke.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", + "Sure, here's one for you:\n", + "\n", "Why don't scientists trust atoms?\n", "\n", "Because they make up everything!\n", @@ -125,36 +131,38 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Great one, Joe! Here's one to add to our routine. Why don't we ever tell secrets on a farm?\n", + "Haha, that's a good one, Cathy! Okay, my turn. \n", "\n", - "Because the potatoes have eyes, the corn has ears, and the beans stalk!\n", + "Why don't we ever tell secrets on a farm?\n", + "\n", + "Because the potatoes have eyes, the corn has ears, and the beans stalk.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", - "Oh, Cathy, that's a good one! I love it. Let's keep the comedy rolling. How about this one? \n", + "Haha, that's a great one! A farm is definitely not the place for secrets. Okay, my turn again. \n", "\n", - "Why don't some fish play piano?\n", + "Why couldn't the bicycle stand up by itself?\n", "\n", - "Because you can't tuna fish!\n", + "Because it was two-tired!\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Hah, classic! Alright, here's my comeback. \n", + "Haha, that's a wheely good one, Cathy!\n", "\n", - "Why don't skeletons fight each other?\n", + "Why did the golfer bring two pairs of pants?\n", "\n", - "Because they don't have the guts!\n", + "In case he got a hole in one!\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", - "Oh Cathy, you really have a funny bone! Well here's mine:\n", + "Haha, that's a perfect swing of a joke!\n", "\n", - "What do you call a snowman with a six-pack?\n", + "Why did the scarecrow win an award?\n", "\n", - "An abdominal snowman!\n", + "Because he was outstanding in his field!\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -162,7 +170,7 @@ ], "source": [ "result = joe.initiate_chat(\n", - " cathy, message=\"Tell me a joke.\", max_turns=3\n", + " cathy, message=\"Cathy, tell me a joke.\", max_turns=3\n", ") # increase the number of max turns before termination" ] }, @@ -190,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -199,11 +207,13 @@ "text": [ "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Tell me a joke.\n", + "Cathy, tell me a joke.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", + "Sure, here's one for you:\n", + "\n", "Why don't scientists trust atoms?\n", "\n", "Because they make up everything!\n", @@ -211,18 +221,20 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Great one, Joe! Here's one to add to our routine. Why don't we ever tell secrets on a farm?\n", + "Haha, that's a good one, Cathy! Okay, my turn. \n", + "\n", + "Why don't we ever tell secrets on a farm?\n", "\n", - "Because the potatoes have eyes, the corn has ears, and the beans stalk!\n", + "Because the potatoes have eyes, the corn has ears, and the beans stalk.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mcathy\u001b[0m (to joe):\n", "\n", - "Oh, Cathy, that's a good one! I love it. Let's keep the comedy rolling. How about this one? \n", + "Haha, that's a great one! A farm is definitely not the place for secrets. Okay, my turn again. \n", "\n", - "Why don't some fish play piano?\n", + "Why couldn't the bicycle stand up by itself?\n", "\n", - "Because you can't tuna fish!\n", + "Because it was two-tired!\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -237,7 +249,7 @@ " max_consecutive_auto_reply=1, # Limit the number of consecutive auto-replies.\n", ")\n", "\n", - "result = joe.initiate_chat(cathy, message=\"Tell me a joke.\")" + "result = joe.initiate_chat(cathy, message=\"Cathy, tell me a joke.\")" ] }, { @@ -260,7 +272,7 @@ "text": [ "\u001b[33mjoe\u001b[0m (to cathy):\n", "\n", - "Tell me a joke and then say the words GOOD BYE.\n", + "Cathy, tell me a joke and then say the words GOOD BYE.\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -290,7 +302,7 @@ " is_termination_msg=lambda msg: \"good bye\" in msg[\"content\"].lower(),\n", ")\n", "\n", - "result = joe.initiate_chat(cathy, message=\"Tell me a joke and then say the words GOOD BYE.\")" + "result = joe.initiate_chat(cathy, message=\"Cathy, tell me a joke and then say the words GOOD BYE.\")" ] }, { @@ -335,7 +347,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.5" } }, "nbformat": 4,