Spaces:
Build error
Build error
Commit
·
b41394d
1
Parent(s):
c89adbc
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,7 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
from functools import partial
|
5 |
-
|
6 |
-
def save_chatbot_dialogue(chat_tutor, save_type):
|
7 |
-
|
8 |
-
formatted_convo = pd.DataFrame(chat_tutor.conversation_memory, columns=['user', 'chatbot'])
|
9 |
-
|
10 |
-
output_fname = f'tutoring_conversation.{save_type}'
|
11 |
-
|
12 |
-
if save_type == 'csv':
|
13 |
-
formatted_convo.to_csv(output_fname, index=False)
|
14 |
-
elif save_type == 'json':
|
15 |
-
formatted_convo.to_json(output_fname, orient='records')
|
16 |
-
elif save_type == 'txt':
|
17 |
-
temp = formatted_convo.apply(lambda x: 'User: {0}\nAI: {1}'.format(x[0], x[1]), axis=1)
|
18 |
-
temp = '\n\n'.join(temp.tolist())
|
19 |
-
with open(output_fname, 'w') as f:
|
20 |
-
f.write(temp)
|
21 |
-
else:
|
22 |
-
gr.update(value=None, visible=False)
|
23 |
-
|
24 |
-
return gr.update(value=output_fname, visible=True)
|
25 |
-
|
26 |
-
save_json = partial(save_chatbot_dialogue, save_type='json')
|
27 |
-
save_txt = partial(save_chatbot_dialogue, save_type='txt')
|
28 |
-
save_csv = partial(save_chatbot_dialogue, save_type='csv')
|
29 |
-
|
30 |
|
31 |
# history is a list of list
|
32 |
# [[user_input_str, bot_response_str], ...]
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from functools import partial
|
4 |
+
from ai_classroom_suite.UIBaseComponents import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# history is a list of list
|
7 |
# [[user_input_str, bot_response_str], ...]
|