Mehak900 commited on
Commit
fcb5203
·
verified ·
1 Parent(s): e8029c8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import groq
4
+
5
+ # Load API key from Hugging Face secret environment variable
6
+ client = groq.Groq(api_key=os.environ["GROQ_API_KEY"])
7
+
8
+ def get_health_advice(symptoms):
9
+ prompt = f"""
10
+ You are an AI Health Advisor. A user reports the following symptoms: "{symptoms}"
11
+
12
+ Please provide:
13
+ 1. Possible medical condition(s)
14
+ 2. A short description
15
+ 3. Severity (Mild, Moderate, Severe)
16
+ 4. Recommended solution (home remedy, OTC medicine, or doctor visit)
17
+
18
+ ⚠️ Disclaimer: This is not professional medical advice. Always consult a licensed physician.
19
+
20
+ Format:
21
+ 🔹 Possible Condition(s):
22
+ 🔹 Description:
23
+ 🔹 Severity:
24
+ 🔹 Recommended Solution:
25
+ 🔹 Disclaimer
26
+ """
27
+ try:
28
+ response = client.chat.completions.create(
29
+ model="llama3-70b-8192", # ✅ Supported model
30
+ messages=[{"role": "user", "content": prompt}],
31
+ temperature=0.7
32
+ )
33
+ return response.choices[0].message.content
34
+ except Exception as e:
35
+ return f"❌ Error: {e}"
36
+
37
+ # Gradio Interface
38
+ gr.Interface(
39
+ fn=get_health_advice,
40
+ inputs=gr.Textbox(lines=3, placeholder="e.g., fever, cough, sore throat"),
41
+ outputs="text",
42
+ title="🤖 AI Health Advisor",
43
+ description="Enter symptoms to get disease awareness and suggestions.\n⚠️ This is not medical advice.",
44
+ ).launch()