From 46093978925a68a26fee3f339d728d521e4ae696 Mon Sep 17 00:00:00 2001 From: Nicole Brewer Date: Sun, 31 Mar 2024 16:09:01 -0700 Subject: [PATCH] Added ChatBot view --- jupyter_mentor/chatbot.py | 83 +++++++++++++++++++++++ nbs/chatbot.ipynb | 138 ++++++++++++++++++++++++++++++++++++++ nbs/fourthTab.ipynb | 111 ------------------------------ 3 files changed, 221 insertions(+), 111 deletions(-) create mode 100644 jupyter_mentor/chatbot.py create mode 100644 nbs/chatbot.ipynb delete mode 100644 nbs/fourthTab.ipynb diff --git a/jupyter_mentor/chatbot.py b/jupyter_mentor/chatbot.py new file mode 100644 index 0000000..b54a2bd --- /dev/null +++ b/jupyter_mentor/chatbot.py @@ -0,0 +1,83 @@ +# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/chatbot.ipynb. + +# %% auto 0 +__all__ = ['ChatBot'] + +# %% ../nbs/chatbot.ipynb 1 +import ipywidgets as widgets +from ipywidgets import Textarea, Text, Layout, HBox + +# %% ../nbs/chatbot.ipynb 2 +class ChatBot(widgets.VBox): + + def __init__(self): + # If you forget to call the superconstructor on an extended widget + # you will get an AttributeError: object has no attribute '_model_id' + super().__init__() + + example_convo = ''' +User: Hello, bot! + +Bot: Hi there! How can I assist you today? + +User: I need help setting up my email account. Can you guide me through the process? + +Bot: Of course! Could you please provide me with the email service provider you're using? + +User: I use Gmail. + +Bot: Great! First, go to the Gmail website and click on the "Create account" button. + +User: Okay, I'm there. What's next? + +Bot: Enter your personal information such as your name, desired email address, password, and recovery information. + +User: Done! What's next? + +Bot: Follow the prompts to verify your phone number and agree to the terms of service. + +User: All set! Thank you for your help, bot! + +Bot: You're welcome! If you have any more questions, feel free to ask. +''' + self.chat = Textarea( + disabled = True, + value = example_convo, + layout=Layout(width='90%', height='400px') + ) + self.user_input_and_submit = HBox() + self.user_input = widgets.Text( + placeholder='Message AI chatbot...', + #layout=Layout(width='100%') + ) + self.submit = widgets.ToggleButton( + value=False, + disabled=False, + button_style='success', + icon='arrow-circle-right' + ) + self.user_input_and_submit.children = (self.user_input, self.submit) + + self.suggestion_buttons = HBox() + self.step_by_step = widgets.Button( + description='Step-by-Step', + button_style='info', + tooltip='Description', + ) + self.metaphor = widgets.Button( + description='Metaphor', + button_style='info', + tooltip='Description', + ) + self.hints = widgets.Button( + description='Hints', + button_style='info', + tooltip='Description', + ) + self.guided_questions = widgets.Button( + description='AI Guided Questions', + button_style='info', + tooltip='Description', + ) + self.suggestion_buttons.children = (self.step_by_step, self.metaphor, self.hints, self.guided_questions) + self.children = (self.chat, self.suggestion_buttons, self.user_input_and_submit) diff --git a/nbs/chatbot.ipynb b/nbs/chatbot.ipynb new file mode 100644 index 0000000..9c6a05a --- /dev/null +++ b/nbs/chatbot.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "8e116d25-0170-4b10-ba20-9524e85ea507", + "metadata": {}, + "outputs": [], + "source": [ + "#| default_exp chatbot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a5b60d64-4066-4398-b6b2-bcc0431a565d", + "metadata": {}, + "outputs": [], + "source": [ + "#| export\n", + "import ipywidgets as widgets\n", + "from ipywidgets import Textarea, Text, Layout, HBox" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "db5c215f-b20b-4df4-9f5f-ad1bfdb9c64b", + "metadata": {}, + "outputs": [], + "source": [ + "#| export\n", + "\n", + "class ChatBot(widgets.VBox):\n", + " \n", + " def __init__(self):\n", + " # If you forget to call the superconstructor on an extended widget\n", + " # you will get an AttributeError: object has no attribute '_model_id'\n", + " super().__init__()\n", + "\n", + " example_convo = '''\n", + "User: Hello, bot!\n", + "\n", + "Bot: Hi there! How can I assist you today?\n", + "\n", + "User: I need help setting up my email account. Can you guide me through the process?\n", + "\n", + "Bot: Of course! Could you please provide me with the email service provider you're using?\n", + "\n", + "User: I use Gmail.\n", + "\n", + "Bot: Great! First, go to the Gmail website and click on the \"Create account\" button.\n", + "\n", + "User: Okay, I'm there. What's next?\n", + "\n", + "Bot: Enter your personal information such as your name, desired email address, password, and recovery information.\n", + "\n", + "User: Done! What's next?\n", + "\n", + "Bot: Follow the prompts to verify your phone number and agree to the terms of service.\n", + "\n", + "User: All set! Thank you for your help, bot!\n", + "\n", + "Bot: You're welcome! If you have any more questions, feel free to ask.\n", + "'''\n", + " self.chat = Textarea(\n", + " disabled = True,\n", + " value = example_convo,\n", + " layout=Layout(width='90%', height='400px')\n", + " )\n", + " self.user_input_and_submit = HBox()\n", + " self.user_input = widgets.Text(\n", + " placeholder='Message AI chatbot...',\n", + " #layout=Layout(width='100%')\n", + " )\n", + " self.submit = widgets.ToggleButton(\n", + " value=False,\n", + " disabled=False,\n", + " button_style='success',\n", + " icon='arrow-circle-right' \n", + " )\n", + " self.user_input_and_submit.children = (self.user_input, self.submit)\n", + "\n", + " self.suggestion_buttons = HBox()\n", + " self.step_by_step = widgets.Button(\n", + " description='Step-by-Step',\n", + " button_style='info',\n", + " tooltip='Description',\n", + " )\n", + " self.metaphor = widgets.Button(\n", + " description='Metaphor',\n", + " button_style='info',\n", + " tooltip='Description',\n", + " )\n", + " self.hints = widgets.Button(\n", + " description='Hints',\n", + " button_style='info',\n", + " tooltip='Description',\n", + " )\n", + " self.guided_questions = widgets.Button(\n", + " description='AI Guided Questions',\n", + " button_style='info',\n", + " tooltip='Description', \n", + " )\n", + " self.suggestion_buttons.children = (self.step_by_step, self.metaphor, self.hints, self.guided_questions)\n", + " self.children = (self.chat, self.suggestion_buttons, self.user_input_and_submit) " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4403118f-7766-43b2-bea5-7ebaa8021806", + "metadata": {}, + "outputs": [], + "source": [ + "chatbot = ChatBot()\n", + "chatbot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "acf72e11-5e48-40cf-a1fc-89f2f201aaac", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "python3", + "language": "python", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/nbs/fourthTab.ipynb b/nbs/fourthTab.ipynb deleted file mode 100644 index 8a7319c..0000000 --- a/nbs/fourthTab.ipynb +++ /dev/null @@ -1,111 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 6, - "id": "8e116d25-0170-4b10-ba20-9524e85ea507", - "metadata": {}, - "outputs": [], - "source": [ - "#| default_exp fourthTab" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "a5b60d64-4066-4398-b6b2-bcc0431a565d", - "metadata": {}, - "outputs": [], - "source": [ - "#| export\n", - "import ipywidgets as widgets\n", - "from ipywidgets import Tab, Output, Button\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "db5c215f-b20b-4df4-9f5f-ad1bfdb9c64b", - "metadata": {}, - "outputs": [], - "source": [ - "#| export\n", - "\n", - "class FourthTab(widgets.VBox):\n", - " \n", - " def __init__(self):\n", - " # If you forget to call the superconstructor on an extended widget\n", - " # you will get an AttributeError: object has no attribute '_model_id'\n", - " super().__init__()\n", - " \n", - " # Using Accordion\n", - " # Create accordion containing HTML content\n", - " self.using_acc = widgets.Accordion()\n", - " # self.using_acc.set_title(0, 'Using this App')\n", - " USING_TEXT = '''\n", - " In the Data tab above, you can review the dataset.\n", - " In the Selection tab, you can search for and download data of interest.\n", - " Once you've selected data, generate plots in the Visualize tab.\n", - " '''\n", - " self.using_body = widgets.HTML(USING_TEXT)\n", - " self.using_acc.children = (self.using_body, )\n", - " \n", - " # Data Souces Accordion\n", - " # Create accordion containing HTML content\n", - " self.sources_acc = widgets.Accordion()\n", - " # self.sources_acc.set_title(0, 'Data Sources')\n", - " SOURCES_TEXT = '''\n", - " Land-Ocean Temperature Index\n", - " Global Temperature (NASA)\n", - " ,\n", - " GISS Surface Temperature Analysis (NASA)\n", - " \n", - " This site is based on data downloaded from the following site on 2020-07-14:\n", - " Global Mean Estimates based on Land_and Ocean Data (NASA)\n", - " '''\n", - " self.sources_body = widgets.HTML(SOURCES_TEXT)\n", - " self.sources_acc.children = (self.sources_body, )" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "778079f5-b1fd-4b58-91b1-4a7185a1d2c5", - "metadata": {}, - "outputs": [], - "source": [ - "from nbdev.export import nb_export\n", - "nb_export('fourthTab.ipynb', 'nbdevFolder')\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "acf72e11-5e48-40cf-a1fc-89f2f201aaac", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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.8.19" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}