Spaces:
Sleeping
Sleeping
import streamlit as st | |
import requests | |
# Define the healthcare knowledge base or fetch from APIs | |
health_knowledge_base = { | |
"flu": { | |
"symptoms": ["fever", "cough", "sore throat", "body aches", "fatigue"], | |
"treatment": "Rest, fluids, pain relievers, and anti-viral medications if prescribed.", | |
}, | |
"headache": { | |
"symptoms": ["head pain", "nausea", "sensitivity to light"], | |
"treatment": "Rest, hydration, over-the-counter painkillers, and avoid triggers.", | |
}, | |
"diabetes": { | |
"symptoms": ["increased thirst", "frequent urination", "fatigue", "blurred vision"], | |
"treatment": "Insulin therapy, lifestyle changes, and dietary management.", | |
}, | |
} | |
# Function to search for health information in the knowledge base | |
def get_health_info(query): | |
query = query.lower() | |
# Search for conditions that match the query | |
for condition, info in health_knowledge_base.items(): | |
if condition in query: | |
return f"Condition: {condition.title()}\n" \ | |
f"Symptoms: {', '.join(info['symptoms'])}\n" \ | |
f"Treatment: {info['treatment']}" | |
return "Sorry, I couldn't find information on that condition. Please try another query." | |
# Set up the Streamlit app interface | |
st.title("Healthcare Knowledge Chatbot") | |
st.write("Ask me about health conditions, symptoms, treatments, and I'll provide relevant information.") | |
# Input field for user queries | |
user_input = st.text_input("Ask a healthcare-related question...") | |
# Display response based on user input | |
if user_input: | |
response = get_health_info(user_input) | |
st.write(response) | |