Skip to content

tail-unica/PHaSEAPI

Repository files navigation

PHaSE-API - Food Recommendation System

PHaSE-API is a RESTful service that provides personalized food recommendations based on user preferences, restrictions, and other contextual information.

Getting Started

These instructions will help you set up and run the PHaSE-API on your local machine for development and testing purposes.

Prerequisites

  • 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.

Running with Docker

Build the Docker Image

# Clone the repository
git clone https://github.com/yourusername/PhaseAPI.git
cd PhaseAPI

# Build the Docker image
docker build -t phase-api:latest .

Running with Docker

# Run the container and map port 8100
docker run -p 8100:8100 phase-api:latest

GPU 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 GPU

The API will now be accessible at http://localhost:8100

API Documentation

Once the service is running, you can access the API documentation at:

Testing Endpoints via Command Line

You can test the API endpoints directly from the command line using tools like curl:

Get API Landing Page

curl http://localhost:8100/

Get Food Recommendation

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"
  }'

Get Info about Food Item

curl -X GET http://localhost:8100/food-info/onion \
  -H "Content-Type: application/json"

Get Alternative Food Items

curl -X POST http://localhost:8100/alternative \
  -H "Content-Type: application/json" \
  -d '{
    "food_item": "salmon"
  }'

Local Development (without Docker)

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages