File size: 1,651 Bytes
80ffae0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)