Spaces:
Sleeping
Sleeping
modified
Browse files
app.py
CHANGED
|
@@ -276,18 +276,18 @@ def customLLMBot(user_input, uploaded_image, chat_history):
|
|
| 276 |
tts.save(audio_file)
|
| 277 |
logger.info(f"Audio response saved as {audio_file}")
|
| 278 |
|
| 279 |
-
# Return
|
| 280 |
-
return [(entry[
|
| 281 |
|
| 282 |
except Exception as e:
|
| 283 |
# Handle errors gracefully
|
| 284 |
logger.error(f"Error in customLLMBot function: {e}")
|
| 285 |
-
return [("
|
| 286 |
|
| 287 |
|
| 288 |
# Gradio Interface
|
| 289 |
def chatbot_ui():
|
| 290 |
-
chat_history = [] # Initialize empty chat history
|
| 291 |
|
| 292 |
with gr.Blocks() as demo:
|
| 293 |
gr.Markdown("# Healthcare Chatbot Doctor")
|
|
@@ -328,16 +328,17 @@ def chatbot_ui():
|
|
| 328 |
outputs=[chatbot, audio_output, user_input],
|
| 329 |
)
|
| 330 |
|
| 331 |
-
# Action for clearing all fields
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
clear_btn.click(clear_chat, inputs=[], outputs=[chatbot, user_input, uploaded_image, audio_output])
|
| 338 |
|
| 339 |
return demo
|
| 340 |
|
| 341 |
|
| 342 |
# Launch the interface
|
| 343 |
-
chatbot_ui().launch(
|
|
|
|
|
|
|
|
|
| 276 |
tts.save(audio_file)
|
| 277 |
logger.info(f"Audio response saved as {audio_file}")
|
| 278 |
|
| 279 |
+
# Return chat history as a list of tuples (sender, message)
|
| 280 |
+
return [(entry[1], entry[0]) for entry in chat_history], audio_file
|
| 281 |
|
| 282 |
except Exception as e:
|
| 283 |
# Handle errors gracefully
|
| 284 |
logger.error(f"Error in customLLMBot function: {e}")
|
| 285 |
+
return [(user_input or "Image uploaded", f"An error occurred: {e}")], None
|
| 286 |
|
| 287 |
|
| 288 |
# Gradio Interface
|
| 289 |
def chatbot_ui():
|
| 290 |
+
chat_history = [] # Initialize empty chat history
|
| 291 |
|
| 292 |
with gr.Blocks() as demo:
|
| 293 |
gr.Markdown("# Healthcare Chatbot Doctor")
|
|
|
|
| 328 |
outputs=[chatbot, audio_output, user_input],
|
| 329 |
)
|
| 330 |
|
| 331 |
+
# Action for clearing all fields
|
| 332 |
+
clear_btn.click(
|
| 333 |
+
lambda: ([], "", None, None),
|
| 334 |
+
inputs=[],
|
| 335 |
+
outputs=[chatbot, user_input, uploaded_image, audio_output],
|
| 336 |
+
)
|
|
|
|
| 337 |
|
| 338 |
return demo
|
| 339 |
|
| 340 |
|
| 341 |
# Launch the interface
|
| 342 |
+
chatbot_ui().launch(server_name="0.0.0.0", server_port=7860)
|
| 343 |
+
|
| 344 |
+
#chatbot_ui().launch(server_name="localhost", server_port=7860)
|