PHaSE-API is a RESTful service that provides personalized food recommendations based on user preferences, restrictions, and other contextual information.
These instructions will help you set up and run the PHaSE-API on your local machine for development and testing purposes.
- Docker installed on your system
- Pretrained Weights and Dataset downloaded and placed at the root of the project directory. It includes two folders:
checkpoint: Contains the pretrained model weights, the preprocessed dataset, and the tokenizer.data: Contains the dataset used to retrieve food information.
# Clone the repository
git clone https://github.com/yourusername/PhaseAPI.git
cd PhaseAPI
# Build the Docker image
docker build -t phase-api:latest .# Run the container and map port 8100
docker run -p 8100:8100 phase-api:latestGPU support is enabled by default, enabled by using the following command (if it doesn't work, ensure you have the NVIDIA Container Toolkit installed):
docker run --gpus all -p 8100:8100 phase-api:latest
docker run --gpus '"device=1"' -p 8100:8100 phase-api:latest # to use a specific GPUThe API will now be accessible at http://localhost:8100
Once the service is running, you can access the API documentation at:
- Swagger UI: http://localhost:8100/docs
- ReDoc: http://localhost:8100/redoc
- OpenAPI Schema: http://localhost:8100/openapi.json
You can test the API endpoints directly from the command line using tools like curl:
curl http://localhost:8100/curl -X POST http://localhost:8100/recommend \
-H "Content-Type: application/json" \
-d '{
"user_id": 12345,
"preferences": ["pasta", "Italian cuisine", "tomatoes"],
"soft_restrictions": ["seafood", "spicy"],
"hard_restrictions": ["peanuts", "shellfish"],
"meal_time": "dinner",
"previous_recommendations": ["spaghetti carbonara"],
"recommendation_count": 3,
"diversity_factor": 0.7,
"conversation_id": "conv_2025032012345"
}'curl -X GET http://localhost:8100/food-info/onion \
-H "Content-Type: application/json"curl -X POST http://localhost:8100/alternative \
-H "Content-Type: application/json" \
-d '{
"food_item": "salmon"
}'Requires uv
# Install dependencies using uv, automatically creating a virtual environment
uv sync
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Run the application
uv run uvicorn src.app.main:app --reload --host 0.0.0.0 --port 8100