Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,9 @@
|
|
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
2 |
|
3 |
# Disease and Treatment Information Data
|
4 |
diseases_info = {
|
@@ -22,14 +27,18 @@ diseases_info = {
|
|
22 |
"symptoms": ["shortness of breath", "wheezing", "chest tightness", "coughing"],
|
23 |
"treatment": "Inhalers, bronchodilators, corticosteroids, and avoiding triggers.",
|
24 |
},
|
25 |
-
"pneumonia": {
|
26 |
-
"symptoms": ["cough with mucus", "fever", "shortness of breath", "chest pain"],
|
27 |
-
"treatment": "Antibiotics for bacterial pneumonia, rest, fluids, and pain relievers.",
|
28 |
-
},
|
29 |
"hypertension": {
|
30 |
"symptoms": ["headaches", "dizziness", "shortness of breath", "nosebleeds"],
|
31 |
"treatment": "Medications like beta-blockers, ACE inhibitors, lifestyle changes including exercise and diet.",
|
32 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
"anxiety": {
|
34 |
"symptoms": ["excessive worry", "restlessness", "fatigue", "difficulty concentrating", "irritability"],
|
35 |
"treatment": "Cognitive-behavioral therapy (CBT), medications like SSRIs, relaxation techniques.",
|
@@ -38,70 +47,68 @@ diseases_info = {
|
|
38 |
"symptoms": ["persistent sadness", "loss of interest", "fatigue", "changes in appetite or sleep patterns"],
|
39 |
"treatment": "Antidepressants, therapy (CBT), exercise, and social support.",
|
40 |
},
|
41 |
-
|
42 |
-
|
43 |
-
"
|
44 |
-
|
45 |
-
"covid-19": {
|
46 |
-
"symptoms": ["fever", "dry cough", "fatigue", "loss of taste or smell", "shortness of breath"],
|
47 |
-
"treatment": "Rest, fluids, over-the-counter medications, and antiviral drugs if prescribed.",
|
48 |
},
|
49 |
-
|
50 |
-
"symptoms": ["
|
51 |
-
"treatment": "
|
52 |
},
|
53 |
}
|
54 |
|
55 |
-
|
56 |
# Function to display disease info
|
57 |
def display_disease_info(disease_name):
|
58 |
disease_name = disease_name.lower().replace(" ", "_")
|
59 |
if disease_name in diseases_info:
|
60 |
disease = diseases_info[disease_name]
|
61 |
-
result = f"
|
62 |
-
result += f"
|
63 |
-
result += f"
|
64 |
return result
|
65 |
else:
|
66 |
-
return "
|
67 |
|
68 |
-
# Function to
|
69 |
def chat_bot(user_input):
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
return
|
76 |
-
|
77 |
-
return "
|
78 |
|
79 |
# Streamlit App Interface
|
80 |
def main():
|
81 |
# Title of the app
|
82 |
-
st.title("
|
83 |
-
|
84 |
# Disease Input
|
85 |
disease_name = st.text_input("Enter Disease Name", "")
|
86 |
if disease_name:
|
87 |
st.subheader("Disease Information")
|
88 |
disease_info = display_disease_info(disease_name)
|
89 |
st.text_area("Disease Info", disease_info, height=150)
|
90 |
-
|
91 |
# Chat Bot Section
|
92 |
st.subheader("Chat with Bot")
|
93 |
-
user_input = st.text_input("Enter a Message
|
94 |
if user_input:
|
95 |
response = chat_bot(user_input)
|
96 |
st.text_area("Chat Bot Response", response, height=100)
|
97 |
-
|
98 |
-
# Add
|
99 |
-
st.markdown(
|
|
|
100 |
- **Enter a disease name** in the input box to get information about symptoms and treatments.
|
101 |
-
- **
|
102 |
-
|
103 |
-
|
104 |
|
105 |
# Run the app
|
106 |
if __name__ == "__main__":
|
107 |
main()
|
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
+
from groq import Groq
|
4 |
+
GROQ_API_KEY = "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"
|
5 |
+
# Initialize Groq Client
|
6 |
+
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
7 |
|
8 |
# Disease and Treatment Information Data
|
9 |
diseases_info = {
|
|
|
27 |
"symptoms": ["shortness of breath", "wheezing", "chest tightness", "coughing"],
|
28 |
"treatment": "Inhalers, bronchodilators, corticosteroids, and avoiding triggers.",
|
29 |
},
|
|
|
|
|
|
|
|
|
30 |
"hypertension": {
|
31 |
"symptoms": ["headaches", "dizziness", "shortness of breath", "nosebleeds"],
|
32 |
"treatment": "Medications like beta-blockers, ACE inhibitors, lifestyle changes including exercise and diet.",
|
33 |
},
|
34 |
+
"arthritis": {
|
35 |
+
"symptoms": ["joint pain", "swelling", "stiffness", "reduced range of motion"],
|
36 |
+
"treatment": "Pain relievers, anti-inflammatory drugs, physical therapy, and joint protection.",
|
37 |
+
},
|
38 |
+
"covid-19": {
|
39 |
+
"symptoms": ["fever", "dry cough", "fatigue", "loss of taste or smell", "shortness of breath"],
|
40 |
+
"treatment": "Rest, fluids, over-the-counter medications, and antiviral drugs if prescribed.",
|
41 |
+
},
|
42 |
"anxiety": {
|
43 |
"symptoms": ["excessive worry", "restlessness", "fatigue", "difficulty concentrating", "irritability"],
|
44 |
"treatment": "Cognitive-behavioral therapy (CBT), medications like SSRIs, relaxation techniques.",
|
|
|
47 |
"symptoms": ["persistent sadness", "loss of interest", "fatigue", "changes in appetite or sleep patterns"],
|
48 |
"treatment": "Antidepressants, therapy (CBT), exercise, and social support.",
|
49 |
},
|
50 |
+
# Additional Diseases
|
51 |
+
"migraine": {
|
52 |
+
"symptoms": ["severe headache", "nausea", "sensitivity to light and sound"],
|
53 |
+
"treatment": "Prescription medications, rest in a dark room, and lifestyle adjustments.",
|
|
|
|
|
|
|
54 |
},
|
55 |
+
"eczema": {
|
56 |
+
"symptoms": ["itchy skin", "red rashes", "dry skin", "cracked or scaly patches"],
|
57 |
+
"treatment": "Moisturizers, corticosteroid creams, antihistamines, and avoiding irritants.",
|
58 |
},
|
59 |
}
|
60 |
|
|
|
61 |
# Function to display disease info
|
62 |
def display_disease_info(disease_name):
|
63 |
disease_name = disease_name.lower().replace(" ", "_")
|
64 |
if disease_name in diseases_info:
|
65 |
disease = diseases_info[disease_name]
|
66 |
+
result = f"**Disease:** {disease_name.replace('_', ' ').title()}\n"
|
67 |
+
result += f"**Symptoms:** {', '.join(disease['symptoms'])}\n"
|
68 |
+
result += f"**Treatment:** {disease['treatment']}"
|
69 |
return result
|
70 |
else:
|
71 |
+
return "Sorry, no information available for this disease."
|
72 |
|
73 |
+
# Function to interact with Groq API for Chat Bot
|
74 |
def chat_bot(user_input):
|
75 |
+
try:
|
76 |
+
chat_completion = client.chat.completions.create(
|
77 |
+
messages=[{"role": "user", "content": user_input}],
|
78 |
+
model="llama-3.3-70b-versatile",
|
79 |
+
)
|
80 |
+
return chat_completion.choices[0].message.content
|
81 |
+
except Exception as e:
|
82 |
+
return f"Error: Unable to process your request. {str(e)}"
|
83 |
|
84 |
# Streamlit App Interface
|
85 |
def main():
|
86 |
# Title of the app
|
87 |
+
st.title("Health Guide Chat Bot")
|
88 |
+
|
89 |
# Disease Input
|
90 |
disease_name = st.text_input("Enter Disease Name", "")
|
91 |
if disease_name:
|
92 |
st.subheader("Disease Information")
|
93 |
disease_info = display_disease_info(disease_name)
|
94 |
st.text_area("Disease Info", disease_info, height=150)
|
95 |
+
|
96 |
# Chat Bot Section
|
97 |
st.subheader("Chat with Bot")
|
98 |
+
user_input = st.text_input("Enter a Message for the Chat Bot", "")
|
99 |
if user_input:
|
100 |
response = chat_bot(user_input)
|
101 |
st.text_area("Chat Bot Response", response, height=100)
|
102 |
+
|
103 |
+
# Add instructions
|
104 |
+
st.markdown(
|
105 |
+
"""
|
106 |
- **Enter a disease name** in the input box to get information about symptoms and treatments.
|
107 |
+
- **Chat with the bot** to get general health advice or answers to your questions.
|
108 |
+
"""
|
109 |
+
)
|
110 |
|
111 |
# Run the app
|
112 |
if __name__ == "__main__":
|
113 |
main()
|
114 |
+
|