← back to Enrich Local Hybrid

DEPLOY.md

50 lines

# enrich-ai-tags → local hybrid (build + you-deploy)

**What:** swaps DW image enrichment from paid Gemini to a HYBRID local pipeline —
exact hex+% from real pixels (Pillow, ground-truth, beats Gemini) + qwen2.5vl on
Mac1 (via Tailscale from Kamatera) for color names / styles / patterns / material /
imageType / dims / description. Same `aiData` output contract; ~$0.

**Safety:** `ENRICH_PROVIDER` defaults to `gemini`, so dropping the files changes
nothing until you set the env. Any local failure auto-falls-back to Gemini. Verified:
Kamatera (100.107.67.67) reaches Mac1 Ollama (100.94.103.98:11434, qwen2.5vl present).

## Files
- `enrich-palette.py`     — Pillow ground-truth palette (exact hex + %)
- `enrich-local.js`       — hybrid analyzer, exports localAnalyze() (geminiAnalyze shape)
- `enrich-ai-tags.patched.js` — prod script + analyze() dispatcher (off by default)

## Deploy (run from Mac2)
```bash
# 1. Back up the live prod script
ssh my-server 'cp /root/DW-Agents/vendor-scrapers/enrich-ai-tags.js /root/DW-Agents/vendor-scrapers/enrich-ai-tags.js.bak-gemini-$(date +%Y%m%d)'

# 2. Copy the 3 files up; swap the patched main into place
scp enrich-local.js enrich-palette.py enrich-ai-tags.patched.js my-server:/root/DW-Agents/vendor-scrapers/
ssh my-server 'cd /root/DW-Agents/vendor-scrapers && mv enrich-ai-tags.patched.js enrich-ai-tags.js'

# 3. DRY-RUN with local provider (NO DB writes) — proves Kamatera→Mac1 + quality
ssh my-server 'cd /root/DW-Agents/vendor-scrapers && ENRICH_PROVIDER=local node enrich-ai-tags.js thibaut --dry-run --limit 3'
```

## GO LIVE (the gated step — only after the dry-run looks good)
The nightly enrichment is NOT `node enrich-ai-tags.js` directly — it's three Phase-3
crons (tier 1/2/3 @ 9/10/11 UTC ≈ 2-4am PT) running `full-monte-batch.js --phase 3`,
which SPAWNS `enrich-ai-tags.js` with `env: {...process.env}`. All three source
`/root/DW-Agents/full-monte/.env`, so the entire go-live is ONE line in that file:
```bash
ssh my-server 'grep -q "^ENRICH_PROVIDER=" /root/DW-Agents/full-monte/.env || echo "ENRICH_PROVIDER=local" >> /root/DW-Agents/full-monte/.env'
```
Takes effect next Phase-3 run (cron re-sources .env each run; no restart). Covers all tiers.

**Rollback (instant):**
```bash
ssh my-server "sed -i '/^ENRICH_PROVIDER=/d' /root/DW-Agents/full-monte/.env"
```
Or restore `enrich-ai-tags.js.bak-gemini-*`. Per-image Gemini fallback also auto-covers any local outage.

## Env knobs
- `ENRICH_PROVIDER` = local | hybrid | gemini (default gemini)
- `ENRICH_OLLAMA_URL` = http://100.94.103.98:11434 (Mac1 tailnet; default)
- `ENRICH_VL_MODEL`   = qwen2.5vl:7b (default)