NCTCMumbai commited on
Commit
0aeac8d
·
verified ·
1 Parent(s): 7a4c273

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -229,16 +229,37 @@ with gr.Blocks(theme='NoCrypt/miku') as CHATBOT:
229
 
230
  prompt_html = gr.HTML()
231
  translated_textbox = gr.Textbox(label="Translated Response")
232
-
233
- txt_msg = txt_btn.click(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
234
- bot, [chatbot, cross_encoder], [chatbot, prompt_html]).then(
 
 
 
 
 
 
235
  translate_text, [txt, language_dropdown], translated_textbox
236
  )
237
-
238
- txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
239
- bot, [chatbot, cross_encoder], [chatbot, prompt_html]).then(
 
 
 
 
 
 
240
  translate_text, [txt, language_dropdown], translated_textbox
241
  )
 
 
 
 
 
 
 
 
 
242
 
243
  # Launch the Gradio application
244
  CHATBOT.launch(share=True)
 
229
 
230
  prompt_html = gr.HTML()
231
  translated_textbox = gr.Textbox(label="Translated Response")
232
+
233
+ # Click event handler for submit button
234
+ txt_btn.click(
235
+ add_text, [chatbot, txt], [chatbot, txt], queue=False
236
+ ).then(
237
+ bot, [chatbot, cross_encoder], [chatbot, prompt_html]
238
+ ).then(
239
+ lambda history: history[-1][1], [chatbot], translated_textbox # Extract chatbot output
240
+ ).then(
241
  translate_text, [txt, language_dropdown], translated_textbox
242
  )
243
+
244
+ # Submit event handler for pressing Enter key
245
+ txt.submit(
246
+ add_text, [chatbot, txt], [chatbot, txt], queue=False
247
+ ).then(
248
+ bot, [chatbot, cross_encoder], [chatbot, prompt_html]
249
+ ).then(
250
+ lambda history: history[-1][1], [chatbot], translated_textbox # Extract chatbot output
251
+ ).then(
252
  translate_text, [txt, language_dropdown], translated_textbox
253
  )
254
+ # txt_msg = txt_btn.click(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
255
+ # bot, [chatbot, cross_encoder], [chatbot, prompt_html]).then(
256
+ # translate_text, [txt, language_dropdown], translated_textbox
257
+ # )
258
+
259
+ # txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
260
+ # bot, [chatbot, cross_encoder], [chatbot, prompt_html]).then(
261
+ # translate_text, [txt, language_dropdown], translated_textbox
262
+ # )
263
 
264
  # Launch the Gradio application
265
  CHATBOT.launch(share=True)