import os import gradio as gr import groq # Load API key from Hugging Face secret environment variable client = groq.Groq(api_key=os.environ["GROQ_API_KEY"]) def get_health_advice(symptoms): prompt = f""" You are an AI Health Advisor. A user reports the following symptoms: "{symptoms}" Please provide: 1. Possible medical condition(s) 2. A short description 3. Severity (Mild, Moderate, Severe) 4. Recommended solution (home remedy, OTC medicine, or doctor visit) āš ļø Disclaimer: This is not professional medical advice. Always consult a licensed physician. Format: šŸ”¹ Possible Condition(s): šŸ”¹ Description: šŸ”¹ Severity: šŸ”¹ Recommended Solution: šŸ”¹ Disclaimer """ try: response = client.chat.completions.create( model="llama3-70b-8192", # āœ… Supported model messages=[{"role": "user", "content": prompt}], temperature=0.7 ) return response.choices[0].message.content except Exception as e: return f"āŒ Error: {e}" # Gradio Interface gr.Interface( fn=get_health_advice, inputs=gr.Textbox(lines=3, placeholder="e.g., fever, cough, sore throat"), outputs="text", title="šŸ¤– AI Health Advisor", description="Enter symptoms to get disease awareness and suggestions.\nāš ļø This is not medical advice.", ).launch()