Aadarshwahmare commited on
Commit
56db06a
Β·
verified Β·
1 Parent(s): 1bfc7bd

Update app.py

Browse files

Final fix - working model

Files changed (1) hide show
  1. app.py +16 -36
app.py CHANGED
@@ -5,61 +5,41 @@ import os
5
  # Configure API key
6
  genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
7
 
8
- # Use correct model
9
- model = genai.GenerativeModel("gemini-pro")
10
 
11
  def fitness_coach(age, weight, goal, activity):
12
  try:
13
  prompt = f"""
14
- You are a professional fitness coach.
15
 
16
- Generate a UNIQUE and personalized fitness plan based on the user details.
17
 
18
- User Details:
19
- Age: {age}
20
- Weight: {weight} kg
21
- Goal: {goal}
22
- Activity Level: {activity}
23
 
24
- Instructions:
25
- - If goal is Weight Loss β†’ focus on fat loss workouts
26
- - If goal is Muscle Gain β†’ focus on strength training
27
- - If goal is Maintenance β†’ balanced plan
28
- - If activity is Beginner β†’ simple plan
29
- - If Intermediate β†’ moderate plan
30
- - If Advanced β†’ intense plan
31
-
32
- Include:
33
- 1. Workout Plan
34
- 2. Diet Plan
35
- 3. Tips
36
-
37
- Make sure the response changes based on inputs.
38
- """
39
-
40
- response = model.generate_content(
41
- prompt,
42
- generation_config={
43
- "temperature": 0.9,
44
- "top_p": 1,
45
- "top_k": 1,
46
- "max_output_tokens": 500,
47
- }
48
- )
49
 
 
50
  return response.text
51
 
52
  except Exception as e:
53
  return f"Error: {str(e)}"
54
 
55
- # Gradio UI
56
  interface = gr.Interface(
57
  fn=fitness_coach,
58
  inputs=[
59
  gr.Number(label="Age"),
60
  gr.Number(label="Weight (kg)"),
61
  gr.Dropdown(["Weight Loss", "Muscle Gain", "Maintenance"], label="Goal"),
62
- gr.Dropdown(["Beginner", "Intermediate", "Advanced"], label="Activity Level")
63
  ],
64
  outputs="text",
65
  title="πŸ’ͺ Personalized Fitness Coach",
 
5
  # Configure API key
6
  genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
7
 
8
+ # Use working model
9
+ model = genai.GenerativeModel("gemini-1.5-flash")
10
 
11
  def fitness_coach(age, weight, goal, activity):
12
  try:
13
  prompt = f"""
14
+ You are a certified fitness coach.
15
 
16
+ Create a personalized fitness plan:
17
 
18
+ Age: {age}
19
+ Weight: {weight}
20
+ Goal: {goal}
21
+ Activity Level: {activity}
 
22
 
23
+ Include:
24
+ 1. Workout Plan
25
+ 2. Diet Plan
26
+ 3. Tips
27
+ """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ response = model.generate_content(prompt)
30
  return response.text
31
 
32
  except Exception as e:
33
  return f"Error: {str(e)}"
34
 
35
+
36
  interface = gr.Interface(
37
  fn=fitness_coach,
38
  inputs=[
39
  gr.Number(label="Age"),
40
  gr.Number(label="Weight (kg)"),
41
  gr.Dropdown(["Weight Loss", "Muscle Gain", "Maintenance"], label="Goal"),
42
+ gr.Dropdown(["Beginner", "Intermediate", "Advanced"], label="Activity Level"),
43
  ],
44
  outputs="text",
45
  title="πŸ’ͺ Personalized Fitness Coach",