Update app.py
Browse files
app.py
CHANGED
|
@@ -20,9 +20,10 @@ with gr.Blocks() as demo:
|
|
| 20 |
# First Column with 20% width
|
| 21 |
with gr.Column(scale=1):
|
| 22 |
save_button = gr.Button("Save & Start new Chat")
|
| 23 |
-
display_chat_names = gr.Textbox(label="Chat histories",placeholder="Chat names not found", readonly=True, lines=
|
| 24 |
enter_chat_name = gr.Textbox(label="just enter the number to load chat",placeholder="1")
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
# Second Column with 80% width
|
|
@@ -49,14 +50,15 @@ with gr.Blocks() as demo:
|
|
| 49 |
|
| 50 |
def load_chat(entered_chat_name):
|
| 51 |
# Fetch the specific chat history based on provided name
|
| 52 |
-
chat_name = entered_chat_name
|
|
|
|
| 53 |
chat_name = "chat history "+chat_name
|
| 54 |
if chat_name in chat_histories:
|
| 55 |
return "", chat_histories[chat_name]
|
| 56 |
else:
|
| 57 |
return "Chat not found!", []
|
| 58 |
|
| 59 |
-
|
| 60 |
enter_chat_name.change(load_chat, [enter_chat_name], outputs=[msg,chatbot])
|
| 61 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 62 |
save_button.click(save_chat, [chatbot], outputs=[display_chat_names,chatbot,audio_input2]) # Added display_chat_names as an output
|
|
|
|
| 20 |
# First Column with 20% width
|
| 21 |
with gr.Column(scale=1):
|
| 22 |
save_button = gr.Button("Save & Start new Chat")
|
| 23 |
+
display_chat_names = gr.Textbox(label="Chat histories",placeholder="Chat names not found", readonly=True, lines=16)
|
| 24 |
enter_chat_name = gr.Textbox(label="just enter the number to load chat",placeholder="1")
|
| 25 |
+
dropdown = gr.Dropdown(["1","2","3","4"])
|
| 26 |
+
load_button = gr.Button("Load Chat",visible=False)
|
| 27 |
|
| 28 |
|
| 29 |
# Second Column with 80% width
|
|
|
|
| 50 |
|
| 51 |
def load_chat(entered_chat_name):
|
| 52 |
# Fetch the specific chat history based on provided name
|
| 53 |
+
chat_name = entered_chat_name
|
| 54 |
+
print(chat_name)# Remove any trailing or leading spaces
|
| 55 |
chat_name = "chat history "+chat_name
|
| 56 |
if chat_name in chat_histories:
|
| 57 |
return "", chat_histories[chat_name]
|
| 58 |
else:
|
| 59 |
return "Chat not found!", []
|
| 60 |
|
| 61 |
+
dropdown.select(load_chat, [dropdown], outputs=[msg,chatbot])
|
| 62 |
enter_chat_name.change(load_chat, [enter_chat_name], outputs=[msg,chatbot])
|
| 63 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 64 |
save_button.click(save_chat, [chatbot], outputs=[display_chat_names,chatbot,audio_input2]) # Added display_chat_names as an output
|