File size: 1,576 Bytes
6ced5e8
 
 
 
 
 
 
fc46483
6ced5e8
 
596e9c4
6ced5e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import streamlit as st
from openai import OpenAI

# Function to generate a workout plan
def generate_workout_plan(weight, height, bmi):
    client = OpenAI(
        base_url="https://integrate.api.nvidia.com/v1",
        api_key="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"
    )

    prompt = f"I am a health care professional. Give me a general workout plan to adjust my clients weight where his weight is {weight} pounds, his height is {height} feet, and his BMI is {bmi}. It should be a weekly plan with durations of each step. I just want to match your plan with my suggestions. So, give me a general overview."

    completion = client.chat.completions.create(
        model="meta/llama-3.1-405b-instruct",
        messages=[{"role": "user", "content": prompt}],
        temperature=0.2,
        top_p=0.7,
        max_tokens=1024,
        stream=True
    )

    workout_plan = ""
    for chunk in completion:
        if chunk.choices[0].delta.content is not None:
            workout_plan += chunk.choices[0].delta.content

    return workout_plan

# Streamlit UI
st.title("AI-Generated Workout Plan")

weight = st.number_input("Enter your weight (in pounds):", min_value=1)
height = st.number_input("Enter your height (in feet):", min_value=0.5, max_value=8.0, step=0.1)
bmi = st.number_input("Enter your BMI:", min_value=1.0, max_value=100.0, step=0.1)

if st.button("Generate Workout Plan"):
    workout_plan = generate_workout_plan(weight, height, bmi)
    st.text_area("Your AI-Generated Workout Plan:", value=workout_plan, height=300)