Spaces:
Sleeping
Sleeping
| # app.py | |
| import gradio as gr | |
| from pipeline import chatbot_response, generate_coherent_response, ChatHistory | |
| # Create a new instance of chat history | |
| chat_history = ChatHistory() | |
| # Step 6: Define Gradio Interface for Chatbot | |
| def gradio_chatbot(user_query): | |
| # Step 7: Retrieve relevant data for the query | |
| retrieved_data = chatbot_response(user_query) | |
| # Step 8: Check and verify the query for health/wellness content | |
| is_valid = True | |
| if is_valid: | |
| # Generate a coherent response using Groq's DeepSeek-R1 LLM | |
| coherent_response = generate_coherent_response(user_query, retrieved_data, chat_history.get_history()) | |
| else: | |
| coherent_response = "The query does not seem to match health and wellness topics." | |
| # Add the user message and assistant response to the chat history | |
| chat_history.add_message("user", user_query) | |
| chat_history.add_message("assistant", coherent_response) | |
| # Return the response and the chat history | |
| return coherent_response, chat_history.get_history() | |
| # Create the Gradio interface | |
| iface = gr.Interface(fn=gradio_chatbot, | |
| inputs=gr.Textbox(label="Ask a question"), | |
| outputs=[gr.Textbox(label="Chatbot Response"), gr.Textbox(label="Chat History")], | |
| title="Wellness Chatbot") | |
| # Launch the Gradio interface | |
| iface.launch() | |