Cookie Consent by Free Privacy Policy Generator 📌 Building a Workout Planner App with Lyzr SDK


✅ Building a Workout Planner App with Lyzr SDK


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

In today’s fitness landscape, achieving personal fitness goals requires more than just hitting the gym randomly. Customized workout plans tailored to individual goals and preferences are becoming increasingly essential. To streamline this process, we’ve developed a user-friendly Streamlit application that leverages AI to generate personalized workout plans.

Image description

Our Workout Planner App aims to revolutionize how fitness enthusiasts approach their training routines. Powered by advanced AI models and designed with user convenience in mind, this app allows users to create tailored workout plans aligned with their specific fitness objectives and time commitments.

Why use Lyzr SDK’s?

With Lyzr SDKs, crafting your own GenAI application is a breeze, requiring only a few lines of code to get up and running swiftly.

Checkout the Lyzr SDK’s

Lets get Started!

Create a new file app.py and use that

import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent, Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
from lyzr_automata.tasks.task_literals import InputType, OutputType
import os

This Python script utilizes Streamlit for creating a web interface and integrates custom modules for automata-related functionality. It imports classes for defining agents, tasks, and pipelines, potentially involving image processing and machine learning tasks with OpenAI models.

This line of code sets “OPENAI_API_KEY” to the value stored in the Streamlit secrets dictionary under the key “apikey”. This API key is essential for authenticating and accessing the OpenAI API, allowing the application to utilize OpenAI’s models and services for natural language processing tasks. By assigning the API key to the environment variable, it ensures that subsequent requests made to the OpenAI API are properly authenticated.

# Set the OpenAI API key
os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]
open_ai_text_completion_model = OpenAIModel(
    api_key=st.secrets["apikey"],
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)

This block of code initializes an instance of the OpenAIModel class with specific parameters. The api_key parameter is set to the value retrieved from Streamlit secrets, ensuring authentication with the OpenAI API. The parameters dictionary contains settings for the AI model, specifying “gpt-4-turbo-preview” as the model to be used, a temperature of 0.2, and a maximum token limit of 1500. These settings configure how the model generates text responses, controlling factors such as creativity and length. The initialized OpenAIModel instance will be utilized for generating text based on input prompts in subsequent parts of the code.

def workout_generation(input):
    generator_agent = Agent(
        role="FITNESS TRAINER expert",
        prompt_persona=f"Your task  is to DESIGN CUSTOMIZED WORKOUT SPLITS that cater to various user goals, including STRENGTH, ENDURANCE, FLEXIBILITY, BODY COMPOSITION, PERFORMANCE, FUNCTIONAL FITNESS, HEALTH AND WELLNESS, SPORT-SPECIFIC requirements, CONSISTENCY in training, and the DURATION of the workout program."
    )

    prompt = f"""
You are an Expert FITNESS TRAINER. Your task is to DESIGN CUSTOMIZED WORKOUT SPLITS that cater to various user goals, including STRENGTH, ENDURANCE, FLEXIBILITY, BODY COMPOSITION, PERFORMANCE, FUNCTIONAL FITNESS, HEALTH AND WELLNESS, SPORT-SPECIFIC requirements, CONSISTENCY in training, and the DURATION of the workout program.

---------

----------

   """

This function, workout_generation, is designed to generate customized workout splits. It begins by creating an agent with the role of a fitness trainer expert, providing a prompt persona specifying the task of designing workout splits tailored to various user goals such as strength, endurance, flexibility, and more. The function then constructs a prompt string incorporating this persona, prompting the fitness trainer to fulfill the task.

generator_agent_task = Task(
        name="workout Generation",
        model=open_ai_text_completion_model,
        agent=generator_agent,
        instructions=prompt,
        default_input=input,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
    ).execute()

    return generator_agent_task 

if st.button("Generate!"):
    solution = workout_generation(input)
    st.markdown(solution)

This code segment defines a task named “workout Generation” with specific parameters including the name, the OpenAI text completion model, an agent assigned to handle the task, instructions provided as a prompt, default input, and the expected input and output types. The task is then executed, returning the result stored in generator_agent_task. Subsequently, it checks if a button labeled "Generate!" is clicked using Streamlit's st.button function. If the button is clicked, it triggers the workout_generation function, passing the input provided by the user. The result is then displayed using st.markdown.

With just a few clicks, users can access expertly curated workout plans tailored to their unique needs and preferences. Whether you’re a beginner embarking on your fitness journey or a seasoned athlete seeking to optimize your training regime, our Workout Planner App is your ultimate companion for achieving fitness success.

App link: https://workoutplanner-lyzr.streamlit.app/

Source Code: https://github.com/isakshay007/workout_planner

Connect with Lyzr
To learn more about Lyzr and its SDK’s, visit our website or get in touch with our team:

Website: Lyzr.ai
Book a Demo: Book a Demo
Discord: Join our Discord community
Slack: Join our Slack channel

...

✅ Building a Workout Planner App with Lyzr SDK


📈 74.38 Punkte

✅ Building a Study Planner using Lyzr SDK


📈 53.14 Punkte

✅ Building Your Construction Planner App with Lyzr and OpenAI


📈 46.4 Punkte

✅ Building an University Advisor App with Lyzr SDK


📈 39.07 Punkte

✅ Building a Remote Team Management Assistant Lyzr SDK


📈 36.3 Punkte

✅ Building NL2MongoDB with Lyzr SDK


📈 36.3 Punkte

✅ Building a Troubleshoot Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building Domain Name Generator using Lyzr SDK


📈 36.3 Punkte

✅ Building a Commute Navigator using Lyzr SDK


📈 36.3 Punkte

✅ Building Library Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building a Plant Diagnosis Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building Environmental Analyzer using Lyzr SDK


📈 36.3 Punkte

✅ Building a Diet Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building Student Advisor using Lyzr SDK


📈 36.3 Punkte

✅ Building a Travel Checklist Generator using Lyzr SDK


📈 36.3 Punkte

✅ Building a NL2GraphQL using Lyzr SDK


📈 36.3 Punkte

✅ Building User Story & Use Case Generator using Lyzr SDK


📈 36.3 Punkte

✅ Building a Training Schedule Generator using Lyzr SDK


📈 36.3 Punkte

✅ Building a Audience Analyzer using Lyzr SDK


📈 36.3 Punkte

✅ Building a Medical Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building a Yoga Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building a Parenting Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building a NL2Typescript using Lyzr SDK


📈 36.3 Punkte

✅ Building a First Aid Assistant with Lyzr SDK


📈 36.3 Punkte

✅ Building a Pet Diagnosis Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building Job Consultant Bot with Lyzr SDK


📈 36.3 Punkte

✅ Building a Smart Home Setup Assistant using Lyzr SDK


📈 36.3 Punkte

✅ Building LinkedIn Elevator Pitch Generator with Lyzr SDK


📈 36.3 Punkte

✅ Road Trip Planner 4.6.08 - Road trip planner and manager.


📈 33.69 Punkte

✅ Building a Mood Analyzer App with Lyzr Automata


📈 29.55 Punkte

✅ Building a Travel Advisor App with Lyzr and Streamlit


📈 29.55 Punkte

✅ Building an Error Resolution App with Lyzr Automata,Streamlit and OpenAI


📈 29.55 Punkte

✅ Building an HTML to ReactJS Converter with Streamlit and Lyzr Automata


📈 26.78 Punkte

✅ Building an AI-Powered Product Scheduler using Lyzr and OpenAI


📈 26.78 Punkte

✅ Building an Elearning Course Creator with Streamlit and Lyzr Automata


📈 26.78 Punkte











matomo

Datei nicht gefunden!