Spaces:
Runtime error
Runtime error
Jithin James
commited on
Commit
·
61bed76
1
Parent(s):
c757ce4
renamed to app.py
Browse files- chatbot-demo.py → app.py +10 -12
chatbot-demo.py → app.py
RENAMED
@@ -12,12 +12,9 @@ def get_model_response(chat_txt, user_chats, full_chat_history):
|
|
12 |
return responses, full_chat_history, user_chats
|
13 |
|
14 |
|
15 |
-
def clear_chat():
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
def clear_dropdown():
|
20 |
-
return gr.update(choices=[], value="")
|
21 |
|
22 |
|
23 |
def add_to_dropdown(txt, drop_down_options):
|
@@ -26,12 +23,12 @@ def add_to_dropdown(txt, drop_down_options):
|
|
26 |
|
27 |
|
28 |
drop_down = gr.Dropdown(
|
29 |
-
label="Clear Till", choices=[], interactive=True, multiselect=False
|
30 |
)
|
31 |
with gr.Blocks() as demo:
|
32 |
user_chats = gr.State(value=[])
|
33 |
full_chat_history = gr.State(value=[])
|
34 |
-
|
35 |
|
36 |
chatbox = gr.Chatbot()
|
37 |
with gr.Row():
|
@@ -47,22 +44,23 @@ with gr.Blocks() as demo:
|
|
47 |
user_chat_txt.submit(lambda: gr.update(value=""), [], user_chat_txt)
|
48 |
user_chat_txt.submit(
|
49 |
add_to_dropdown,
|
50 |
-
inputs=[user_chat_txt,
|
51 |
-
outputs=[drop_down,
|
52 |
)
|
53 |
with gr.Column(scale=1, min_width=250):
|
54 |
drop_down.render()
|
55 |
clear_btn = gr.Button("Clear", label="Clear chat history")
|
56 |
clear_btn.click(
|
57 |
clear_chat,
|
|
|
58 |
outputs=[
|
59 |
full_chat_history,
|
60 |
chatbox,
|
61 |
user_chats,
|
62 |
-
|
|
|
63 |
],
|
64 |
)
|
65 |
-
clear_btn.click(clear_dropdown, outputs=drop_down)
|
66 |
|
67 |
with gr.Accordion(label="Red-Teaming", open=True):
|
68 |
gr.Markdown("*instructions on what to do if you break the model*")
|
|
|
12 |
return responses, full_chat_history, user_chats
|
13 |
|
14 |
|
15 |
+
def clear_chat(index: int):
|
16 |
+
print(index)
|
17 |
+
return [], [], [], [], gr.update(choices=[], value="")
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
def add_to_dropdown(txt, drop_down_options):
|
|
|
23 |
|
24 |
|
25 |
drop_down = gr.Dropdown(
|
26 |
+
label="Clear Till", choices=[], interactive=True, multiselect=False, type="index"
|
27 |
)
|
28 |
with gr.Blocks() as demo:
|
29 |
user_chats = gr.State(value=[])
|
30 |
full_chat_history = gr.State(value=[])
|
31 |
+
cleartill_dropdown_choices = gr.State(value=[])
|
32 |
|
33 |
chatbox = gr.Chatbot()
|
34 |
with gr.Row():
|
|
|
44 |
user_chat_txt.submit(lambda: gr.update(value=""), [], user_chat_txt)
|
45 |
user_chat_txt.submit(
|
46 |
add_to_dropdown,
|
47 |
+
inputs=[user_chat_txt, cleartill_dropdown_choices],
|
48 |
+
outputs=[drop_down, cleartill_dropdown_choices],
|
49 |
)
|
50 |
with gr.Column(scale=1, min_width=250):
|
51 |
drop_down.render()
|
52 |
clear_btn = gr.Button("Clear", label="Clear chat history")
|
53 |
clear_btn.click(
|
54 |
clear_chat,
|
55 |
+
inputs=[drop_down],
|
56 |
outputs=[
|
57 |
full_chat_history,
|
58 |
chatbox,
|
59 |
user_chats,
|
60 |
+
cleartill_dropdown_choices,
|
61 |
+
drop_down,
|
62 |
],
|
63 |
)
|
|
|
64 |
|
65 |
with gr.Accordion(label="Red-Teaming", open=True):
|
66 |
gr.Markdown("*instructions on what to do if you break the model*")
|