Spaces:
Build error
Build error
Commit
·
164bf10
1
Parent(s):
fda45a4
Update app.py
Browse files
app.py
CHANGED
@@ -24,9 +24,10 @@ def save_chatbot_dialogue(chat_tutor, save_type):
|
|
24 |
|
25 |
save_json = partial(save_chatbot_dialogue, save_type='json')
|
26 |
save_txt = partial(save_chatbot_dialogue, save_type='txt')
|
27 |
-
save_csv = partial(save_chatbot_dialogue, save_type='csv')
|
28 |
|
29 |
|
|
|
|
|
30 |
|
31 |
class BasicTutor:
|
32 |
# create basic initialization function
|
@@ -49,14 +50,12 @@ class BasicTutor:
|
|
49 |
self.conversation_memory = []
|
50 |
self.flattened_conversation = ''
|
51 |
|
52 |
-
# history is a list of list
|
53 |
-
# [[user_input_str, bot_response_str], ...]
|
54 |
|
55 |
### Chatbot Functions ###
|
56 |
def add_user_message(user_message, chat_tutor):
|
57 |
"""Display user message and update chat history to include it."""
|
58 |
chat_tutor.add_user_message(user_message)
|
59 |
-
return
|
60 |
|
61 |
def get_tutor_reply(user_message, chat_tutor):
|
62 |
chat_tutor.get_tutor_reply(user_message)
|
@@ -79,13 +78,11 @@ with gr.Blocks() as demo:
|
|
79 |
with gr.Row():
|
80 |
user_chat_input = gr.Textbox(label="User input", scale=9)
|
81 |
user_chat_submit = gr.Button("Ask/answer model", scale=1)
|
82 |
-
with gr.Column():
|
83 |
-
clear = gr.Button("Clear")
|
84 |
|
85 |
-
user_chat_submit.click(add_user_message,
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
with gr.Blocks():
|
91 |
gr.Markdown("""
|
|
|
24 |
|
25 |
save_json = partial(save_chatbot_dialogue, save_type='json')
|
26 |
save_txt = partial(save_chatbot_dialogue, save_type='txt')
|
|
|
27 |
|
28 |
|
29 |
+
# history is a list of list
|
30 |
+
# [[user_input_str, bot_response_str], ...]
|
31 |
|
32 |
class BasicTutor:
|
33 |
# create basic initialization function
|
|
|
50 |
self.conversation_memory = []
|
51 |
self.flattened_conversation = ''
|
52 |
|
|
|
|
|
53 |
|
54 |
### Chatbot Functions ###
|
55 |
def add_user_message(user_message, chat_tutor):
|
56 |
"""Display user message and update chat history to include it."""
|
57 |
chat_tutor.add_user_message(user_message)
|
58 |
+
return chat_tutor.conversation_memory, chat_tutor
|
59 |
|
60 |
def get_tutor_reply(user_message, chat_tutor):
|
61 |
chat_tutor.get_tutor_reply(user_message)
|
|
|
78 |
with gr.Row():
|
79 |
user_chat_input = gr.Textbox(label="User input", scale=9)
|
80 |
user_chat_submit = gr.Button("Ask/answer model", scale=1)
|
|
|
|
|
81 |
|
82 |
+
user_chat_submit.click(add_user_message,
|
83 |
+
[user_chat_input, study_tutor],
|
84 |
+
[chatbot, study_tutor], queue=False).then(
|
85 |
+
get_tutor_reply, [user_chat_input, study_tutor], [user_chat_input, chatbot, study_tutor], queue=True)
|
86 |
|
87 |
with gr.Blocks():
|
88 |
gr.Markdown("""
|