Spaces:
Sleeping
Sleeping
File size: 4,724 Bytes
931130c d37fea4 c934db1 d37fea4 c934db1 931130c b23563c 80ffae0 b23563c 80ffae0 b23563c 80ffae0 b23563c 80ffae0 99032ef b23563c 99032ef 163b4b3 b23563c 163b4b3 d37fea4 b23563c 163b4b3 b23563c 163b4b3 d37fea4 163b4b3 d37fea4 3a27d27 80ffae0 931130c 95309d0 b23563c d37fea4 931130c be9ce02 d37fea4 80ffae0 d37fea4 931130c d37fea4 e9e1caa 931130c 95309d0 931130c d37fea4 931130c d37fea4 931130c d37fea4 931130c d37fea4 931130c d37fea4 80ffae0 931130c 95309d0 |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
import streamlit as st
from groq import Groq
# Define the Groq API Key
GROQ_API_KEY = "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"
# Initialize Groq Client using the API key
client = Groq(api_key=GROQ_API_KEY)
# Disease and Treatment Information Data
diseases_info = {
"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.",
},
"cold": {
"symptoms": ["sore throat", "runny nose", "cough", "sneezing", "mild body aches"],
"treatment": "Rest, hydration, decongestants, and over-the-counter pain relief.",
},
"asthma": {
"symptoms": ["shortness of breath", "wheezing", "chest tightness", "coughing"],
"treatment": "Inhalers, bronchodilators, corticosteroids, and avoiding triggers.",
},
"hypertension": {
"symptoms": ["headaches", "dizziness", "shortness of breath", "nosebleeds"],
"treatment": "Medications like beta-blockers, ACE inhibitors, lifestyle changes including exercise and diet.",
},
"arthritis": {
"symptoms": ["joint pain", "swelling", "stiffness", "reduced range of motion"],
"treatment": "Pain relievers, anti-inflammatory drugs, physical therapy, and joint protection.",
},
"covid-19": {
"symptoms": ["fever", "dry cough", "fatigue", "loss of taste or smell", "shortness of breath"],
"treatment": "Rest, fluids, over-the-counter medications, and antiviral drugs if prescribed.",
},
"anxiety": {
"symptoms": ["excessive worry", "restlessness", "fatigue", "difficulty concentrating", "irritability"],
"treatment": "Cognitive-behavioral therapy (CBT), medications like SSRIs, relaxation techniques.",
},
"depression": {
"symptoms": ["persistent sadness", "loss of interest", "fatigue", "changes in appetite or sleep patterns"],
"treatment": "Antidepressants, therapy (CBT), exercise, and social support.",
},
"migraine": {
"symptoms": ["severe headache", "nausea", "sensitivity to light and sound"],
"treatment": "Prescription medications, rest in a dark room, and lifestyle adjustments.",
},
"eczema": {
"symptoms": ["itchy skin", "red rashes", "dry skin", "cracked or scaly patches"],
"treatment": "Moisturizers, corticosteroid creams, antihistamines, and avoiding irritants.",
},
}
# Function to display disease info
def display_disease_info(disease_name):
disease_name = disease_name.lower().replace(" ", "_")
if disease_name in diseases_info:
disease = diseases_info[disease_name]
result = f"**Disease:** {disease_name.replace('_', ' ').title()}\n"
result += f"**Symptoms:** {', '.join(disease['symptoms'])}\n"
result += f"**Treatment:** {disease['treatment']}"
return result
else:
return "Sorry, no information available for this disease."
# Function to interact with Groq API for Chat Bot
def chat_bot(user_input):
try:
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": user_input}],
model="llama-3.3-70b-versatile",
)
return chat_completion.choices[0].message.content
except Exception as e:
return f"Error: Unable to process your request. {str(e)}"
# Streamlit App Interface
def main():
# Title of the app
st.title("Health Guide Chat Bot")
# Disease Input
disease_name = st.text_input("Enter Disease Name", "")
if disease_name:
st.subheader("Disease Information")
disease_info = display_disease_info(disease_name)
st.text_area("Disease Info", disease_info, height=150)
# Chat Bot Section
st.subheader("Chat with Bot")
user_input = st.text_input("Enter a Message for the Chat Bot", "")
if user_input:
response = chat_bot(user_input)
st.text_area("Chat Bot Response", response, height=100)
# Add instructions
st.markdown(
"""
- **Enter a disease name** in the input box to get information about symptoms and treatments.
- **Chat with the bot** to get general health advice or answers to your questions.
"""
)
# Run the app
if __name__ == "__main__":
main()
|