waqasali1707 commited on
Commit
6ced5e8
·
verified ·
1 Parent(s): 46e04d1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from openai import OpenAI
3
+
4
+ # Function to generate a workout plan
5
+ def generate_workout_plan(weight, height, bmi):
6
+ client = OpenAI(
7
+ base_url="https://integrate.api.nvidia.com/v1",
8
+ api_key="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"
9
+ )
10
+
11
+ prompt = f"Give me a workout plan to lose weight where my weight is {weight} pounds, my height is {height} feet, and my BMI is {bmi}."
12
+
13
+ completion = client.chat.completions.create(
14
+ model="meta/llama-3.1-405b-instruct",
15
+ messages=[{"role": "user", "content": prompt}],
16
+ temperature=0.2,
17
+ top_p=0.7,
18
+ max_tokens=1024,
19
+ stream=True
20
+ )
21
+
22
+ workout_plan = ""
23
+ for chunk in completion:
24
+ if chunk.choices[0].delta.content is not None:
25
+ workout_plan += chunk.choices[0].delta.content
26
+
27
+ return workout_plan
28
+
29
+ # Streamlit UI
30
+ st.title("AI-Generated Workout Plan")
31
+
32
+ weight = st.number_input("Enter your weight (in pounds):", min_value=1)
33
+ height = st.number_input("Enter your height (in feet):", min_value=0.5, max_value=8.0, step=0.1)
34
+ bmi = st.number_input("Enter your BMI:", min_value=1.0, max_value=100.0, step=0.1)
35
+
36
+ if st.button("Generate Workout Plan"):
37
+ workout_plan = generate_workout_plan(weight, height, bmi)
38
+ st.text_area("Your AI-Generated Workout Plan:", value=workout_plan, height=300)