Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,6 +104,8 @@ with chat_interface:
|
|
| 104 |
chatbot_output = gr.Chatbot(label="Chat History", type="messages")
|
| 105 |
with gr.Row():
|
| 106 |
copy_button = gr.Button("Copy Response")
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# Add functionality to handle interactions
|
| 109 |
def handle_chat(user_input, category, history):
|
|
@@ -118,10 +120,14 @@ with chat_interface:
|
|
| 118 |
<script>
|
| 119 |
const copyText = '{last_bot_response}';
|
| 120 |
navigator.clipboard.writeText(copyText)
|
| 121 |
-
.then(() =>
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
</script>
|
| 124 |
-
""")
|
| 125 |
|
| 126 |
send_button.click(
|
| 127 |
handle_chat,
|
|
@@ -132,7 +138,7 @@ with chat_interface:
|
|
| 132 |
copy_button.click(
|
| 133 |
handle_copy,
|
| 134 |
inputs=[chatbot_output],
|
| 135 |
-
outputs=[]
|
| 136 |
)
|
| 137 |
|
| 138 |
chat_interface.launch()
|
|
|
|
| 104 |
chatbot_output = gr.Chatbot(label="Chat History", type="messages")
|
| 105 |
with gr.Row():
|
| 106 |
copy_button = gr.Button("Copy Response")
|
| 107 |
+
with gr.Row():
|
| 108 |
+
copy_message = gr.HTML("") # To display the confirmation message
|
| 109 |
|
| 110 |
# Add functionality to handle interactions
|
| 111 |
def handle_chat(user_input, category, history):
|
|
|
|
| 120 |
<script>
|
| 121 |
const copyText = '{last_bot_response}';
|
| 122 |
navigator.clipboard.writeText(copyText)
|
| 123 |
+
.then(() => {{
|
| 124 |
+
alert('Response copied to clipboard!');
|
| 125 |
+
}})
|
| 126 |
+
.catch(() => {{
|
| 127 |
+
alert('Failed to copy!');
|
| 128 |
+
}});
|
| 129 |
</script>
|
| 130 |
+
"""), "Response copied to clipboard!"
|
| 131 |
|
| 132 |
send_button.click(
|
| 133 |
handle_chat,
|
|
|
|
| 138 |
copy_button.click(
|
| 139 |
handle_copy,
|
| 140 |
inputs=[chatbot_output],
|
| 141 |
+
outputs=[copy_message] # Display the copy confirmation message
|
| 142 |
)
|
| 143 |
|
| 144 |
chat_interface.launch()
|