AI Workout Generator

Fill out the form below to get a personalized workout plan.

Your Personalized Workout Plan

Generating your workout, please wait...

'; $resp = LocalAIApi::createResponse( [ 'input' => [ ['role' => 'system', 'content' => $system_prompt], ['role' => 'user', 'content' => $user_prompt], ], ] ); if (!empty($resp['success'])) { $text = LocalAIApi::extractText($resp); $workout_data = json_decode($text, true); if ($workout_data && isset($workout_data['workout'])) { echo '
'; foreach ($workout_data['workout'] as $section) { echo '
'; echo '

' . htmlspecialchars($section['title']) . '

'; echo '
    '; foreach ($section['exercises'] as $exercise) { echo '
  • '; echo '' . htmlspecialchars($exercise['name']) . ''; echo '' . htmlspecialchars($exercise['sets']) . ' of ' . htmlspecialchars($exercise['reps']) . ''; if (!empty($exercise['video_url'])) { echo 'Watch Video'; } echo '
  • '; } echo '
'; echo '
'; } echo '
'; } else { echo '

Error: The AI returned an invalid workout structure. Here is the raw response:

' . htmlspecialchars($text) . '
'; } } else { echo '

Error generating workout. Details: ' . htmlspecialchars($resp['error'] ?? 'Unknown error') . '

'; } } ?>