Skip to content

Commit

Permalink
Final draft for submission
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-brewer committed Apr 6, 2024
1 parent 37988cb commit c50b53b
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 173 deletions.
6 changes: 5 additions & 1 deletion jupyter_mentor/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@
'jupyter_mentor/madlib.py'),
'jupyter_mentor.madlib.MadLibView.observe_value_change': ( 'madlib.html#madlibview.observe_value_change',
'jupyter_mentor/madlib.py')},
'jupyter_mentor.student_course_overview': { 'jupyter_mentor.student_course_overview.StudentCourseOverview': ( 'student_course_overview.html#studentcourseoverview',
'jupyter_mentor.student_course_overview': { 'jupyter_mentor.student_course_overview.FileDownloader': ( 'student_course_overview.html#filedownloader',
'jupyter_mentor/student_course_overview.py'),
'jupyter_mentor.student_course_overview.FileDownloader.__init__': ( 'student_course_overview.html#filedownloader.__init__',
'jupyter_mentor/student_course_overview.py'),
'jupyter_mentor.student_course_overview.StudentCourseOverview': ( 'student_course_overview.html#studentcourseoverview',
'jupyter_mentor/student_course_overview.py'),
'jupyter_mentor.student_course_overview.StudentCourseOverview.__init__': ( 'student_course_overview.html#studentcourseoverview.__init__',
'jupyter_mentor/student_course_overview.py')},
Expand Down
11 changes: 6 additions & 5 deletions jupyter_mentor/chatbot_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ def prompt(self):
kwargs = {key:value for key, value in zip(keys,values)}
prompt = chat_prompt.format_prompt( **kwargs )
bot = self.llm.invoke(prompt).content
user = "\n".join([desc + ' ' + val for desc, val in zip(self.madlib_models[self.selected_index].descriptions, self.madlib_models[self.selected_index].values)])
interm= [desc + ' ' + val for desc, val in zip(self.madlib_models[self.selected_index].descriptions, self.madlib_models[self.selected_index].values)]
user = "\n".join(interm)
return (user, bot)

def prompt_with_kwargs(self, kwargs):
ret = self.llm.invoke(self.chat_prompt.format_prompt(**kwargs))
return ret.content

# %% ../nbs/06_chatbot.ipynb 8
# %% ../nbs/06_chatbot.ipynb 9
class ChatBotView(widgets.VBox):
""" This view also exists in 04_chatbot, but wea
are overwriting it here
Expand Down Expand Up @@ -94,7 +95,7 @@ def __init__(self):
self.hbox.children = (self.stack, self.submit_button)
self.children = (self.chat, self.radio_buttons, self.hbox )

# %% ../nbs/06_chatbot.ipynb 10
# %% ../nbs/06_chatbot.ipynb 11
class ChatBot(ChatBotView):
""" This view also exists in 04_chatbot, but wea
are overwriting it here
Expand Down Expand Up @@ -122,9 +123,9 @@ def __init__(self, model):
self.submit_button.on_click(self.on_click)

def on_click(self, change):
for child in self.stack.children[self.selected_index].children:
child.value = ''
user, bot = self.model.prompt()
self.chat.value = "USER: " + user + '\n\n' + "CHATBOT: " + bot + '\n\n'
self.selected_index = 0
for child in self.stack.children[self.selected_index].children:
child.value = ''

5 changes: 3 additions & 2 deletions jupyter_mentor/educator_course_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
__all__ = ['EducatorCourseOverview']

# %% ../nbs/04_educator_course_overview.ipynb 1
from .llm import FileModel
from .file_viewer import FileViewer
import ipywidgets as widgets
from ipywidgets import VBox, HBox, HTML, Button, Label, Text, Textarea, Checkbox, Accordion, FileUpload
from IPython.display import display, clear_output
import ipyvuetify as v
from traitlets import observe

# %% ../nbs/04_educator_course_overview.ipynb 2
# %% ../nbs/04_educator_course_overview.ipynb 3
class EducatorCourseOverview(VBox):

def __init__(self, file_viewer):
def __init__(self):
super().__init__()

# File Upload button
Expand Down
1 change: 1 addition & 0 deletions jupyter_mentor/student_course_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self):
children=["Download All"]
)
self.children = [self.file_chooser, self.download_button]


# %% ../nbs/14_student_course_overview.ipynb 3
class StudentCourseOverview(VBox):
Expand Down
148 changes: 69 additions & 79 deletions nbs/00_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "89293f18-ab92-426e-abf4-249f3e17727d",
"metadata": {},
"outputs": [],
Expand All @@ -32,13 +32,13 @@
"from jupyter_mentor.student_profile import StudentProfile\n",
"from jupyter_mentor.educator_course_overview import EducatorCourseOverview\n",
"from jupyter_mentor.student_course_overview import StudentCourseOverview\n",
"from jupyter_mentor.chatbot_tab import ChatBot, ChatBotModel, StudentChatBot, EducatorChatBot\n",
"from jupyter_mentor.chatbot_tab import ChatBot, ChatBotModel\n",
"from jupyter_mentor.file_viewer import FileViewerView"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "af80f333-81cd-4f2d-8f92-195b79a8e307",
"metadata": {},
"outputs": [],
Expand All @@ -55,35 +55,71 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "d25ddd77-b1e3-41e6-9254-686a04ee7633",
"metadata": {},
"outputs": [],
"source": [
"madlibs_list = [\n",
" {'name': 'Open Prompt',\n",
" 'description': '',\n",
" 'variables': {\n",
" 'input_text': 'value'\n",
" }, \n",
" 'template': '{input_text}' ,\n",
" 'placeholder': 'Message AI chatbot...',\n",
" },\n",
" {\n",
" 'name': 'Metaphor',\n",
" 'variables': {\n",
" 'concept': 'value'\n",
" }, \n",
" 'template': \"I'm having trouble understanding {concept}. Explain it as a metaphor\",\n",
" 'description': \"I'm having trouble understanding...\", \n",
" 'placeholder': 'why the sky is blue'\n",
"student_madlibs = [\n",
" { 'name': 'Open Prompt',\n",
" 'template': '{input_text}',\n",
" 'variables': ['input_text'],\n",
" 'descriptions': [''],\n",
" 'placeholders': ['Message AI chatbot...']\n",
" }, {'name': 'Metaphor',\n",
" 'template': \"I'm having trouble understanding {concept}. Please explain it as a metaphor\",\n",
" 'variables': ['concept'],\n",
" 'descriptions': [\"I'm having trouble understanding\"],\n",
" 'placeholders': ['']\n",
" }, {'name': 'Step-by-Step',\n",
" 'template': \"I'm having trouble understanding {concept}. Please help me break it down into steps.\",\n",
" 'variables': ['concept'],\n",
" 'descriptions': [\"I'm having trouble understanding\"],\n",
" 'placeholders': ['']\n",
" }, {'name': 'Debate Partner',\n",
" 'template': \"I want to debate about {concept}. Let's use the Socratic method. You are subject matter expert who is trying to convince me about it. You will speak first and then wait for me to respond.\",\n",
" 'variables': ['concept'],\n",
" 'descriptions': [\"I want to debate about\"],\n",
" 'placeholders': ['']\n",
" }\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "19a93c82-481e-4e50-8e88-85f37b964d3d",
"metadata": {},
"outputs": [],
"source": [
"educator_madlibs = [\n",
" { 'name': 'Open Prompt',\n",
" 'template': '{input_text}',\n",
" 'variables': ['input_text'],\n",
" 'descriptions': [''],\n",
" 'placeholders': ['Message AI chatbot...']\n",
" }, {'name': 'Metaphor',\n",
" 'template': \"I'm having trouble understanding {concept}. Please explain it as a metaphor\",\n",
" 'variables': ['concept'],\n",
" 'descriptions': [\"I'm having trouble understanding\"],\n",
" 'placeholders': ['']\n",
" }, {'name': 'Translate',\n",
" 'template': \"Help me translate the following text into {language}: {text}\",\n",
" 'variables': ['language', 'text'],\n",
" 'descriptions': [\"Text\", \"Language\"],\n",
" 'placeholders': ['', '']\n",
" }, {'name': 'Quiz Questions',\n",
" 'template': \"Help me generate 10 quiz questions about {concept}.\",\n",
" 'variables': ['concept'],\n",
" 'descriptions': [\"Quiz Topic\"],\n",
" 'placeholders': ['']\n",
" }\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "ff4ce152-adef-4c60-828a-8bbf68129209",
"metadata": {},
"outputs": [],
Expand All @@ -96,14 +132,14 @@
" \n",
" # initialize models\n",
" # self.model = DataModel(FILENAME)\n",
" self.educator_chatbot_model = ChatBotModel(madlibs_list)\n",
" self.educator_chatbot_model = ChatBotModel(educator_madlibs)\n",
"\n",
" \n",
" # initialize views\n",
" self.first = Login()\n",
" self.second = EducatorProfileView()\n",
" self.file_viewer = FileViewerView()\n",
" self.third = EducatorCourseOverview(self.file_viewer)\n",
" self.third = EducatorCourseOverview()\n",
" self.fourth = ChatBot(self.educator_chatbot_model)\n",
" \n",
" # Add tabs to the Tab widget\n",
Expand All @@ -127,40 +163,23 @@
" self.selected_index = 2\n",
" \n",
" def switch_to_fourth(self, button):\n",
" self.selected_index = 3\n",
" "
" self.selected_index = 3"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "9ca28623-ed1f-4f1c-b671-462ee582040f",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "45777c8ce5e544ccb75ef60ea2d3f504",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EducatorMain(children=(Login(children=(Container(children=[Html(attributes={'title': 'a title'}, children=['Lo…"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"educator_main = EducatorMain()\n",
"educator_main"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "7548d87a-94e3-4cdc-bb20-fe46ec366425",
"metadata": {},
"outputs": [],
Expand All @@ -173,13 +192,12 @@
" \n",
" # initialize models\n",
" # self.model = EducatorModel(FILENAME)\n",
" self.student_chatbot_model = ChatBotModel(madlibs_list)\n",
" self.student_chatbot_model = ChatBotModel(student_madlibs)\n",
"\n",
" # initialize views\n",
" self.first = Login()\n",
" self.second = StudentProfile()\n",
" self.file_viewer = FileViewerView()\n",
" #self.third = StudentCourseOverview(self.file_viewer\n",
" self.third = StudentCourseOverview()\n",
" self.fourth = ChatBot(self.student_chatbot_model)\n",
"\n",
Expand All @@ -190,7 +208,7 @@
" self.set_title(0, 'LogIn')\n",
" self.set_title(1, 'User Profile')\n",
" self.set_title(2, 'Course Overview')\n",
" self.set_title(3, 'Student Chatbox')\n",
" self.set_title(3, 'Test/Assn Generator')\n",
"\n",
"\n",
" # Add event handlers to \"Next\" buttons in each tab\n",
Expand All @@ -210,26 +228,10 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "36cabf8d-427b-4d24-9c5d-8a6f8e4ab6b5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5ba5c5efdcdb42fa8efc2fcc9c77d2b5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"StudentMain(children=(Login(children=(Container(children=[Html(attributes={'title': 'a title'}, children=['Log…"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"student_main = StudentMain()\n",
"student_main"
Expand Down Expand Up @@ -257,21 +259,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "python3",
"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,
Expand Down
Loading

0 comments on commit c50b53b

Please sign in to comment.