Building a Training Schedule Generator using Lyzr SDK

In the fast-paced world of athletic training, having a personalized training plan can make a significant difference in an athlete’s performance. Leveraging advanced AI technologies, we can now create tailored training schedules that cater to individual…


This content originally appeared on DEV Community and was authored by Akshay Keerthi

In the fast-paced world of athletic training, having a personalized training plan can make a significant difference in an athlete’s performance. Leveraging advanced AI technologies, we can now create tailored training schedules that cater to individual needs. In this blog post, we explore how to develop a Training Schedule Generator app using Lyzr Automata SDK and OpenAI’s GPT-4 Turbo.

Image description

Imagine being able to generate a customized training plan for any sport, considering the athlete’s experience level and the time remaining until their race day. This is now possible with the integration of Lyzr Automata and OpenAI’s GPT-4 Turbo. This app will guide you through creating a personalized workout plan, ensuring you’re well-prepared to achieve your goals.

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!

Before diving into the code, ensure you have the necessary libraries installed. We’ll be using Streamlit for the web interface, the Lyzr Automata SDK for task management, and the OpenAI API for text generation.

pip install streamlit lyzr-automata openai pillow

Here’s a breakdown of the code to create our Training Schedule Generator app.

First, we need to import the required libraries:

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

Here streamlit is used for creating the web app interface,
lyzr_automata SDK provides classes for managing AI models and tasks,PIL (Python Imaging Library) is used for handling images and os is used for setting environment variables, such as the OpenAI API key.

We need to set up the OpenAI API key to authenticate our requests:

os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]

This line sets the OpenAI API key from Streamlit’s secrets management.

Now , we add a title and some introductory text to the app:

st.title("Training Schedule Generator")
st.markdown("Welcome to Training Schedule Generator! We create personalized workout plans based on your sport, experience level, and race date, ensuring you're perfectly prepared to crush your goals and perform at your best.")
st.markdown("1) Name of the sports you are participating at.")
st.markdown("2) Mention your experience level.")
st.markdown("3) Mention the amount of time left until the race day.")
Here, we prompt the user to enter their training details:

input = st.text_input("Please enter the above details:", placeholder="Type here")

We configure the OpenAI model with specific parameters later on:


open_ai_text_completion_model = OpenAIModel(
    api_key=st.secrets["apikey"],
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)

Defining the Training Plan Generation Function
We define a function to generate the training plan:

def generation(input):
    generator_agent = Agent(
        role="Expert ATHLETIC COACH and PERSONAL TRAINER",
        prompt_persona="Your task is to DEVELOP a personalized training plan based on the INPUTS provided: the SPORT NAME, the athlete's EXPERIENCE LEVEL, and the RACE DATE.")
    prompt = """
[Prompts here]
   """
    generator_agent_task = Task(
        name="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

We add a button to generate the training plan when clicked:

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

By leveraging the power of Lyzr Automata and OpenAI’s GPT-4 Turbo, we can create a highly customized and effective training schedule generator. This app allows athletes to input their specific needs and receive a tailored training plan to help them achieve their goals. Whether you’re a coach or an athlete, this tool can be a game-changer in optimizing performance and ensuring readiness for race day.

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

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

The Training Schedule Generator is powered by the Lyzr Automata Agent, utilizing the capabilities of OpenAI’s GPT-4 Turbo. For any inquiries or issues, please contact Lyzr. You can learn more about Lyzr and their offerings through the following links:

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


This content originally appeared on DEV Community and was authored by Akshay Keerthi


Print Share Comment Cite Upload Translate Updates
APA

Akshay Keerthi | Sciencx (2024-07-01T18:34:12+00:00) Building a Training Schedule Generator using Lyzr SDK. Retrieved from https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/

MLA
" » Building a Training Schedule Generator using Lyzr SDK." Akshay Keerthi | Sciencx - Monday July 1, 2024, https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/
HARVARD
Akshay Keerthi | Sciencx Monday July 1, 2024 » Building a Training Schedule Generator using Lyzr SDK., viewed ,<https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/>
VANCOUVER
Akshay Keerthi | Sciencx - » Building a Training Schedule Generator using Lyzr SDK. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/
CHICAGO
" » Building a Training Schedule Generator using Lyzr SDK." Akshay Keerthi | Sciencx - Accessed . https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/
IEEE
" » Building a Training Schedule Generator using Lyzr SDK." Akshay Keerthi | Sciencx [Online]. Available: https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/. [Accessed: ]
rf:citation
» Building a Training Schedule Generator using Lyzr SDK | Akshay Keerthi | Sciencx | https://www.scien.cx/2024/07/01/building-a-training-schedule-generator-using-lyzr-sdk/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.