From 953a76535b79a5d73def125a0f589500b712abc1 Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:34:20 -0700 Subject: [PATCH] Update outputs (#595) --- .../information-gather-prompting.ipynb | 252 ++---------------- 1 file changed, 23 insertions(+), 229 deletions(-) diff --git a/examples/chatbots/information-gather-prompting.ipynb b/examples/chatbots/information-gather-prompting.ipynb index 12796cdf7..3986886ef 100644 --- a/examples/chatbots/information-gather-prompting.ipynb +++ b/examples/chatbots/information-gather-prompting.ipynb @@ -232,17 +232,10 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "id": "25793988-45a2-4e65-b33c-64e72aadb10e", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "<<<<<<< local\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -252,249 +245,50 @@ "Hello! How can I assist you today?\n", "==================================\u001b[1m Ai Message \u001b[0m==================================\n", "\n", - "Sure! I can help you create an extraction prompt. To get started, I need some information from you:\n", + "Sure! I can help you with that. To create an extraction prompt, I need some information from you. Could you please provide the following details:\n", "\n", "1. What is the objective of the prompt?\n", "2. What variables will be passed into the prompt template?\n", "3. Any constraints for what the output should NOT do?\n", "4. Any requirements that the output MUST adhere to?\n", "\n", - "Please provide me with the details so that I can create the prompt template accordingly.\n", + "Once I have this information, I can create the extraction prompt for you.\n", "==================================\u001b[1m Ai Message \u001b[0m==================================\n", "\n", - "Great! To clarify, is the objective of the prompt to gather feedback on customer satisfaction (CSAT)?\n", - "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Great! To create an extraction prompt for filling out a CSAT (Customer Satisfaction) survey, I will need the following information:\n", "\n", - "Got it! So, the variables that will be passed into the prompt template are the user's score and their comment. \n", + "1. Objective: To gather feedback on customer satisfaction.\n", + "2. Variables: Customer name, Date of interaction, Service provided, Rating (scale of 1-5), Comments.\n", + "3. Constraints: The output should not include any personally identifiable information (PII) of the customer.\n", + "4. Requirements: The output must include a structured format with fields for each variable mentioned above.\n", "\n", - "Now, could you please specify any constraints for what the output should NOT do and any requirements that the output MUST adhere to?\n", - "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "With this information, I will proceed to create the extraction prompt template for filling out a CSAT survey. Let's get started!\n", "Tool Calls:\n", - " PromptInstructions (call_NJIJ5lbJbAKmUpLR0yRuwF5V)\n", - " Call ID: call_NJIJ5lbJbAKmUpLR0yRuwF5V\n", + " PromptInstructions (call_aU48Bjo7X29tXfRtCcrXkrqq)\n", + " Call ID: call_aU48Bjo7X29tXfRtCcrXkrqq\n", " Args:\n", - " objective: Gather feedback on customer satisfaction (CSAT)\n", - " variables: ['User score', 'Comment']\n", - " constraints: []\n", - " requirements: []\n", + " objective: To gather feedback on customer satisfaction.\n", + " variables: ['Customer name', 'Date of interaction', 'Service provided', 'Rating (scale of 1-5)', 'Comments']\n", + " constraints: ['The output should not include any personally identifiable information (PII) of the customer.']\n", + " requirements: ['The output must include a structured format with fields for each variable mentioned above.']\n", "=================================\u001b[1m Tool Message \u001b[0m=================================\n", "\n", "Prompt generated!\n", "==================================\u001b[1m Ai Message \u001b[0m==================================\n", "\n", - "We would love to hear your feedback on your recent experience with us. Please take a moment to share your thoughts by answering the following questions:\n", + "Please provide feedback on your recent interaction with our service. Your input is valuable to us in improving our services.\n", "\n", - "1. On a scale of 1 to 10, how satisfied are you with our service? (1 being very dissatisfied and 10 being extremely satisfied)\n", - "User score: [Insert response]\n", + "Customer name: \n", + "Date of interaction: \n", + "Service provided: \n", + "Rating (scale of 1-5): \n", + "Comments: \n", "\n", - "2. Please provide any additional comments or suggestions to help us improve our service:\n", - "Comment: [Insert response]\n", - "\n", - "Thank you for your valuable feedback!\n", + "Please note that the output should not include any personally identifiable information (PII) of the customer. Your feedback will be kept confidential and used for internal evaluation purposes only. Thank you for taking the time to share your thoughts with us.\n", "Done!\n", "==================================\u001b[1m Ai Message \u001b[0m==================================\n", "\n", - "I'm glad you liked it! If you need any more assistance or have any other requests, feel free to let me know. Have a great day!\n", - "==================================\u001b[1m Ai Message \u001b[0m==================================\n", - "\n", - "You too! Take care!\n", - "AI: Byebye\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "=======\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Hello! How can I assist you today?' response_metadata={'token_usage': {'completion_tokens': 10, 'prompt_tokens': 170, 'total_tokens': 180}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None} id='run-82cac254-ed31-40c7-8155-9de6596ab47f-0' usage_metadata={'input_tokens': 170, 'output_tokens': 10, 'total_tokens': 180}\n", - "\n", - "---\n", - "\n", - "Output from node 'info':\n", - "---\n", - "content='Sure! I can help you with that. To create an extraction prompt, I need some information from you. \\n\\nCan you please provide the following details:\\n1. What is the objective of the prompt?\\n2. What variables will be passed into the prompt template?\\n3. Any constraints for what the output should NOT do?\\n4. Any requirements that the output MUST adhere to?\\n\\nOnce I have this information, I can assist you in creating the extraction prompt template.' response_metadata={'token_usage': {'completion_tokens': 94, 'prompt_tokens': 193, 'total_tokens': 287}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None} id='run-b66dbf2e-de98-4022-891e-2f6c8e8676f6-0' usage_metadata={'input_tokens': 193, 'output_tokens': 94, 'total_tokens': 287}\n", - "\n", - "---\n", - "\n", - "Output from node 'info':\n", - "---\n", - "content='Great! Thank you for providing the objective of the prompt. \\n\\nNow, could you please specify the variables that will be passed into the prompt template for populating the CSAT record in your CRM? \\n\\nAdditionally, are there any constraints for what the output should NOT do and any requirements that the output MUST adhere to? \\n\\nOnce I have this information, I can help you create the extraction prompt template for populating the CSAT record in your CRM.' response_metadata={'token_usage': {'completion_tokens': 92, 'prompt_tokens': 306, 'total_tokens': 398}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None} id='run-26e74d73-5d7c-4731-b2fc-f345cdf81bba-0' usage_metadata={'input_tokens': 306, 'output_tokens': 92, 'total_tokens': 398}\n", - "\n", - "---\n", - "\n", - "Output from node 'info':\n", - "---\n", - "content='' additional_kwargs={'tool_calls': [{'id': 'call_hjFAEvsaJhpeJ5001ZdCEyst', 'function': {'arguments': '{\"objective\":\"Create an extraction prompt template to populate a CSAT record in a CRM\",\"variables\":[\"comment\",\"score\"],\"constraints\":[\"Output should be valid JSON\",\"Output should reflect/summarize the user\\'s inputs\"],\"requirements\":[\"Output must adhere to the specified variables\"]}', 'name': 'PromptInstructions'}, 'type': 'function'}]} response_metadata={'token_usage': {'completion_tokens': 64, 'prompt_tokens': 432, 'total_tokens': 496}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None} id='run-38042cdf-8574-4565-bb39-419ee777819d-0' tool_calls=[{'name': 'PromptInstructions', 'args': {'objective': 'Create an extraction prompt template to populate a CSAT record in a CRM', 'variables': ['comment', 'score'], 'constraints': ['Output should be valid JSON', \"Output should reflect/summarize the user's inputs\"], 'requirements': ['Output must adhere to the specified variables']}, 'id': 'call_hjFAEvsaJhpeJ5001ZdCEyst'}] usage_metadata={'input_tokens': 432, 'output_tokens': 64, 'total_tokens': 496}\n", - "\n", - "---\n", - "\n", - "Output from node 'prompt':\n", - "---\n", - "content='## CSAT Record Extraction Prompt Template\\n\\n### Objective:\\nCreate an extraction prompt template to populate a CSAT record in a CRM.\\n\\n### Variables:\\n1. `comment`: (string) The feedback comment provided by the customer.\\n2. `score`: (integer) The satisfaction score given by the customer.\\n\\n### Constraints:\\n- Output should be valid JSON.\\n- Output should reflect/summarize the user\\'s inputs.\\n\\n### Requirements:\\nOutput must adhere to the specified variables.\\n\\n#### Prompt Template:\\n```json\\n{\\n \"comment\": \"Please provide your feedback here.\",\\n \"score\": \"On a scale of 1-10, how satisfied are you with our service?\"\\n}\\n```' response_metadata={'token_usage': {'completion_tokens': 138, 'prompt_tokens': 82, 'total_tokens': 220}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None} id='run-01ae6136-5c1e-41f8-9746-93304dfd489d-0' usage_metadata={'input_tokens': 82, 'output_tokens': 138, 'total_tokens': 220}\n", - "\n", - "---\n", - "\n", - "AI: Byebye\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - ">>>>>>> remote\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Hello! How can I assist you today?'\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): build me a prompt for extraction\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Sure! I can help you with that. Could you please provide me with more details about the prompt you want to create? Specifically, I need to know the objective of the prompt, the variables that will be passed into the prompt template, any constraints for what the output should not do, and any requirements that the output must adhere to.'\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): i want to do extraction over a page\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Great! Could you please provide me with more details about the objective of the extraction? What specific information are you looking to extract from the page?'\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): i want the user to specify that at run time\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content=\"Understood. So the objective of the prompt is to allow the user to specify the information they want to extract from a page at runtime. \\n\\nNow, let's move on to the variables. Are there any specific variables that you would like to pass into the prompt template? For example, the URL of the page or any other parameters that might be relevant for the extraction process.\"\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): the schema to extract, and the text to extract it from\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Got it. So the variables that will be passed into the prompt template are the schema to extract and the text to extract it from.\\n\\nNext, are there any constraints for what the output should not do? For example, should the output not include any sensitive information or should it not exceed a certain length?'\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): it must be in json\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Understood. So a requirement for the output is that it must be in JSON format.\\n\\nLastly, are there any specific requirements that the output must adhere to? For example, should the output follow a specific structure or include certain fields?'\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): must be json, must include the same fields as the schema specified\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output from node 'info':\n", - "---\n", - "content='Got it. So the requirements for the output are that it must be in JSON format and it must include the same fields as the schema specified.\\n\\nBased on the information you provided, I will now generate the prompt template for extraction. Please give me a moment.\\n\\n' additional_kwargs={'tool_calls': [{'id': 'call_6roy9dQoIrQZsHffR9kjAr0e', 'function': {'arguments': '{\\n \"objective\": \"Extract specific information from a page\",\\n \"variables\": [\"schema\", \"text\"],\\n \"constraints\": [\"Output should not include sensitive information\", \"Output should not exceed a certain length\"],\\n \"requirements\": [\"Output must be in JSON format\", \"Output must include the same fields as the specified schema\"]\\n}', 'name': 'PromptInstructions'}, 'type': 'function'}]}\n", - "\n", - "---\n", - "\n", - "Output from node 'prompt':\n", - "---\n", - "content='Extract specific information from a page and output the result in JSON format. The input page should contain the following fields: {{schema}}. The extracted information should be stored in the variable {{text}}. Ensure that the output does not include any sensitive information and does not exceed a certain length. Additionally, the output should include the same fields as the specified schema.'\n", - "\n", - "---\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User (q/Q to quit): q\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "I'm glad you found it helpful! If you need any more assistance or have any other requests, feel free to let me know. Have a great day!\n", "AI: Byebye\n" ] }