brunhild217 commited on
Commit
b90e510
·
1 Parent(s): 37f3329

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -9
app.py CHANGED
@@ -4,7 +4,7 @@ import pandas as pd
4
  from functools import partial
5
  from ai_classroom_suite.UIBaseComponents import *
6
 
7
- # TODO:
8
  class EchoingTutor(SlightlyDelusionalTutor):
9
  def add_user_message(self, user_message):
10
  self.conversation_memory.append([user_message, None])
@@ -23,13 +23,16 @@ class EchoingTutor(SlightlyDelusionalTutor):
23
 
24
  ### Chatbot Functions ###
25
  def add_user_message(user_message, chat_tutor):
26
- """Display user message and update chat history to include it."""
27
  chat_tutor.add_user_message(user_message)
28
  return chat_tutor.conversation_memory, chat_tutor
29
-
30
  def get_tutor_reply(user_message, chat_tutor):
31
  chat_tutor.get_tutor_reply(user_message)
32
  return gr.update(value="", interactive=True), chat_tutor.conversation_memory, chat_tutor
 
 
 
 
33
 
34
  def get_conversation_history(chat_tutor):
35
  return chat_tutor.conversation_memory, chat_tutor
@@ -78,7 +81,7 @@ def embed_prompt(instructor_prompt):
78
  with gr.Blocks() as demo:
79
 
80
  #initialize tutor (with state)
81
- study_tutor = gr.State(EchoingTutor())
82
 
83
  # Student interface
84
  with gr.Tab("For Students"):
@@ -95,11 +98,18 @@ with gr.Blocks() as demo:
95
  with gr.Row():
96
  user_chat_input = gr.Textbox(label="User input", scale=9)
97
  user_chat_submit = gr.Button("Ask/answer model", scale=1)
98
-
99
- user_chat_submit.click(add_user_message,
100
- [user_chat_input, study_tutor],
101
- [chatbot, study_tutor], queue=False).then(
102
- get_tutor_reply, [user_chat_input, study_tutor], [user_chat_input, chatbot, study_tutor], queue=True)
 
 
 
 
 
 
 
103
 
104
  # Testing purpose
105
  test_btn = gr.Button("View your chat history")
 
4
  from functools import partial
5
  from ai_classroom_suite.UIBaseComponents import *
6
 
7
+ # Testing purpose
8
  class EchoingTutor(SlightlyDelusionalTutor):
9
  def add_user_message(self, user_message):
10
  self.conversation_memory.append([user_message, None])
 
23
 
24
  ### Chatbot Functions ###
25
  def add_user_message(user_message, chat_tutor):
 
26
  chat_tutor.add_user_message(user_message)
27
  return chat_tutor.conversation_memory, chat_tutor
28
+ """
29
  def get_tutor_reply(user_message, chat_tutor):
30
  chat_tutor.get_tutor_reply(user_message)
31
  return gr.update(value="", interactive=True), chat_tutor.conversation_memory, chat_tutor
32
+ """
33
+ def get_tutor_reply(chat_tutor):
34
+ chat_tutor.get_tutor_reply(input_kwargs={'question':''})
35
+ return gr.update(value="", interactive=True), chat_tutor.conversation_memory, chat_tutor
36
 
37
  def get_conversation_history(chat_tutor):
38
  return chat_tutor.conversation_memory, chat_tutor
 
81
  with gr.Blocks() as demo:
82
 
83
  #initialize tutor (with state)
84
+ study_tutor = gr.State(SlightlyDelusionalTutor())
85
 
86
  # Student interface
87
  with gr.Tab("For Students"):
 
98
  with gr.Row():
99
  user_chat_input = gr.Textbox(label="User input", scale=9)
100
  user_chat_submit = gr.Button("Ask/answer model", scale=1)
101
+
102
+ user_chat_submit.click(
103
+ add_user_message,
104
+ [user_chat_input, study_tutor],
105
+ [chatbot, study_tutor],
106
+ queue=False
107
+ ).then(
108
+ get_tutor_reply,
109
+ [study_tutor],
110
+ [user_chat_input, chatbot, study_tutor],
111
+ queue=True)
112
+
113
 
114
  # Testing purpose
115
  test_btn = gr.Button("View your chat history")