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()