Spaces:
Runtime error
Runtime error
Jithin James commited on
Commit ·
78db084
1
Parent(s): c512664
clear till index
Browse files
app.py
CHANGED
|
@@ -12,9 +12,17 @@ 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 |
|
| 20 |
def add_to_dropdown(txt, drop_down_options):
|
|
@@ -23,7 +31,10 @@ def add_to_dropdown(txt, drop_down_options):
|
|
| 23 |
|
| 24 |
|
| 25 |
drop_down = gr.Dropdown(
|
| 26 |
-
label="Clear
|
|
|
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
with gr.Blocks() as demo:
|
| 29 |
user_chats = gr.State(value=[])
|
|
@@ -52,7 +63,13 @@ with gr.Blocks() as demo:
|
|
| 52 |
clear_btn = gr.Button("Clear", label="Clear chat history")
|
| 53 |
clear_btn.click(
|
| 54 |
clear_chat,
|
| 55 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
outputs=[
|
| 57 |
full_chat_history,
|
| 58 |
chatbox,
|
|
|
|
| 12 |
return responses, full_chat_history, user_chats
|
| 13 |
|
| 14 |
|
| 15 |
+
def clear_chat(
|
| 16 |
+
full_chat_history, chatbox, user_chats, cleartill_dropdown_choices, drop_down
|
| 17 |
+
):
|
| 18 |
+
index = user_chats.index(drop_down)
|
| 19 |
+
return (
|
| 20 |
+
full_chat_history[:index],
|
| 21 |
+
chatbox[:index],
|
| 22 |
+
user_chats[:index],
|
| 23 |
+
cleartill_dropdown_choices[:index],
|
| 24 |
+
gr.update(choices=cleartill_dropdown_choices[:index], value=""),
|
| 25 |
+
)
|
| 26 |
|
| 27 |
|
| 28 |
def add_to_dropdown(txt, drop_down_options):
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
drop_down = gr.Dropdown(
|
| 34 |
+
label="Clear From (including)",
|
| 35 |
+
choices=[],
|
| 36 |
+
interactive=True,
|
| 37 |
+
multiselect=False,
|
| 38 |
)
|
| 39 |
with gr.Blocks() as demo:
|
| 40 |
user_chats = gr.State(value=[])
|
|
|
|
| 63 |
clear_btn = gr.Button("Clear", label="Clear chat history")
|
| 64 |
clear_btn.click(
|
| 65 |
clear_chat,
|
| 66 |
+
inputs=[
|
| 67 |
+
full_chat_history,
|
| 68 |
+
chatbox,
|
| 69 |
+
user_chats,
|
| 70 |
+
cleartill_dropdown_choices,
|
| 71 |
+
drop_down,
|
| 72 |
+
],
|
| 73 |
outputs=[
|
| 74 |
full_chat_history,
|
| 75 |
chatbox,
|