Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,27 +5,31 @@ import os
|
|
| 5 |
# Configure API key
|
| 6 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 7 |
|
| 8 |
-
model = genai.GenerativeModel("gemini-
|
| 9 |
|
| 10 |
def fitness_coach(age, weight, goal, activity):
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
interface = gr.Interface(
|
| 31 |
fn=fitness_coach,
|
|
|
|
| 5 |
# Configure API key
|
| 6 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 7 |
|
| 8 |
+
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 9 |
|
| 10 |
def fitness_coach(age, weight, goal, activity):
|
| 11 |
+
try:
|
| 12 |
+
prompt = f"""
|
| 13 |
+
You are a certified fitness coach and nutrition expert.
|
| 14 |
|
| 15 |
+
Create a personalized fitness plan:
|
| 16 |
|
| 17 |
+
Age: {age}
|
| 18 |
+
Weight: {weight}
|
| 19 |
+
Goal: {goal}
|
| 20 |
+
Activity Level: {activity}
|
| 21 |
|
| 22 |
+
Include:
|
| 23 |
+
1. Workout Plan
|
| 24 |
+
2. Diet Plan
|
| 25 |
+
3. Tips
|
| 26 |
+
"""
|
| 27 |
|
| 28 |
+
response = model.generate_content(prompt)
|
| 29 |
+
return response.text
|
| 30 |
+
|
| 31 |
+
except Exception as e:
|
| 32 |
+
return f"Error: {str(e)}"
|
| 33 |
|
| 34 |
interface = gr.Interface(
|
| 35 |
fn=fitness_coach,
|