arpit13 commited on
Commit
fac9e90
·
verified ·
1 Parent(s): f063c08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
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(() => alert('Copied to clipboard!'))
122
- .catch(() => alert('Failed to copy!'));
 
 
 
 
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()