Pace Copilot is an AI-powered running coach that generates personalized training plans to help users achieve their goals. By analyzing their running history, it creates a tailored plan that adapts to their fitness level, goals, and training volume. The tool provides detailed workouts, including road running, trail running, strength training, and road biking.
Pace Copilot is built upon the Vercel AI SDK, a framework that facilitates
seamless integration with multiple LLM providers. This flexibility enables developers to experiment with various models
to evaluate performance in generating structured training plans.
Model Comparisons
Several LLMs were tested for training plan generation, including:
GPT-4: Delivered highly coherent and contextually relevant plans with superior speed and reliability. Ultimately,
it was selected for deployment due to its balance of performance and stability.
Deepseek (deepseek-chat): Produced high-quality plans with accurate and structured outputs, but exhibited
occasional instability. It could be an excellent alternative to OpenAI, with prices 100x cheaper per number of
tokens.
Mistral: Although offering a cost-effective solution, Mistral’s response times were significantly longer, and the
generated plans were less refined and inconsistent in quality.
To ensure high-quality, deterministic outputs, the temperature parameter of the model was set to 0.3, balancing
creativity with reliability.
Authentication and Credit System with Clerk
To manage user authentication efficiently, Pace Copilot integrates Clerk, which allows for a quick
and seamless
authentication process. Using Clerk, user accounts are secured, and access control is streamlined. Additionally, to
regulate the number of training plans generated per user, a credit-based system was implemented. Each user is
allocated three credits, with each plan generation consuming one credit. This system helps maintain fair usage and
manage resource allocation effectively.
Generating Personalized Training Plans
Pace Copilot create a custom prompt for the LLM based on the athlete’s input, ensuring the generated training plan is
tailored to their specific needs. The application collects key information such as weekly mileage, preferred activities,
and target events, which are then used to construct a highly specific prompt.
Workflow
User Input Collection: The athlete provides key information such as weekly
mileage, preferred activities (road running, trail running, strength training, cycling), and target events.
Dynamic Prompt Engineering: The application constructs a highly specific prompt incorporating the user’s data to
guide the model toward generating a tailored plan.
Training Plan Generation: The LLM processes the structured input and produces a comprehensive, step-by-step
training schedule.
Output Validation: The generated plan is validated using a Zod schema, ensuring all necessary fields are
correctly structured and aligned with training principles.
Plan generation diagram
Schema Validation with Zod
A crucial component of the system is the Zod schema, which enforces a structured format for the model’s output. Each
field in the schema is meticulously defined with detailed descriptions, helping the model generate precise and usable
data. This validation step ensures the output remains consistent and aligns with evidence-based training methodologies.