noninjaml/lume-ai
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Architecture
The service now runs in two modes from the same image:
SERVICE_MODE=api: FastAPI app that enqueues indexing work and servesmatch-faceSERVICE_MODE=worker: background worker that claims photo batches from Postgres and indexes them
Queue state lives in the photo_index_tasks table. The SQL setup is in `sql/queue_schema.sql`.
Environment
Create your own API key for this service. It is not provided by Supabase or this repo.
Generate one locally:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"Copy the example env file and fill it in:
cp .env.example .envSUPABASE_URL: your Supabase project URLSUPABASE_SERVICE_KEY: service role key used by this backendSERVICE_MODE:apiorworkerLUME_API_KEY: shared secret required by the protected API routesFACE_MATCH_THRESHOLD: optional cosine similarity threshold, defaults to0.6INDEX_BATCH_SIZE: number of photos a worker claims at once, defaults to20TASK_LEASE_SECONDS: worker lease timeout for claimed tasks, defaults to1800WORKER_POLL_INTERVAL: idle sleep between worker polls, defaults to2WORKER_MAX_ATTEMPTS: retry limit before a task is marked failed, defaults to3
Queue Setup
Apply `sql/queue_schema.sql` to your Supabase Postgres database before starting workers. It creates:
photo_index_tasksclaim_photo_index_tasks(...)
Running
API mode:
SERVICE_MODE=api sh start.shWorker mode:
SERVICE_MODE=worker sh start.shScale indexing by running multiple worker containers with SERVICE_MODE=worker.
Calling The API
Queue a moment for indexing:
curl -X POST http://localhost:7860/moments/abc123/index \
-H "x-api-key: your-generated-secret"Check indexing status:
curl http://localhost:7860/moments/abc123/index-status \
-H "x-api-key: your-generated-secret"Legacy clients can still call:
curl -X POST http://localhost:7860/process-moment \
-H "Content-Type: application/json" \
-H "x-api-key: your-generated-secret" \
-d '{"moment_id":"abc123"}'For Hugging Face Spaces, store SUPABASE_URL, SUPABASE_SERVICE_KEY, and LUME_API_KEY in Space Secrets.
