📄 config.py 6,028 bytes Apr 19, 2026 📋 Raw

"""Configuration for Costco Route Optimizer."""

import os

---------------------------------------------------------------------------

LLM / Embedding endpoints (defaults for local Ollama on Gaming PC)

---------------------------------------------------------------------------

LLM_URL = os.environ.get(
"LLM_URL",
"http://localhost:11434/api/chat",
)
EMBED_URL = os.environ.get(
"EMBED_URL",
"http://localhost:11434/api/embeddings",
)
LLM_MODEL = os.environ.get("LLM_MODEL", "qwen2.5-coder:7b")
EMBED_MODEL = os.environ.get("EMBED_MODEL", "nomic-embed-text")

---------------------------------------------------------------------------

Headless browser (Browserless Docker container)

---------------------------------------------------------------------------

BROWSERLESS_URL = os.environ.get("BROWSERLESS_URL", "http://127.0.0.1:3000")

---------------------------------------------------------------------------

ChromaDB (learned item locations)

---------------------------------------------------------------------------

CHROMA_PATH = os.path.expanduser("~/.costco_route/chroma_db")
CHROMA_COLLECTION = "costco_items"

---------------------------------------------------------------------------

Costco Zone Map — standard 2026 counter-clockwise warehouse layout

---------------------------------------------------------------------------

ZONES = {
"01": {"name": "Electronics / Entrance", "aliases": ["electronics", "tech", "tv", "entrance"]},
"02": {"name": "Seasonal / Center", "aliases": ["seasonal", "clothing", "clothes", "toys", "holiday"]},
"03": {"name": "Health & Beauty", "aliases": ["health", "beauty", "pharmacy", "vitamins", "otc"]},
"04": {"name": "Pantry / Snacks", "aliases": ["pantry", "snacks", "dry goods", "canned", "coffee", "nuts"]},
"05": {"name": "Beverages", "aliases": ["beverages", "drinks", "water", "soda", "beer", "wine"]},
"06": {"name": "Dairy / Cold Room", "aliases": ["dairy", "cold", "milk", "eggs", "cheese", "butter"]},
"07": {"name": "Fresh / Bakery / Meat", "aliases": ["fresh", "bakery", "meat", "produce", "deli", "rotisserie"]},
"08": {"name": "Household / Cleaning", "aliases": ["household", "cleaning", "paper", "laundry", "detergent"]},
"09": {"name": "Freezer", "aliases": ["freezer", "frozen"]},
"10": {"name": "Checkout / Food Court", "aliases": ["checkout", "food court", "front"]},
}

Traversal order: entrance → exit (counter-clockwise U-shape)

ZONE_ORDER = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10"]

---------------------------------------------------------------------------

LLM prompt for zone classification

---------------------------------------------------------------------------

ZONE_CLASSIFY_PROMPT = """SYSTEM: You are a Costco Warehouse Logistics Expert.
Your goal is to categorize a shopping list into specific warehouse zones to minimize walking distance.

Each item must be assigned to exactly one zone. Use the zone that best matches where the item is typically found in a Costco warehouse.

ZONES:
01: Electronics / Entrance — TVs, laptops, batteries, jewelry, featured sale items
02: Seasonal / Center — Outdoor furniture, holiday decor, toys, clothing, books
03: Health & Beauty — Vitamins, shampoo, toothpaste, OTC meds, pharmacy items
04: Pantry / Snacks — Crackers, chips, nuts, coffee, canned goods, pasta, oil, spices, pet food
05: Beverages — Soda, water, juice, beer, wine, energy drinks
06: Dairy / Cold Room — Milk, eggs, butter, cheese, yogurt, refrigerated items
07: Fresh / Bakery / Meat — Produce, fruit, vegetables, rotisserie chicken, beef, poultry, bakery bread, deli
08: Household / Cleaning — Paper towels, toilet paper, laundry detergent, trash bags, cleaning supplies
09: Freezer — Frozen meals, frozen fruit, ice cream, frozen vegetables
10: Checkout / Food Court — Items typically grabbed at the front

RULES:
- Assign each item to the zone where it is PHYSICALLY LOCATED in the warehouse, not by category similarity
- Kirkland Signature items go where Costco stocks them, not where a grocery store would
- PRODUCE (fruit, vegetables, lettuce, tomatoes, etc.) → Zone 07 (Fresh/Bakery/Meat) — produce is in the back wall cooler
- CHEESE (including Kirkland cheddar, mozzarella, etc.) → Zone 06 (Dairy/Cold Room) — cheese is refrigerated
- BACON → Zone 06 (Dairy/Cold Room) — bacon is in the cold room, not at the meat counter
- STOCK/BROTH (chicken stock, beef broth, etc.) → Zone 04 (Pantry) — shelf-stable, center aisles
- Toilet paper, paper towels → Zone 08 (Household/Cleaning) — never checkout
- Pet food and treats → Zone 04 (pantry center aisles)
- Rotisserie chicken → Zone 07 (back of store)
- Batteries → Zone 01 (electronics near entrance)
- Vitamins/supplements → Zone 03 (health/beauty section)
- NEVER assign household essentials (toilet paper, paper towels, detergent) to Zone 10
- Zone 10 is ONLY for items grabbed at checkout (gift cards, snacks, food court items)
- Include ALL items from the list — do not drop any
- Do NOT add items that are not in the input list
- Return ONLY valid JSON: a mapping of zone ID to list of items

USER: Categorize these items into zones:
{items}

RESPONSE (JSON only, no markdown):"""

---------------------------------------------------------------------------

LLM prompt for item extraction from stream-of-consciousness

---------------------------------------------------------------------------

EXTRACT_PROMPT = """SYSTEM: You are a grocery list parser. Extract individual items from a stream-of-consciousness grocery list. Normalize spelling and brand names. Remove filler words.

RULES:
- Separate compound phrases into individual items
- Keep brand names (Kirkland, Organic, etc.)
- Normalize quantities if present but keep them with the item
- Remove conversational filler ("that cheese Aundrea likes" → "cheese")
- Return ONLY a JSON array of item strings

USER: {input}

RESPONSE (JSON array only):"""