A FastAPI-based application that uses OpenAI's GPT-4 model to generate personalized workout routines based on user goals and experience levels.
Juan Carlo Reforme Sueyoshi
- Generates workout routines tailored to user goals (e.g., weight loss, strength training).
- Supports different experience levels (e.g., beginner, intermediate, advanced).
- Leverages OpenAI's GPT-4 model for intelligent and detailed responses.
- Get exercise from a Database (e.g., Pierna, Abdomen, Pecho)
- Python 3.8 or higher
- OpenAI Python library (
openai
) - FastAPI (
fastapi
) - Uvicorn (
uvicorn
)
- Clone the repository:
git clone https://github.com/your-username/routine-generator.git
cd routine-generator
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the required dependencies:
pip install -r requirements.txt
- Set your OpenAI API key as an environment variable: bash export OPENAI_API_KEY=your_openai_api_key Or replace your_openai_api_key directly in the code.
Usage
- Start the FastAPI server:
uvicorn routine_generator:app --reload
- Access the API documentation at:
http://127.0.0.1:8000/docs
- Use the /generate-routine endpoint to generate a workout routine. Example request:
{
"goal": "weight loss",
"experience": "beginner"
}
Example Response
{
"goal": "weight loss",
"experience": "beginner",
"routine": "1. Warm-up: 5 minutes of light jogging...\n2. Strength training: 3 sets of squats..."
}
Project Structure routine-generator/ ├── routine_generator.py # Main application code ├── requirements.txt # Python dependencies └── README.md # Project documentation
Dependencies OpenAI Python Library FastAPI Uvicorn License This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments OpenAI for providing the GPT-4 model. FastAPI for the web framework.