feat: cf-orch integration — CFOrchClient for recipe gen + Docuvision OCR fast-path #11

Closed
pyr0ball wants to merge 0 commits from feature/orch-auto-lifecycle into main
Owner

Summary

  • Recipe gen: replaces legacy VRAM lease calls with CFOrchClient.allocate(service="vllm", ...) when CF_ORCH_URL env is set; falls back to LLMRouter when not configured
  • DocuvisionClient: new thin client (app/services/ocr/docuvision_client.py) for the cf-docuvision vision service — sends base64-encoded images, returns DocuvisionResult
  • OCR fast-path: _try_docuvision() in vl_model.py runs before the local VLM; only accepts results with meaningful parsed content (items or merchant); degrades gracefully with DEBUG logging on any failure
  • missing_ingredients: now correctly subtracts pantry items from the LLM ingredient list before building the missing list

Test Plan

  • 70 tests passing (conda run -n cf pytest tests/ -v)
  • Set CF_ORCH_URL=http://heimdall:7700 in kiwi .env; verify recipe gen routes through cf-orch
  • Upload a receipt image; verify docuvision fast-path is attempted first (check DEBUG logs)
  • With CF_ORCH_URL unset, verify both paths fall back to local models
## Summary - **Recipe gen**: replaces legacy VRAM lease calls with `CFOrchClient.allocate(service="vllm", ...)` when `CF_ORCH_URL` env is set; falls back to `LLMRouter` when not configured - **DocuvisionClient**: new thin client (`app/services/ocr/docuvision_client.py`) for the `cf-docuvision` vision service — sends base64-encoded images, returns `DocuvisionResult` - **OCR fast-path**: `_try_docuvision()` in `vl_model.py` runs before the local VLM; only accepts results with meaningful parsed content (items or merchant); degrades gracefully with `DEBUG` logging on any failure - **`missing_ingredients`**: now correctly subtracts pantry items from the LLM ingredient list before building the missing list ## Test Plan - [ ] 70 tests passing (`conda run -n cf pytest tests/ -v`) - [ ] Set `CF_ORCH_URL=http://heimdall:7700` in kiwi `.env`; verify recipe gen routes through cf-orch - [ ] Upload a receipt image; verify docuvision fast-path is attempted first (check DEBUG logs) - [ ] With `CF_ORCH_URL` unset, verify both paths fall back to local models
pyr0ball added 3 commits 2026-04-02 22:13:03 -07:00
- Assembly template system (13 templates: burrito, fried rice, omelette, stir fry,
  pasta, sandwich, grain bowl, soup/stew, casserole, pancakes, porridge, pie, pudding)
  with role-based matching, whole-word single-keyword guard, deterministic titles
  via MD5 pantry hash
- Prep-state stripping: strips 'melted butter' → 'butter' for coverage checks;
  reconstructs actionable states as 'Before you start:' cooking instructions
  (NutritionPanel prep_notes field + RecipesView.vue display block)
- FTS5 fixes: always double-quote all terms; strip apostrophes to prevent
  syntax errors on brands like "Stouffer's"; 'plant-based' → bare 'based' crash
- Bidirectional synonym expansion: alt-meat, alt-chicken, alt-beef, alt-pork
  mapped to canonical texture class; pantry expansion covers 'hamburger' from
  'burger patties' etc.
- Texture profile backfill script (378K ingredient_profiles rows) with macro-derived
  classification in priority order (fatty → creamy → starchy → firm → fibrous →
  tender → liquid → neutral); oats/legumes starchy-first fix
- LLM prompt: ban flavoured/sweetened ingredients (vanilla yoghurt) from savoury
- Migrations 014 (nutrition macros) + 015 (recipe FTS index)
- Nutrition estimation pipeline script
- gitignore MagicMock sqlite test artifacts
- Style/category filter panel with active chip display
- Dismiss (excluded_ids) support — recipes don't reappear until next fresh search
- Load more appends next batch without full re-fetch
- Prep notes 'Before you start:' section above directions
- Nutrition macro chips (kcal, fat, protein, carbs, fiber, sugar, sodium)
- Composables extracted for reuse
pyr0ball added 1 commit 2026-04-02 22:57:29 -07:00
- compose.override.yml: cf-orch agent sidecar (port 7702) self-registers with
  coordinator at COORDINATOR_URL; advertise-host configurable via CF_ORCH_ADVERTISE_HOST
- scheduler.py: pass coordinator_url=settings.COORDINATOR_URL and service_name="kiwi"
  so VRAM leases appear as "kiwi" on the orchestrator dashboard
- environment.yml: add psutil>=5.9 (required by cf-orch agent eviction executor)
- .env.example: document CF_ORCH_ADVERTISE_HOST
pyr0ball closed this pull request 2026-04-02 23:08:21 -07:00

Pull request closed

Sign in to join this conversation.
No description provided.