Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -650,22 +650,33 @@ Available: {match.get('Available', 'N/A')}"""
|
|
650 |
# Gradio will run this interface
|
651 |
# The `chatbot` element will manage the chat history state automatically
|
652 |
with gr.Blocks() as demo:
|
|
|
653 |
gr.Markdown(f"# Business Q&A Assistant with {model_id}")
|
654 |
gr.Markdown("Ask questions about the business (details from Google Sheet) or general knowledge (via search).")
|
655 |
|
|
|
656 |
chatbot = gr.Chatbot(height=400) # height in pixels
|
|
|
|
|
657 |
msg = gr.Textbox(label="Your Question")
|
658 |
-
clear = gr.ClearButton([msg, chatbot])
|
659 |
|
660 |
-
# The
|
661 |
-
|
662 |
-
msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
663 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
|
665 |
# Launch the Gradio app
|
666 |
-
# share=True creates a public link (useful for testing, disable for private apps)
|
667 |
-
# enable_queue=True can help handle multiple users
|
668 |
if __name__ == "__main__":
|
669 |
print("Launching Gradio app...")
|
670 |
-
# Use server_name="0.0.0.0" and server_port=7860 for Hugging Face Spaces default
|
671 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
650 |
# Gradio will run this interface
|
651 |
# The `chatbot` element will manage the chat history state automatically
|
652 |
with gr.Blocks() as demo:
|
653 |
+
# Display the model ID in the title for clarity
|
654 |
gr.Markdown(f"# Business Q&A Assistant with {model_id}")
|
655 |
gr.Markdown("Ask questions about the business (details from Google Sheet) or general knowledge (via search).")
|
656 |
|
657 |
+
# The Chatbot component to display the conversation history
|
658 |
chatbot = gr.Chatbot(height=400) # height in pixels
|
659 |
+
|
660 |
+
# The Textbox component for user input
|
661 |
msg = gr.Textbox(label="Your Question")
|
|
|
662 |
|
663 |
+
# The Clear button to clear the input and chatbot history
|
664 |
+
clear = gr.ClearButton([msg, chatbot])
|
|
|
665 |
|
666 |
+
# The submit event: when the user presses Enter in the textbox or clicks the send button
|
667 |
+
# - fn: The Python function to call (our respond function)
|
668 |
+
# - inputs: A list of Gradio components whose values should be passed as arguments to the fn.
|
669 |
+
# [msg] passes the user's input from the textbox.
|
670 |
+
# [chatbot] passes the current state of the chatbot history.
|
671 |
+
# - outputs: A list of Gradio components that should be updated with the values returned by the fn.
|
672 |
+
# [msg] is updated with the first return value (intended to clear the textbox with "").
|
673 |
+
# [chatbot] is updated with the second return value (the updated chat history).
|
674 |
+
msg.submit(fn=respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
675 |
|
676 |
# Launch the Gradio app
|
677 |
+
# share=True creates a public link (useful for testing, disable for private apps) - Use with caution.
|
678 |
+
# enable_queue=True can help handle multiple users by queuing requests.
|
679 |
if __name__ == "__main__":
|
680 |
print("Launching Gradio app...")
|
681 |
+
# Use server_name="0.0.0.0" and server_port=7860 for Hugging Face Spaces default deployment
|
682 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|