import streamlit as st import requests API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-small" headers = { "Authorization": f"Bearer {st.secrets['HF_API_TOKEN']}" } st.set_page_config(page_title="Fitness Plan AI", layout="centered") st.title("🏋️ Fitness Plan AI Generator") st.write("Generate a personalized fitness plan using AI") age = st.number_input("Age", 15, 80, 22) gender = st.selectbox("Gender", ["Male", "Female"]) goal = st.selectbox("Fitness Goal", ["Weight Loss", "Muscle Gain", "General Fitness"]) level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"]) days = st.slider("Workout Days per Week", 1, 7, 4) def query(payload): response = requests.post(API_URL, headers=headers, json=payload) return response.json() if st.button("Generate Fitness Plan"): prompt = ( f"Create a {days}-day fitness workout plan for a " f"{age}-year-old {gender}. " f"Goal: {goal}. " f"Fitness level: {level}. " f"Include warm-up, main workout, and cool-down." ) with st.spinner("Generating plan..."): output = query({"inputs": prompt}) st.success("✅ Your Fitness Plan") st.write(outp