NCTCMumbai
commited on
Update app.py
Browse files
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 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
translate_text, [txt, language_dropdown], translated_textbox
|
236 |
)
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|