vital-ai is a Django-based project that integrates with OpenAI to provide personalized health advice to users based on their Apple Health data. The platform generates recommendations for users based on their sleep patterns, physical activity, and other health metrics. The project uses OpenAI's GPT models to generate these personalized responses, and it features an API that allows users to access health advice in real-time.
- Health Data Insights: Users' Apple Health data is analyzed to provide insights and advice.
- OpenAI Integration: GPT-3.5 or GPT-4 models are used to generate personalized health suggestions.
- Django API: The project exposes an API that provides users with personalized advice based on their health metrics.
- Custom Commands: The project includes custom Django commands to generate random user health data.
To get started, clone the repository to your local machine using the following command:
git clone https://github.com/your-username/vital-ai.git
Navigate into the project directory:
cd vital-ai
Install Python dependencies using pip. It is recommended to create a virtual environment first:
python -m venv env #or your ways of creating virtual environment
# Activate the virtual environment
# For macOS/Linux:
source env/bin/activate
# For Windows:
.\env\Scripts\activate
# Install the required dependencies
pip install -r requirements.txt
Set up your environment variables in a .env file at the root of the project:
touch .env
Inside your .env file, add the following:
OPENAI_API_KEY=your-openai-api-key
Before running the project, apply the necessary database migrations:
python manage.py migrate
You can generate random user health data using the custom management command:
python manage.py generate_random_data
This will create random Apple Health data for users, which can then be used for testing the API.
Once everything is set up, run the Django development server:
python manage.py runserver
The server will start at http://127.0.0.1:8000/.
The project provides several API endpoints to retrieve user-specific health advice based on their Apple Health data.
This endpoint returns advice for users who have walked more than 10,000 steps today.
Request:
GET http://127.0.0.1:8000/api/steps-condition-1/
Response
{
"user": "john_doe",
"ai_response": "Wow, that's an outstanding hike in your physical activity compared to yesterday! It's great to see you active, but it's also important to listen to your body. ..."
}
This endpoint returns advice for users who have had less than 6 hours of sleep in the past week.
Request:
GET http://127.0.0.1:8000/api/sleep-condition/
Response:
{
"user": "jane_doe",
"ai_response": "It looks like you haven't been getting enough sleep recently. Prioritizing your rest is important for your overall health. Aim for at least 7-8 hours of sleep every night. ..."
}