Public Access
Matcher improvements (matcher.py): - Plural normalization: 'tortillas'→'tortilla', 'thighs'→'thigh' so subset recall check works without stemmer - Precision floor lowered 0.45→0.30: allows 'Bacon'→'Wright Brand Bacon' (1/3=0.33) while exclusion words still block category contaminants - _EXCLUSION_WORDS now normalized through same singularizer for consistency LLM second-pass (llm_matcher.py): - run_llm_match_job(): for each still-unmatched ingredient, collects top-12 candidates from grocery catalog ranked by fuzzy×precision (same metric as AUTO matcher), then asks Ollama to pick the best match - Candidate scoring: combined = (partial_token_sort_ratio/100) × precision ensures "McCormick Black Pepper" outranks "Dr Pepper" for 'Black Pepper' - Stores picks as source='auto_llm' (confidence=0.750) - Ollama Cloud endpoint: https://ollama.com/v1, model: kimi-k2.6:cloud Migration 0010: adds 'auto_llm' to ingredient_match_source_enum Config: OLLAMA_BASE_URL / OLLAMA_API_KEY / OLLAMA_MODEL settings Docker-compose: wires all three Ollama + Spoonacular env vars to backend/scheduler Scraper service: calls run_llm_match_job after run_match_job on every scrape Results: AUTO matcher went from 36→25 unmatched (plural normalization fix), LLM added 3 more (Black Pepper, Zucchini, Chicken Thighs). Remaining 22 are genuine Lucky CA catalog gaps (standalone olive oil, dried spices, etc. not in Swiftly weekly ad). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
from pydantic_settings import BaseSettings
|
|
from pydantic import model_validator
|
|
from typing import Optional
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# Required — fail fast at import time if unset.
|
|
DATABASE_URL: str = ""
|
|
|
|
SENDGRID_API_KEY: Optional[str] = None
|
|
SENDGRID_FROM_EMAIL: str = "peter@research.bike"
|
|
SENDGRID_REPLY_TO: str = "peter@research.bike"
|
|
EMAIL_BACKEND: str = "console"
|
|
LUCKY_CA_URL: str = "https://www.luckyncal.com"
|
|
# Swiftly product API (replaces Playwright path). The bearer JWT is
|
|
# auto-minted at request time via app.services.swiftly_auth.get_token().
|
|
LUCKY_STORE_ID: str = "757"
|
|
SWIFTLY_API_BASE: str = "https://prod.swiftlyapi.net"
|
|
SWIFTLY_CATEGORIES_URL: str = "https://luckysupermarkets.com/categories"
|
|
AI_IMAGE_ENABLED: bool = False
|
|
AI_IMAGE_PROVIDER: Optional[str] = None
|
|
AI_IMAGE_API_KEY: Optional[str] = None
|
|
LOG_LEVEL: str = "INFO"
|
|
SECRET_KEY: str = "dev-secret-key"
|
|
|
|
# Auth (R1-B+D)
|
|
ADMIN_TOKEN: str = ""
|
|
SESSION_PASSWORD: str = ""
|
|
ADMIN_EMAIL: str = ""
|
|
APP_BASE_URL: str = "http://localhost"
|
|
|
|
# Ollama Cloud LLM (used for ingredient→grocery LLM matching second pass)
|
|
OLLAMA_BASE_URL: str = "https://ollama.com/v1"
|
|
OLLAMA_API_KEY: Optional[str] = None
|
|
OLLAMA_MODEL: str = "kimi-k2.6:cloud"
|
|
|
|
FAMILY_EMAIL_1: Optional[str] = None
|
|
FAMILY_EMAIL_2: Optional[str] = None
|
|
RECIPES_EMAIL: Optional[str] = None
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
@model_validator(mode="after")
|
|
def _require_database_url(self) -> "Settings":
|
|
if not self.DATABASE_URL:
|
|
raise RuntimeError("DATABASE_URL is required")
|
|
return self
|
|
|
|
|
|
settings = Settings()
|