Jayashree Sridhar
commited on
Commit
·
401c0a0
1
Parent(s):
4e01161
modified gradio async func in app.py
Browse files
app.py
CHANGED
|
@@ -229,17 +229,23 @@ def create_interface():
|
|
| 229 |
inputs=[text_input, language]
|
| 230 |
)
|
| 231 |
|
| 232 |
-
# Event handlers
|
| 233 |
-
async def handle_submission(text, voice, lang, history):
|
| 234 |
-
|
| 235 |
|
| 236 |
-
# Connect events
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
for trigger in [text_input.submit, send_btn.click]:
|
| 238 |
trigger(
|
| 239 |
-
fn=
|
| 240 |
inputs=[text_input, voice_input, language, chatbot],
|
| 241 |
outputs=[chatbot, audio_output, text_input, voice_input]
|
| 242 |
-
|
| 243 |
|
| 244 |
clear_btn.click(
|
| 245 |
fn=app.clear_conversation,
|
|
|
|
| 229 |
inputs=[text_input, language]
|
| 230 |
)
|
| 231 |
|
| 232 |
+
# # Event handlers
|
| 233 |
+
# async def handle_submission(text, voice, lang, history):
|
| 234 |
+
# return await app.process_input(text, voice, lang, history)
|
| 235 |
|
| 236 |
+
# # Connect events
|
| 237 |
+
# for trigger in [text_input.submit, send_btn.click]:
|
| 238 |
+
# trigger(
|
| 239 |
+
# fn=lambda *args: asyncio.run(handle_submission(*args)),
|
| 240 |
+
# inputs=[text_input, voice_input, language, chatbot],
|
| 241 |
+
# outputs=[chatbot, audio_output, text_input, voice_input]
|
| 242 |
+
# )
|
| 243 |
for trigger in [text_input.submit, send_btn.click]:
|
| 244 |
trigger(
|
| 245 |
+
fn=app.process_input, # <-- Use async method directly!
|
| 246 |
inputs=[text_input, voice_input, language, chatbot],
|
| 247 |
outputs=[chatbot, audio_output, text_input, voice_input]
|
| 248 |
+
)
|
| 249 |
|
| 250 |
clear_btn.click(
|
| 251 |
fn=app.clear_conversation,
|