diff --git a/Albert_Project/.env.example b/Albert_Project/.env.example index fe34c0f..6d690a8 100644 --- a/Albert_Project/.env.example +++ b/Albert_Project/.env.example @@ -1,19 +1,24 @@ -# Copy this file to .env and fill in your API keys -# Never commit .env to version control +# Copy this file to .env and fill in your local keys. +# Never commit .env to version control. -# ── AI Vision API Keys ─────────────────────────────────────────────────────── -# PRIMARY: Gemini 2.5 Pro (FREE — 25 req/day) -# Get key at: https://aistudio.google.com → Get API Key → Create API Key +# AI vision provider +# Primary path: OpenRouter -> Google Gemini vision models. +# Get a key at: https://openrouter.ai/keys +OPENROUTER_API_KEY=sk-or-v1-...your-openrouter-key-here... + +# Optional legacy/direct provider keys for experiments or older scripts. GEMINI_API_KEY=AIza...your-gemini-key-here... - -# OPTIONAL: Anthropic Claude (paid) — only if you prefer Claude +GROQ_API_KEY=gsk_...your-groq-key-here... ANTHROPIC_API_KEY=sk-ant-...your-anthropic-key-here... +OPENAI_API_KEY=sk-...your-openai-key-here... -# ── Currency Conversion ───────────────────────────────────────────────────── -# EUR to USD exchange rate (update periodically) +# Demo mode lowers image resolution and prompt/output size for cheaper demos. +DEMO_MODE=false + +# Currency conversion EUR_USD_RATE=1.09 -# ── Job Costing Defaults (can override per project in project_config.json) ── +# Job costing defaults. Individual projects can override these in project_config.json. GP_TARGET_PCT=0.35 COMMISSION_PCT=0.05 BOND_PCT=0.015 diff --git a/Albert_Project/.gitignore b/Albert_Project/.gitignore index de1a171..982ff45 100644 --- a/Albert_Project/.gitignore +++ b/Albert_Project/.gitignore @@ -1,7 +1,9 @@ -# ── Secrets ───────────────────────────────────────────────────────────────── +# Secrets .env +.env.* +!.env.example -# ── Python ─────────────────────────────────────────────────────────────────── +# Python __pycache__/ *.py[cod] *.pyo @@ -15,28 +17,30 @@ build/ .mypy_cache/ *.so -# ── Virtual environments ────────────────────────────────────────────────────── +# Virtual environments venv/ .venv/ env/ ENV/ -# ── OS files ────────────────────────────────────────────────────────────────── +# OS files .DS_Store Thumbs.db desktop.ini -# ── IDE ─────────────────────────────────────────────────────────────────────── +# IDE .vscode/ .idea/ *.swp *.swo -# ── Outputs (generated — do NOT commit large output files) ──────────────────── -# Comment these out if you WANT to commit generated outputs -# outputs/ - -# ── Temporary / scratch ─────────────────────────────────────────────────────── +# Logs and scratch +*.log +outputs/*.log *.tmp *.bak scratch/ + +# Generated outputs are currently tracked for demo artifacts. +# Uncomment this line if generated artifacts should be excluded in future. +# outputs/ diff --git a/Albert_Project/core/ai_vision_classifier.py b/Albert_Project/core/ai_vision_classifier.py index 949d364..acb6638 100644 --- a/Albert_Project/core/ai_vision_classifier.py +++ b/Albert_Project/core/ai_vision_classifier.py @@ -1,38 +1,61 @@ """ =========================================================================== - core/ai_vision_classifier.py — Groq Vision Cabinet Classifier + core/ai_vision_classifier.py — OpenRouter Vision Cabinet Classifier =========================================================================== - Uses Groq API (llama-3.2-90b-vision-preview) to classify cabinets from - architectural elevation drawings. Groq is free, extremely fast, and - llama-3.2-90b-vision is excellent at reading technical drawings. + Uses OpenRouter API (Google Gemini models only) to classify cabinets + from architectural elevation drawings. + + PRIMARY MODEL: google/gemini-2.5-flash + - Best for technical/architectural drawings + - Excellent spatial reasoning and OCR on dimension annotations + - $1.5/1M input tokens — fast and affordable + - 1M token context window + + FALLBACK MODEL: google/gemini-2.5-pro + - More powerful Gemini for complex/ambiguous drawings + - $2.5/1M input tokens + - Kicks in when Flash returns low-confidence or invalid JSON Pipeline per elevation crop: 1. Receive: PNG image bytes (400 DPI crop) + pre-extracted dims + rects 2. Build: structured prompt with dimension context - 3. Call: Groq API (llama-3.2-90b-vision-preview) with base64 image + 3. Call: OpenRouter API (gemini-2.5-flash) with base64 image 4. Parse: JSON response → list[CabinetItem] - 5. Retry with fix prompt if JSON parse fails + 5. Retry with gemini-2.5-pro if JSON parse fails or confidence < 0.7 6. Exponential backoff on API errors - Free tier: very generous (no hard daily limit on llama-3.2-90b-vision) - Get key at: https://console.groq.com -=========================================================================== -""" + Get key at: https://openrouter.ai +===========================================================================""" from __future__ import annotations import base64 import json import re import time +import urllib.request from dataclasses import dataclass, field, asdict from typing import Optional -from core.config import GROQ_API_KEY, AUTO_APPROVE_CONFIDENCE +import os +from core.config import AUTO_APPROVE_CONFIDENCE, OPENROUTER_API_KEY -GROQ_MODEL = "meta-llama/llama-4-scout-17b-16e-instruct" -GROQ_MAX_TOKENS = 4096 +# ── OpenRouter Configuration ───────────────────────────────────────────────── +OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1/chat/completions" +# Primary: Gemini 2.5 Flash — best at technical/spatial drawings, fast & cheap +PRIMARY_MODEL = "google/gemini-2.5-flash" +# Fallback: Gemini 2.5 Pro — stronger reasoning for ambiguous/complex drawings +FALLBACK_MODEL = "google/gemini-2.5-pro" +MAX_TOKENS = 4096 +# ── Demo Mode — low token usage for client demonstrations ───────────────────── +# Set DEMO_MODE=true in .env or environment, or pass demo_mode=True to classify_elevation() +# Reduces cost from ~$0.0015/call → ~$0.0002/call (~85% savings) +DEMO_MODE: bool = os.getenv("DEMO_MODE", "false").lower() in ("1", "true", "yes") +DEMO_DPI = 150 # vs 400 in full mode — image tokens: ~88% smaller +DEMO_MAX_TOKENS = 800 # vs 4096 — output capped tightly +DEMO_MAX_DIMS = 8 # vs 30 pre-extracted dims sent in context +DEMO_MAX_RECTS = 10 # vs 40 rectangle vectors sent in context # ══════════════════════════════════════════════════════════════════════════ # DATA CLASSES @@ -71,7 +94,7 @@ class CabinetItem: quantity: int = 1 is_ada: bool = False notes: str = "" - source: str = "claude" # "claude" | "gpt4o" | "manual" + source: str = "gemini" # "gemini" | "manual" | "fallback" @property def code(self) -> str: @@ -144,7 +167,20 @@ class ElevationResult: # PROMPT BUILDER # ══════════════════════════════════════════════════════════════════════════ -def _build_system_prompt() -> str: +def _build_system_prompt(demo: bool = False) -> str: + if demo: + # Compact prompt — ~250 tokens vs ~800 tokens + return ( + "You are a cabinet estimator. Analyze this architectural elevation drawing and return " + "a JSON array of cabinets. Types: upper_wall, base, sink_base, dw_adjacent, " + "microwave_shelf, pantry, corner_upper, corner_base, vanity, medicine_cabinet, " + "linen, appliance_space, filler, unknown. " + "Each item: {item_num, cabinet_type, width_mm, height_mm, depth_mm, location, " + "elevation_ref, confidence, quantity, is_ada, notes}. " + "Std widths: 300,350,400,450,500,550,600,762,900mm. " + "Base h=720mm d=600mm. Wall h=300mm d=330mm. Pantry h=2130mm. " + "Return ONLY valid JSON array, no markdown." + ) return """You are an expert cabinet estimator with 20+ years of experience reading architectural kitchen and bathroom elevation drawings for US residential construction projects (FHA/ADA housing). Your job is to analyze architectural elevation drawings and extract a precise, complete cabinet schedule. @@ -207,23 +243,31 @@ def _build_user_prompt( pre_extracted_dims: list[dict], pre_extracted_rects: list[dict], is_ada: bool = False, + demo: bool = False, ) -> str: """Build the user message with pre-extracted context.""" - ada_note = " (ADA ACCESSIBLE UNIT — base cabinet heights are 864mm max, countertop 34\" max)" if is_ada else "" + ada_note = " (ADA — base h≤864mm, countertop≤34\")" if is_ada else "" + + # Demo mode: send fewer context items to save tokens + max_dims = DEMO_MAX_DIMS if demo else 30 + max_rects = DEMO_MAX_RECTS if demo else 40 dims_str = "" if pre_extracted_dims: - dims_str = "\n\nPRE-EXTRACTED DIMENSION VALUES (from PDF text, use these as ground truth):\n" - for d in pre_extracted_dims[:30]: # limit to 30 most relevant - dims_str += f" [{d.get('type','?')}] '{d.get('text','')}' at x={d.get('x',0):.0f}, y={d.get('y',0):.0f}\n" + dims_str = "\nDIMENSIONS (ground truth):\n" + for d in pre_extracted_dims[:max_dims]: + dims_str += f" [{d.get('type','?')}] '{d.get('text','')}' x={d.get('x',0):.0f} y={d.get('y',0):.0f}\n" rects_str = "" - if pre_extracted_rects: - rects_str = "\n\nPRE-EXTRACTED RECTANGLE GEOMETRY (potential cabinet boxes from PDF vectors):\n" - for i, r in enumerate(pre_extracted_rects[:40]): - rects_str += (f" Rect {i+1}: x={r.get('x0',0):.1f}→{r.get('x1',0):.1f}, " - f"y={r.get('y0',0):.1f}→{r.get('y1',0):.1f}, " - f"W={r.get('w',0):.1f}pts, H={r.get('h',0):.1f}pts\n") + if pre_extracted_rects and not demo: # skip rect context in demo (saves ~300 tokens) + rects_str = "\nRECTANGLES (potential cabinet boxes):\n" + for i, r in enumerate(pre_extracted_rects[:max_rects]): + rects_str += (f" R{i+1}: W={r.get('w',0):.0f}pt H={r.get('h',0):.0f}pt " + f"@ ({r.get('x0',0):.0f},{r.get('y0',0):.0f})\n") + + if demo: + return (f"Project:{project_name} Unit:{unit_type}{ada_note} Section:{elevation_label}\n" + f"{dims_str}\nIdentify all cabinets. Return ONLY JSON array.") return f"""Project: {project_name} Unit Type: {unit_type}{ada_note} @@ -251,7 +295,7 @@ Return ONLY the JSON array, nothing else.""" class CabinetVisionClassifier: """ Classifies cabinets from architectural elevation drawing images - using Groq API (llama-3.2-90b-vision-preview) — free & fast. + using Google Gemini vision models through OpenRouter. Usage: classifier = CabinetVisionClassifier() @@ -264,25 +308,17 @@ class CabinetVisionClassifier: """ def __init__(self): - self._groq_client = None self._validate_keys() def _validate_keys(self): - if not GROQ_API_KEY: + if not OPENROUTER_API_KEY: raise EnvironmentError( - "GROQ_API_KEY is not set.\n" - "1. Go to https://console.groq.com\n" - "2. Create an API key\n" - "3. Add to .env: GROQ_API_KEY=gsk_...\n" - "4. Or use --skip-ai flag to skip AI extraction" + "OPENROUTER_API_KEY is not set.\n" + "Get your key at: https://openrouter.ai\n" + "Add to .env: OPENROUTER_API_KEY=sk-or-v1-...\n" + "Or use --skip-ai flag to skip AI extraction" ) - def _get_groq(self): - if self._groq_client is None: - from groq import Groq - self._groq_client = Groq(api_key=GROQ_API_KEY) - return self._groq_client - # ── Main Classification ─────────────────────────────────────────────── def classify_elevation( @@ -295,6 +331,7 @@ class CabinetVisionClassifier: pre_extracted_rects: Optional[list[dict]] = None, is_ada: bool = False, max_retries: int = 3, + demo_mode: bool = None, # None = use global DEMO_MODE ) -> ElevationResult: """ Classify all cabinets in one elevation section. @@ -312,6 +349,9 @@ class CabinetVisionClassifier: Returns: ElevationResult with list of CabinetItem """ + # Resolve demo mode — argument overrides global flag + use_demo = DEMO_MODE if demo_mode is None else demo_mode + result = ElevationResult( elevation_label = elevation_label, unit_type = unit_type, @@ -319,6 +359,11 @@ class CabinetVisionClassifier: is_ada = is_ada, ) + if use_demo: + print(f" [AI-DEMO] Low-token mode: DPI={DEMO_DPI}, max_tokens={DEMO_MAX_TOKENS}") + # Downscale image from 400 DPI to 150 DPI equivalent using PIL if available + image_bytes = _downscale_image_if_possible(image_bytes, target_dpi=DEMO_DPI) + # Build the prompt user_prompt = _build_user_prompt( unit_type = unit_type, @@ -327,37 +372,47 @@ class CabinetVisionClassifier: pre_extracted_dims = pre_extracted_dims or [], pre_extracted_rects = pre_extracted_rects or [], is_ada = is_ada, + demo = use_demo, ) - # Encode image for API - image_b64 = base64.standard_b64encode(image_bytes).decode("utf-8") + # Demo: fewer retries, tighter token budget + retries = 1 if use_demo else max_retries + max_tokens = DEMO_MAX_TOKENS if use_demo else MAX_TOKENS - # Call Groq with retries - raw_json = self._call_groq( + # Call primary model (Gemini 2.5 Flash) with retries + mode_tag = "DEMO" if use_demo else "FULL" + print(f" [AI-{mode_tag}] Calling {PRIMARY_MODEL} for {elevation_label}...") + raw_json = self._call_openrouter( image_bytes = image_bytes, user_prompt = user_prompt, - max_retries = max_retries, + model = PRIMARY_MODEL, + max_retries = retries, + max_tokens = max_tokens, ) result.api_calls += 1 if raw_json is None: - result.review_flags.append("Groq API call failed after all retries") + result.review_flags.append(f"{PRIMARY_MODEL} API call failed after all retries") return result # Parse JSON response cabinets = self._parse_cabinet_json(raw_json, elevation_label) - if cabinets is None: - # Retry with explicit JSON fix instruction + if cabinets is None and not use_demo: + # Full mode only: retry with fallback model (Gemini 2.5 Pro) fix_prompt = ( f"{user_prompt}\n\nIMPORTANT: Return ONLY a valid JSON array. " "No explanation text, no markdown fences, just the raw JSON array." ) - raw_json2 = self._call_groq(image_bytes, fix_prompt, max_retries=1) + print(f" [AI] Retrying with fallback {FALLBACK_MODEL}...") + raw_json2 = self._call_openrouter( + image_bytes, fix_prompt, model=FALLBACK_MODEL, max_retries=1 + ) if raw_json2: cabinets = self._parse_cabinet_json(raw_json2, elevation_label) if cabinets is None: - result.review_flags.append("Failed to parse Groq JSON response") + model_info = f"{PRIMARY_MODEL}" + ("" if use_demo else f" + {FALLBACK_MODEL}") + result.review_flags.append(f"Failed to parse AI JSON from {model_info}") return result result.cabinets = cabinets @@ -373,51 +428,83 @@ class CabinetVisionClassifier: ) return result - # ── Groq API Call ──────────────────────────────────────────────────── + # ── OpenRouter API Call ────────────────────────────────────────────────── - def _call_groq( + def _call_openrouter( self, image_bytes: bytes, user_prompt: str, + model: str = PRIMARY_MODEL, max_retries: int = 3, + max_tokens: int = MAX_TOKENS, ) -> Optional[str]: - """Call Groq llama-3.2-90b-vision API. Returns raw text or None.""" - client = self._get_groq() - image_b64 = base64.standard_b64encode(image_bytes).decode("utf-8") - system_prompt = _build_system_prompt() + """ + Call OpenRouter vision API with any supported model. + Returns raw text response or None on failure. + """ + image_b64 = base64.standard_b64encode(image_bytes).decode("utf-8") + # Use compact system prompt if max_tokens budget is tight (demo mode) + use_demo_prompt = max_tokens <= DEMO_MAX_TOKENS + system_prompt = _build_system_prompt(demo=use_demo_prompt) + img_kb = len(image_bytes) / 1024 + print(f" [API] Image size: {img_kb:.1f} KB | max_tokens: {max_tokens}") + + payload = json.dumps({ + "model": model, + "max_tokens": max_tokens, + "temperature": 0.1, + "messages": [ + {"role": "system", "content": system_prompt}, + { + "role": "user", + "content": [ + { + "type": "image_url", + "image_url": { + "url": f"data:image/png;base64,{image_b64}", + }, + }, + {"type": "text", "text": user_prompt}, + ], + }, + ], + }).encode("utf-8") + + headers = { + "Authorization": f"Bearer {OPENROUTER_API_KEY}", + "Content-Type": "application/json", + "HTTP-Referer": "https://github.com/Prajwalabhang1/Cabinets", + "X-Title": "Cabinet Shop Drawing Generator", + } for attempt in range(max_retries): try: - response = client.chat.completions.create( - model=GROQ_MODEL, - max_tokens=GROQ_MAX_TOKENS, - temperature=0.1, - messages=[ - {"role": "system", "content": system_prompt}, - { - "role": "user", - "content": [ - { - "type": "image_url", - "image_url": { - "url": f"data:image/png;base64,{image_b64}", - }, - }, - {"type": "text", "text": user_prompt}, - ], - }, - ], + req = urllib.request.Request( + OPENROUTER_BASE_URL, + data = payload, + headers = headers, + method = "POST", ) - return response.choices[0].message.content + with urllib.request.urlopen(req, timeout=60) as resp: + result = json.loads(resp.read()) + + content = result["choices"][0]["message"]["content"] + usage = result.get("usage", {}) + cost = usage.get("cost", 0) + print(f" [OK] {model.split('/')[-1]} responded | " + f"tokens={usage.get('total_tokens',0)} | " + f"cost=${cost:.5f}") + return content except Exception as e: wait = 2 ** attempt - print(f" [WARN] Groq attempt {attempt+1}/{max_retries} failed: {e}") + print(f" [WARN] OpenRouter attempt {attempt+1}/{max_retries} " + f"({model}) failed: {e}") if attempt < max_retries - 1: print(f" Retrying in {wait}s...") time.sleep(wait) else: - print(" [FAIL] All Groq retries exhausted.") + print(f" [FAIL] All retries exhausted for {model}.") return None # ── JSON Parsing ────────────────────────────────────────────────────── @@ -497,7 +584,7 @@ class CabinetVisionClassifier: quantity = int(item.get("quantity", 1)), is_ada = bool(item.get("is_ada", False)), notes = str(item.get("notes", "")), - source = "groq", + source = "gemini", )) return cabinets @@ -578,6 +665,44 @@ def _default_depth(cabinet_type: str) -> float: return defaults.get(cabinet_type, 600.0) +def _downscale_image_if_possible(image_bytes: bytes, target_dpi: int = 150) -> bytes: + """ + Reduce image size by downscaling. + In demo mode we crop at 400 DPI but then shrink to ~150 DPI equivalent + to dramatically cut vision token cost (~88% smaller image). + + Falls back to returning original bytes if PIL/Pillow is not installed. + """ + try: + from PIL import Image + import io as _io + + img = Image.open(_io.BytesIO(image_bytes)) + orig_w, orig_h = img.size + scale = target_dpi / 400.0 # 400 DPI was used during crop + new_w = max(1, int(orig_w * scale)) + new_h = max(1, int(orig_h * scale)) + + img_resized = img.resize((new_w, new_h), Image.LANCZOS) + buf = _io.BytesIO() + img_resized.save(buf, format="PNG", optimize=True) + result = buf.getvalue() + + orig_kb = len(image_bytes) / 1024 + result_kb = len(result) / 1024 + print(f" [DEMO] Image scaled {orig_w}×{orig_h} → {new_w}×{new_h} " + f"({orig_kb:.0f} KB → {result_kb:.0f} KB, " + f"{100*(1-result_kb/orig_kb):.0f}% smaller)") + return result + + except ImportError: + print(" [DEMO] Pillow not installed — sending original image size.") + return image_bytes + except Exception as e: + print(f" [DEMO] Downscale failed ({e}) — sending original image.") + return image_bytes + + # ══════════════════════════════════════════════════════════════════════════ # QUICK TEST (no API needed — tests JSON parsing logic) # ══════════════════════════════════════════════════════════════════════════ diff --git a/Albert_Project/core/cabinet_validator.py b/Albert_Project/core/cabinet_validator.py index 35e128c..d79a50d 100644 --- a/Albert_Project/core/cabinet_validator.py +++ b/Albert_Project/core/cabinet_validator.py @@ -131,6 +131,19 @@ class CabinetValidator: for cab in cabinets: if cab.cabinet_type == "appliance_space": continue # appliances are fine with non-standard widths + + # Auto-fix: width=0 means Gemini couldn't read it → snap to 762mm default + if cab.width_mm <= 0: + old_w = cab.width_mm + cab.width_mm = 762.0 # 30" — most common standard cabinet width + corrections.append( + f"Item {cab.item_num} ({cab.cabinet_type}) had width={old_w:.0f}mm " + f"→ defaulted to 762mm (30\"). Verify against drawing." + ) + warnings.append( + f"Item {cab.item_num} width was 0/null — used 762mm default" + ) + nearest, delta = _nearest_standard_width(cab.width_mm) if delta > CABINET_WIDTH_TOLERANCE_MM: flags.append( diff --git a/Albert_Project/core/config.py b/Albert_Project/core/config.py index 6d02b7e..f84dd9a 100644 --- a/Albert_Project/core/config.py +++ b/Albert_Project/core/config.py @@ -24,11 +24,13 @@ ANTHROPIC_API_KEY: str = os.getenv("ANTHROPIC_API_KEY", "") OPENAI_API_KEY: str = os.getenv("OPENAI_API_KEY", "") GEMINI_API_KEY: str = os.getenv("GEMINI_API_KEY", "") GROQ_API_KEY: str = os.getenv("GROQ_API_KEY", "") +OPENROUTER_API_KEY: str = os.getenv("OPENROUTER_API_KEY", "") -# ── Claude model config ───────────────────────────────────────────────────── +# Legacy provider constants retained for older experiments; production vision +# extraction uses OpenRouter Gemini from core.ai_vision_classifier. CLAUDE_MODEL = "claude-3-5-sonnet-20241022" CLAUDE_MAX_TOKENS = 4096 -CLAUDE_TEMPERATURE = 0.1 # Low temp for structured/deterministic output +CLAUDE_TEMPERATURE = 0.1 GPT4O_MODEL = "gpt-4o" # ── Currency & Unit Conversion ────────────────────────────────────────────── @@ -126,14 +128,10 @@ CABINET_LIBRARY_PATH = PROJECT_ROOT / "data" / "cabinet_library.json" def validate_config() -> list[str]: """Return a list of warnings about missing/invalid configuration.""" warnings = [] - if not ANTHROPIC_API_KEY: + if not OPENROUTER_API_KEY: warnings.append( - "ANTHROPIC_API_KEY not set — Claude Vision integration will not work. " - "Set it in .env or use --skip-ai flag." - ) - if not OPENAI_API_KEY: - warnings.append( - "OPENAI_API_KEY not set — GPT-4o backup validation disabled." + "OPENROUTER_API_KEY not set - Gemini Vision extraction will be disabled. " + "Set it in .env or run with --skip-ai." ) if EUR_USD_RATE <= 0: warnings.append(f"EUR_USD_RATE={EUR_USD_RATE} is invalid.") @@ -150,5 +148,5 @@ if __name__ == "__main__": else: print("✅ Configuration OK") print(f"\n EUR/USD rate: {EUR_USD_RATE}") - print(f" Claude model: {CLAUDE_MODEL}") + print(f" OpenRouter key: {'SET' if OPENROUTER_API_KEY else 'NOT SET'}") print(f" Auto-approve threshold: {AUTO_APPROVE_CONFIDENCE}") diff --git a/Albert_Project/core/job_costing.py b/Albert_Project/core/job_costing.py index 5c4955c..775e0fd 100644 --- a/Albert_Project/core/job_costing.py +++ b/Albert_Project/core/job_costing.py @@ -111,12 +111,12 @@ class JobCostingResult: def print_report(self): """Print a formatted job costing report.""" inp = self.inputs - SEP = "─" * 65 - print(f"\n{'═' * 65}") + SEP = "-" * 65 + print(f"\n{'=' * 65}") print(f" JOB COSTING REPORT") print(f" Total Cabinets: {inp.total_cabinet_count:,} | " f"Containers: {self.containers_needed}") - print(f"{'═' * 65}") + print(f"{'=' * 65}") print(f"\n A. QUANTITIES") print(f" {'Total Cabinets':45s} {inp.total_cabinet_count:>10,}") @@ -162,7 +162,7 @@ class JobCostingResult: print(f" {'Total Cost':45s} ${self.total_cost:>12,.2f}") print(f" {'Cost per Cabinet':45s} ${self.cost_per_cabinet:>12,.2f}") print(f" {'Sell per Cabinet':45s} ${self.sell_per_cabinet:>12,.2f}") - print(f"{'═' * 65}\n") + print(f"{'=' * 65}\n") # ══════════════════════════════════════════════════════════════════════════ diff --git a/Albert_Project/core/region_detector.py b/Albert_Project/core/region_detector.py index 9ad21a9..734c16e 100644 --- a/Albert_Project/core/region_detector.py +++ b/Albert_Project/core/region_detector.py @@ -98,7 +98,7 @@ class RegionDetector: # ── Public API ──────────────────────────────────────────────────────── def detect(self) -> list[DetectedRegion]: - """Main entry point. Returns all detected regions.""" + """Main entry point. Returns all detected regions, deduplicated.""" title_x = self.title_block_x # 1. Find all keyword label hits @@ -110,7 +110,13 @@ class RegionDetector: # 3. Build crop zones with smart boundaries regions = self._build_crop_zones(deduped, title_x) - # 4. Sort top-to-bottom, left-to-right + # 4. Remove overlapping regions (keep highest confidence) + regions = self._remove_overlapping_regions(regions) + + # 5. Cap per-type to prevent explosion (max 2 KITCHEN, 2 BATH, 2 VANITY) + regions = self._cap_regions_per_type(regions) + + # 6. Sort top-to-bottom, left-to-right regions.sort(key=lambda r: (r.origin[1], r.origin[0])) return regions @@ -217,7 +223,7 @@ class RegionDetector: def _deduplicate_hits(self, hits: list[dict]) -> list[dict]: """ - Remove duplicate hits that are within 80 pts of each other + Remove duplicate hits that are within 200 pts of each other (same label detected multiple times in different sub-spans). Keep the hit with the largest font size (most prominent). """ @@ -226,7 +232,7 @@ class RegionDetector: # Group by (region_type, x-cluster, y-cluster) groups: list[list[dict]] = [] - CLUSTER_DIST = 80.0 # pts + CLUSTER_DIST = 200.0 # pts — increased from 80 to collapse nearby duplicates for hit in hits: placed = False @@ -234,7 +240,13 @@ class RegionDetector: rep = group[0] dx = abs(hit["origin"][0] - rep["origin"][0]) dy = abs(hit["origin"][1] - rep["origin"][1]) - if hit["region_type"] == rep["region_type"] and dx < CLUSTER_DIST and dy < CLUSTER_DIST: + same_type = ( + hit["region_type"] == rep["region_type"] or + # Also merge BATH/VANITY/MASTER_BATH into same cluster + (hit["region_type"] in ("BATH","VANITY","MASTER_BATH") and + rep["region_type"] in ("BATH","VANITY","MASTER_BATH")) + ) + if same_type and dx < CLUSTER_DIST and dy < CLUSTER_DIST: group.append(hit) placed = True break @@ -350,10 +362,84 @@ class RegionDetector: return columns + def _remove_overlapping_regions( + self, + regions: list[DetectedRegion], + ) -> list[DetectedRegion]: + """ + Remove crop regions that heavily overlap each other. + If two regions of the SAME type share > 60% of the smaller one's area, + keep only the one with higher confidence (larger font = more prominent label). + """ + if len(regions) <= 1: + return regions + + def overlap_ratio(a: DetectedRegion, b: DetectedRegion) -> float: + ix0 = max(a.x0, b.x0) + iy0 = max(a.y0, b.y0) + ix1 = min(a.x1, b.x1) + iy1 = min(a.y1, b.y1) + if ix1 <= ix0 or iy1 <= iy0: + return 0.0 + inter = (ix1 - ix0) * (iy1 - iy0) + area_a = a.width * a.height + area_b = b.width * b.height + smaller = min(area_a, area_b) + return inter / smaller if smaller > 0 else 0.0 + + # Sort by confidence desc so we keep the best ones + sorted_r = sorted(regions, key=lambda r: -r.confidence) + kept: list[DetectedRegion] = [] + + for candidate in sorted_r: + dominated = False + for keeper in kept: + same_family = ( + candidate.region_type == keeper.region_type or + (candidate.region_type in ("BATH","VANITY","MASTER_BATH") and + keeper.region_type in ("BATH","VANITY","MASTER_BATH")) + ) + if same_family and overlap_ratio(candidate, keeper) > 0.60: + dominated = True + break + if not dominated: + kept.append(candidate) + + return kept + + def _cap_regions_per_type( + self, + regions: list[DetectedRegion], + ) -> list[DetectedRegion]: + """ + Hard cap on how many regions of each type are sent to AI. + A unit plan has at most 2 kitchen elevations, 2 bath elevations, + 1-2 vanity views. More than that = detector false positives. + """ + CAPS = { + "KITCHEN": 2, + "BATH": 2, + "VANITY": 2, + "MASTER_BATH": 1, + "ELEVATION_A": 1, + "ELEVATION_B": 1, + "ELEVATION_C": 1, + "ELEVATION_D": 1, + "FLOOR_PLAN": 1, + } + from collections import Counter + type_count: Counter = Counter() + capped: list[DetectedRegion] = [] + + # Sort by confidence desc so we keep the best detections + for r in sorted(regions, key=lambda r: -r.confidence): + cap = CAPS.get(r.region_type, 2) + if type_count[r.region_type] < cap: + capped.append(r) + type_count[r.region_type] += 1 + + return capped -# ══════════════════════════════════════════════════════════════════════════ -# CONVENIENCE FUNCTIONS -# ══════════════════════════════════════════════════════════════════════════ def detect_regions( spans: list[TextSpan], diff --git a/Albert_Project/generators/cabinet_excel.py b/Albert_Project/generators/cabinet_excel.py index 1d7690e..3608d01 100644 --- a/Albert_Project/generators/cabinet_excel.py +++ b/Albert_Project/generators/cabinet_excel.py @@ -516,7 +516,7 @@ def generate_excel( _build_shop_drawing_sheet(ws_sd, unit_type, config, schedule, st) wb.save(str(output_path)) - print(f" ✅ Excel saved: {output_path}") + print(f" [SUCCESS] Excel saved: {output_path}") return output_path diff --git a/Albert_Project/generators/shop_drawing_pdf.py b/Albert_Project/generators/shop_drawing_pdf.py index bf359b7..cb0f432 100644 --- a/Albert_Project/generators/shop_drawing_pdf.py +++ b/Albert_Project/generators/shop_drawing_pdf.py @@ -522,7 +522,7 @@ def generate_shop_drawings( c.showPage() c.save() - print(f" ✅ Shop drawing PDF saved: {output_path} ({total_pages} pages)") + print(f" [SUCCESS] Shop drawing PDF saved: {output_path} ({total_pages} pages)") return output_path diff --git a/Albert_Project/outputs/23-033/23-033_Cabinet_Estimation.xlsx b/Albert_Project/outputs/23-033/23-033_Cabinet_Estimation.xlsx index db42924..903587a 100644 Binary files a/Albert_Project/outputs/23-033/23-033_Cabinet_Estimation.xlsx and b/Albert_Project/outputs/23-033/23-033_Cabinet_Estimation.xlsx differ diff --git a/Albert_Project/outputs/23-033/23-033_Shop_Drawings.pdf b/Albert_Project/outputs/23-033/23-033_Shop_Drawings.pdf index 03764d4..8258d24 100644 Binary files a/Albert_Project/outputs/23-033/23-033_Shop_Drawings.pdf and b/Albert_Project/outputs/23-033/23-033_Shop_Drawings.pdf differ diff --git a/Albert_Project/outputs/23-033/crops/A1_BATH.png b/Albert_Project/outputs/23-033/crops/A1_BATH.png index fcef791..0aa108a 100644 Binary files a/Albert_Project/outputs/23-033/crops/A1_BATH.png and b/Albert_Project/outputs/23-033/crops/A1_BATH.png differ diff --git a/Albert_Project/outputs/23-033/crops/A1_ELEVATION_B.png b/Albert_Project/outputs/23-033/crops/A1_ELEVATION_B.png index edd62ec..b7c0a5c 100644 Binary files a/Albert_Project/outputs/23-033/crops/A1_ELEVATION_B.png and b/Albert_Project/outputs/23-033/crops/A1_ELEVATION_B.png differ diff --git a/Albert_Project/outputs/23-033/crops/A1_KITCHEN.png b/Albert_Project/outputs/23-033/crops/A1_KITCHEN.png index adaf312..6031047 100644 Binary files a/Albert_Project/outputs/23-033/crops/A1_KITCHEN.png and b/Albert_Project/outputs/23-033/crops/A1_KITCHEN.png differ diff --git a/Albert_Project/outputs/23-033/crops/A1_VANITY.png b/Albert_Project/outputs/23-033/crops/A1_VANITY.png index ea5ecaf..9643cc5 100644 Binary files a/Albert_Project/outputs/23-033/crops/A1_VANITY.png and b/Albert_Project/outputs/23-033/crops/A1_VANITY.png differ diff --git a/Albert_Project/outputs/23-033/crops/A2-ADA_BATH.png b/Albert_Project/outputs/23-033/crops/A2-ADA_BATH.png deleted file mode 100644 index 4b06dff..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A2-ADA_BATH.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A2-ADA_ELEVATION_B.png b/Albert_Project/outputs/23-033/crops/A2-ADA_ELEVATION_B.png deleted file mode 100644 index 0838c84..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A2-ADA_ELEVATION_B.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A2-ADA_KITCHEN.png b/Albert_Project/outputs/23-033/crops/A2-ADA_KITCHEN.png deleted file mode 100644 index cd8b728..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A2-ADA_KITCHEN.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A2-ADA_VANITY.png b/Albert_Project/outputs/23-033/crops/A2-ADA_VANITY.png deleted file mode 100644 index f1c785a..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A2-ADA_VANITY.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A3_BATH.png b/Albert_Project/outputs/23-033/crops/A3_BATH.png deleted file mode 100644 index 2a29a2c..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A3_BATH.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A3_ELEVATION_B.png b/Albert_Project/outputs/23-033/crops/A3_ELEVATION_B.png deleted file mode 100644 index 90ba652..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A3_ELEVATION_B.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A3_KITCHEN.png b/Albert_Project/outputs/23-033/crops/A3_KITCHEN.png deleted file mode 100644 index 509642c..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A3_KITCHEN.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/A3_VANITY.png b/Albert_Project/outputs/23-033/crops/A3_VANITY.png deleted file mode 100644 index c364b1c..0000000 Binary files a/Albert_Project/outputs/23-033/crops/A3_VANITY.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B1_BATH.png b/Albert_Project/outputs/23-033/crops/B1_BATH.png deleted file mode 100644 index c6715c8..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B1_BATH.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B1_ELEVATION_B.png b/Albert_Project/outputs/23-033/crops/B1_ELEVATION_B.png deleted file mode 100644 index 90ba652..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B1_ELEVATION_B.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B1_KITCHEN.png b/Albert_Project/outputs/23-033/crops/B1_KITCHEN.png deleted file mode 100644 index 72b67ad..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B1_KITCHEN.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B1_MASTER_BATH.png b/Albert_Project/outputs/23-033/crops/B1_MASTER_BATH.png deleted file mode 100644 index 84f343d..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B1_MASTER_BATH.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B1_VANITY.png b/Albert_Project/outputs/23-033/crops/B1_VANITY.png deleted file mode 100644 index c364b1c..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B1_VANITY.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B2-ADA_BATH.png b/Albert_Project/outputs/23-033/crops/B2-ADA_BATH.png deleted file mode 100644 index 6f3834e..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B2-ADA_BATH.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B2-ADA_ELEVATION_B.png b/Albert_Project/outputs/23-033/crops/B2-ADA_ELEVATION_B.png deleted file mode 100644 index 90ba652..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B2-ADA_ELEVATION_B.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B2-ADA_KITCHEN.png b/Albert_Project/outputs/23-033/crops/B2-ADA_KITCHEN.png deleted file mode 100644 index 76941ac..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B2-ADA_KITCHEN.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/crops/B2-ADA_VANITY.png b/Albert_Project/outputs/23-033/crops/B2-ADA_VANITY.png deleted file mode 100644 index c364b1c..0000000 Binary files a/Albert_Project/outputs/23-033/crops/B2-ADA_VANITY.png and /dev/null differ diff --git a/Albert_Project/outputs/23-033/json/cabinet_schedule_A1.json b/Albert_Project/outputs/23-033/json/cabinet_schedule_A1.json index 3d11e4f..5b3b478 100644 --- a/Albert_Project/outputs/23-033/json/cabinet_schedule_A1.json +++ b/Albert_Project/outputs/23-033/json/cabinet_schedule_A1.json @@ -3,126 +3,12 @@ "is_ada": false, "auto_approved": false, "review_flags": [ - "Requires review: avg confidence 0.83 < 0.9", "Requires review: avg confidence 0.75 < 0.9", - "Requires review: avg confidence 0.80 < 0.9", - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.75 < 0.9", - "Groq API call failed after all retries", - "Requires review: avg confidence 0.72 < 0.9", - "Requires review: avg confidence 0.78 < 0.9", - "Requires review: avg confidence 0.74 < 0.9", "Requires review: avg confidence 0.89 < 0.9", "Requires review: avg confidence 0.88 < 0.9", - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.76 < 0.9", - "Requires review: avg confidence 0.78 < 0.9", - "Requires review: avg confidence 0.80 < 0.9", - "Requires review: avg confidence 0.78 < 0.9", - "Requires review: avg confidence 0.82 < 0.9", - "Requires review: avg confidence 0.80 < 0.9", - "Requires review: avg confidence 0.72 < 0.9", - "Requires review: avg confidence 0.89 < 0.9", - "Requires review: avg confidence 0.76 < 0.9", - "Requires review: avg confidence 0.82 < 0.9" + "Requires review: avg confidence 0.89 < 0.9" ], "elevations": [ - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.8250000000000001, - "review_flags": [ - "Requires review: avg confidence 0.83 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of sink, above countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Center of wall, above countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under sink, near wall", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, near sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom, under sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.85, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "medicine_cabinet", - "width_mm": 400.0, - "height_mm": 300.0, - "depth_mm": 150.0, - "location": "Bathroom, above sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, { "elevation_label": "BATH", "unit_type": "A1", @@ -135,716 +21,31 @@ "cabinets": [ { "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "DW", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "pantry", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right of refrigerator", - "elevation_ref": "ELEVATION A", - "confidence": 0.6, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, "cabinet_type": "vanity", - "width_mm": 900.0, + "width_mm": 1880.0, "height_mm": 870.0, "depth_mm": 530.0, - "location": "Bathroom", - "elevation_ref": "ELEVATION A", + "location": "Bathroom, left wall", + "elevation_ref": "A-6.00A", "confidence": 0.8, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 150.0, - "location": "Above sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.7999999999999999, - "review_flags": [ - "Requires review: avg confidence 0.80 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range", - "elevation_ref": "", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Width estimated from 6'-2\" dimension for the counter, assuming a standard vanity depth.", + "source": "gemini" }, { "item_num": 2, - "cabinet_type": "base", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop", - "elevation_ref": "", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "DW", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop", - "elevation_ref": "", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom", - "elevation_ref": "", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 150.0, - "location": "Above sink", - "elevation_ref": "", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.8099999999999999, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, near sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.85, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "DW", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, right of sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "pantry", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Tall cabinet, floor to ceiling", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.75, - "review_flags": [ - "Requires review: avg confidence 0.75 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, near sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, adjacent to refrigerator", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, near sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Refrigerator space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "Refrigerator", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "dw_adjacent", - "width_mm": 300.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Adjacent to dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "microwave_shelf", - "width_mm": 762.0, - "height_mm": 380.0, - "depth_mm": 330.0, - "location": "Above range", - "elevation_ref": "ELEVATION A", - "confidence": 0.6, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.0, - "review_flags": [ - "Groq API call failed after all retries" - ], - "cabinets": [] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.725, - "review_flags": [ - "Requires review: avg confidence 0.72 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "sink_base", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "pantry", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Tall cabinet", - "elevation_ref": "ELEVATION A", - "confidence": 0.6, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "corner_base", - "width_mm": 450.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Corner base", - "elevation_ref": "ELEVATION A", - "confidence": 0.6, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 150.0, - "location": "Above sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.78, - "review_flags": [ - "Requires review: avg confidence 0.78 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left side, bottom", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Center, bottom", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above sink", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above toilet", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.7444444444444445, - "review_flags": [ - "Requires review: avg confidence 0.74 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of refrigerator, near top", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Center, above sink", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right of sink, near top", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, microwave shelf", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "microwave", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left of dishwasher, bottom", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "sink_base", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, under sink", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "dw_adjacent", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Right of dishwasher, bottom", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Right of oven, bottom", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 9, - "cabinet_type": "pantry", "width_mm": 600.0, "height_mm": 2130.0, "depth_mm": 600.0, - "location": "Right, tall cabinet", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.6, + "location": "Bathroom, right of vanity", + "elevation_ref": "A-6.00A", + "confidence": 0.7, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Labeled 'LN.', assuming standard pantry/linen dimensions.", + "source": "gemini" } ] }, @@ -853,52 +54,52 @@ "unit_type": "A1", "is_ada": false, "auto_approved": false, - "avg_confidence": 0.8875000000000001, + "avg_confidence": 0.8863636363636364, "review_flags": [ "Requires review: avg confidence 0.89 < 0.9" ], "cabinets": [ { "item_num": 1, - "cabinet_type": "upper_wall", + "cabinet_type": "appliance_space", "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above sink, near range", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above refrigerator space", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, + "height_mm": 900.0, "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "ELEVATION A", + "location": "Kitchen, left side", + "elevation_ref": "KITCHEN", "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Refrigerator space, estimated width from typical appliance sizes.", + "source": "gemini" + }, + { + "item_num": 2, + "cabinet_type": "base", + "width_mm": 762.0, + "height_mm": 720.0, + "depth_mm": 600.0, + "location": "Kitchen, left of sink", + "elevation_ref": "KITCHEN", + "confidence": 0.8, + "quantity": 1, + "is_ada": false, + "notes": "Estimated width based on visual proportion.", + "source": "gemini" + }, + { + "item_num": 3, + "cabinet_type": "sink_base", + "width_mm": 900.0, + "height_mm": 720.0, + "depth_mm": 600.0, + "location": "Kitchen, under sink", + "elevation_ref": "KITCHEN", + "confidence": 0.95, + "quantity": 1, + "is_ada": false, + "notes": "Estimated width based on sink size.", + "source": "gemini" }, { "item_num": 4, @@ -906,69 +107,219 @@ "width_mm": 600.0, "height_mm": 720.0, "depth_mm": 600.0, - "location": "Adjacent to dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, + "location": "Kitchen, right of sink", + "elevation_ref": "KITCHEN", + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Space for dishwasher, cabinet adjacent to it.", + "source": "gemini" }, { "item_num": 5, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, + "cabinet_type": "appliance_space", + "width_mm": 762.0, + "height_mm": 900.0, "depth_mm": 600.0, - "location": "Under countertop, near corner", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, + "location": "Kitchen, right side", + "elevation_ref": "KITCHEN", + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Range space, estimated width from typical appliance sizes.", + "source": "gemini" }, { "item_num": 6, - "cabinet_type": "appliance_space", + "cabinet_type": "upper_wall", "width_mm": 762.0, "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 1.0, + "depth_mm": 330.0, + "location": "Kitchen, above left base cabinet", + "elevation_ref": "KITCHEN", + "confidence": 0.8, "quantity": 1, "is_ada": false, - "notes": "DW", - "source": "groq" + "notes": "Estimated width based on base cabinet below.", + "source": "gemini" }, { "item_num": 7, - "cabinet_type": "appliance_space", - "width_mm": 914.0, + "cabinet_type": "upper_wall", + "width_mm": 900.0, "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Range space", - "elevation_ref": "ELEVATION A", - "confidence": 1.0, + "depth_mm": 330.0, + "location": "Kitchen, above sink", + "elevation_ref": "KITCHEN", + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "Range", - "source": "groq" + "notes": "Estimated width based on sink base below.", + "source": "gemini" }, { "item_num": 8, - "cabinet_type": "appliance_space", - "width_mm": 762.0, + "cabinet_type": "upper_wall", + "width_mm": 600.0, "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Refrigerator space", - "elevation_ref": "ELEVATION A", - "confidence": 1.0, + "depth_mm": 330.0, + "location": "Kitchen, above dishwasher space", + "elevation_ref": "KITCHEN", + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "Refrigerator", - "source": "groq" + "notes": "Estimated width based on dishwasher space below.", + "source": "gemini" + }, + { + "item_num": 9, + "cabinet_type": "microwave_shelf", + "width_mm": 762.0, + "height_mm": 380.0, + "depth_mm": 330.0, + "location": "Kitchen, above range", + "elevation_ref": "KITCHEN", + "confidence": 0.85, + "quantity": 1, + "is_ada": false, + "notes": "Space for microwave above range, estimated width.", + "source": "gemini" + }, + { + "item_num": 10, + "cabinet_type": "linen", + "width_mm": 600.0, + "height_mm": 2130.0, + "depth_mm": 600.0, + "location": "Bathroom, labeled 'LN.'", + "elevation_ref": "BATHROOM", + "confidence": 0.95, + "quantity": 1, + "is_ada": false, + "notes": "Labeled 'LN.', assumed standard pantry/linen depth.", + "source": "gemini" + }, + { + "item_num": 11, + "cabinet_type": "vanity", + "width_mm": 900.0, + "height_mm": 870.0, + "depth_mm": 530.0, + "location": "Bathroom, under sink", + "elevation_ref": "BATHROOM", + "confidence": 0.9, + "quantity": 1, + "is_ada": false, + "notes": "Estimated width based on typical vanity sizes.", + "source": "gemini" + } + ] + }, + { + "elevation_label": "BATH", + "unit_type": "A1", + "is_ada": false, + "auto_approved": true, + "avg_confidence": 0.9, + "review_flags": [], + "cabinets": [ + { + "item_num": 1, + "cabinet_type": "appliance_space", + "width_mm": 762.0, + "height_mm": 864.0, + "depth_mm": 600.0, + "location": "Kitchen, under range", + "elevation_ref": "UNIT A1 KITCHEN PLAN", + "confidence": 0.95, + "quantity": 1, + "is_ada": true, + "notes": "Range appliance space, 30x48 clear area indicated. Assuming ADA height for base cabinets.", + "source": "gemini" + }, + { + "item_num": 2, + "cabinet_type": "sink_base", + "width_mm": 900.0, + "height_mm": 864.0, + "depth_mm": 600.0, + "location": "Kitchen, under sink", + "elevation_ref": "UNIT A1 KITCHEN PLAN", + "confidence": 0.9, + "quantity": 1, + "is_ada": true, + "notes": "Sink base cabinet, 30x48 clear area indicated. Width estimated from drawing, assuming ADA height for base cabinets.", + "source": "gemini" + }, + { + "item_num": 3, + "cabinet_type": "appliance_space", + "width_mm": 600.0, + "height_mm": 864.0, + "depth_mm": 600.0, + "location": "Kitchen, under DW", + "elevation_ref": "UNIT A1 KITCHEN PLAN", + "confidence": 0.95, + "quantity": 1, + "is_ada": true, + "notes": "Dishwasher appliance space, 30x48 clear area indicated. 24\" (MAX) width noted. Assuming ADA height for base cabinets.", + "source": "gemini" + }, + { + "item_num": 4, + "cabinet_type": "base", + "width_mm": 450.0, + "height_mm": 864.0, + "depth_mm": 600.0, + "location": "Kitchen, right of DW", + "elevation_ref": "UNIT A1 KITCHEN PLAN", + "confidence": 0.8, + "quantity": 1, + "is_ada": true, + "notes": "Base cabinet, width estimated from drawing. Assuming ADA height for base cabinets.", + "source": "gemini" + }, + { + "item_num": 5, + "cabinet_type": "appliance_space", + "width_mm": 900.0, + "height_mm": 2130.0, + "depth_mm": 600.0, + "location": "Kitchen, Refrigerator", + "elevation_ref": "UNIT A1 KITCHEN PLAN", + "confidence": 0.95, + "quantity": 1, + "is_ada": false, + "notes": "Refrigerator appliance space. Width estimated from 3'-0\" dimension. Height assumed as standard pantry height.", + "source": "gemini" + }, + { + "item_num": 6, + "cabinet_type": "pantry", + "width_mm": 600.0, + "height_mm": 2130.0, + "depth_mm": 600.0, + "location": "Kitchen, right of Refrigerator", + "elevation_ref": "UNIT A1 KITCHEN PLAN", + "confidence": 0.85, + "quantity": 1, + "is_ada": false, + "notes": "Pantry cabinet. Width estimated from drawing. Height assumed as standard pantry height.", + "source": "gemini" + }, + { + "item_num": 7, + "cabinet_type": "vanity", + "width_mm": 762.0, + "height_mm": 870.0, + "depth_mm": 530.0, + "location": "Bathroom", + "elevation_ref": "BATHROOM", + "confidence": 0.9, + "quantity": 1, + "is_ada": false, + "notes": "Bathroom vanity. Width estimated from 2'-6\" (30\") dimension. Standard vanity height and depth.", + "source": "gemini" } ] }, @@ -984,87 +335,59 @@ "cabinets": [ { "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 600.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "VANITY", - "confidence": 0.9, + "cabinet_type": "pantry", + "width_mm": 305.0, + "height_mm": 2130.0, + "depth_mm": 600.0, + "location": "U9, General Notes", + "elevation_ref": "General Notes", + "confidence": 0.95, "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" + "is_ada": false, + "notes": "12\" Width x 24\" Depth Pantry. Assumed standard pantry height.", + "source": "gemini" }, { "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 150.0, - "depth_mm": 130.0, - "location": "Above vanity", - "elevation_ref": "VANITY", - "confidence": 0.8, + "cabinet_type": "linen", + "width_mm": 305.0, + "height_mm": 2130.0, + "depth_mm": 600.0, + "location": "U14, General Notes", + "elevation_ref": "General Notes", + "confidence": 0.95, "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" + "is_ada": false, + "notes": "12\" Width x 24\" Depth Linen Cabinet. Assumed standard pantry height for linen cabinet.", + "source": "gemini" }, { "item_num": 3, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, tall cabinet", - "elevation_ref": "ELEVATION A", - "confidence": 0.85, + "cabinet_type": "vanity", + "width_mm": 762.0, + "height_mm": 870.0, + "depth_mm": 530.0, + "location": "U20, General Notes", + "elevation_ref": "General Notes", + "confidence": 0.9, "quantity": 1, "is_ada": true, - "notes": "", - "source": "groq" + "notes": "Vanity cabinet. Refer to A-6.06, FHA Bathroom Fixture Legend, #5. Assumed 30\" width based on common vanity sizes and ADA/FHA context. Height based on 36\" high counter (U6) minus countertop thickness, and ADA requirements.", + "source": "gemini" }, { "item_num": 4, - "cabinet_type": "appliance_space", + "cabinet_type": "medicine_cabinet", "width_mm": 762.0, "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, below countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.95, + "depth_mm": 130.0, + "location": "U8, General Notes", + "elevation_ref": "General Notes", + "confidence": 0.7, "quantity": 1, "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, below countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.95, - "quantity": 1, - "is_ada": true, - "notes": "Range", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above range", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" + "notes": "Mirror match width of vanity. Assumed standard medicine cabinet height and depth. Width matches assumed vanity width.", + "source": "gemini" } ] }, @@ -1073,340 +396,136 @@ "unit_type": "A1", "is_ada": false, "auto_approved": false, - "avg_confidence": 0.8142857142857143, + "avg_confidence": 0.8944444444444445, "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" + "Requires review: avg confidence 0.89 < 0.9" ], "cabinets": [ { "item_num": 1, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Refrigerator, bottom left", + "cabinet_type": "upper_wall", + "width_mm": 900, + "height_mm": 762.0, + "depth_mm": 330.0, + "location": "Left of microwave shelf, top row, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "Refrigerator", - "source": "groq" + "notes": "Width estimated from drawing, 3'-0\" dimension", + "source": "gemini" }, { "item_num": 2, - "cabinet_type": "upper_wall", + "cabinet_type": "microwave_shelf", "width_mm": 762.0, - "height_mm": 300.0, + "height_mm": 380.0, "depth_mm": 330.0, - "location": "Top center", + "location": "Above range, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Width estimated from drawing, 2'-6\" range space below", + "source": "gemini" }, { "item_num": 3, "cabinet_type": "upper_wall", "width_mm": 762.0, - "height_mm": 300.0, + "height_mm": 762.0, "depth_mm": 330.0, - "location": "Top right", + "location": "Right of microwave shelf, top row, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Width estimated from drawing, similar to item 1", + "source": "gemini" }, { "item_num": 4, - "cabinet_type": "base", - "width_mm": 900.0, - "height_mm": 720.0, + "cabinet_type": "appliance_space", + "width_mm": 762.0, + "height_mm": 900.0, "depth_mm": 600.0, - "location": "Bottom center", + "location": "Range space, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, + "confidence": 0.95, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Space for 'FULL SIZE RANGE' (U4)", + "source": "gemini" }, { "item_num": 5, "cabinet_type": "base", - "width_mm": 600.0, + "width_mm": 900, "height_mm": 720.0, "depth_mm": 600.0, - "location": "Bottom left", + "location": "Left of range, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, + "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Width estimated from drawing, 3'-0\" dimension", + "source": "gemini" }, { "item_num": 6, - "cabinet_type": "appliance_space", + "cabinet_type": "base", "width_mm": 762.0, "height_mm": 720.0, "depth_mm": 600.0, - "location": "Dishwasher, bottom left", + "location": "Right of range, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "Dishwasher", - "source": "groq" + "notes": "Width estimated from drawing, similar to item 2", + "source": "gemini" }, { "item_num": 7, - "cabinet_type": "microwave_shelf", + "cabinet_type": "appliance_space", "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Top right, above range", + "height_mm": 1700.0, + "depth_mm": 600.0, + "location": "Refrigerator space, Elevation 1", "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.7, + "confidence": 0.95, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.76, - "review_flags": [ - "Requires review: avg confidence 0.76 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 600.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" + "notes": "Space for 'REF.' (Refrigerator)", + "source": "gemini" }, { - "item_num": 2, - "cabinet_type": "linen", + "item_num": 8, + "cabinet_type": "pantry", "width_mm": 300.0, "height_mm": 2130.0, "depth_mm": 600.0, - "location": "Right side, above floor", - "elevation_ref": "BATH", - "confidence": 0.7, + "location": "Right of refrigerator, Elevation 1", + "elevation_ref": "UNIT A1 KITCHEN EL.", + "confidence": 0.8, "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" + "is_ada": false, + "notes": "Width estimated, height 7'-6\" (2286mm) from drawing, depth 'CABINET OVER REF. TO BE 24\" DEPTH' implies 24\" depth for tall cabinets as well. U9 indicates 12\" width, 24\" depth, which could be this cabinet.", + "source": "gemini" }, { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, + "item_num": 9, + "cabinet_type": "upper_wall", + "width_mm": 900, + "height_mm": 762.0, "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "BATH", - "confidence": 0.6, + "location": "Left of refrigerator, Elevation 1", + "elevation_ref": "UNIT A1 KITCHEN EL.", + "confidence": 0.85, "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under vanity", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher area", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.78, - "review_flags": [ - "Requires review: avg confidence 0.78 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "linen", - "width_mm": 610.0, - "height_mm": 610.0, - "depth_mm": 600.0, - "location": "Left wall, above countertop", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Center wall, below sink", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right wall, above sink", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left of vanity, under countertop", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Right of vanity, under countertop", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "VANITY", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.8, - "review_flags": [ - "Requires review: avg confidence 0.80 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, below countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 130.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 600.0, - "depth_mm": 330.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Below countertop, left side", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" + "is_ada": false, + "notes": "Width estimated from drawing, 3'-0\" dimension. Height estimated to match adjacent upper cabinets.", + "source": "gemini" } ] }, @@ -1414,189 +533,9 @@ "elevation_label": "ELEVATION_B", "unit_type": "A1", "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.78, - "review_flags": [ - "Requires review: avg confidence 0.78 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, below sink", - "elevation_ref": "ELEVATION_B", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION_B", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 600.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "ELEVATION_B", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Below linen closet", - "elevation_ref": "ELEVATION_B", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left side, below countertop", - "elevation_ref": "ELEVATION_B", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.8166666666666668, - "review_flags": [ - "Requires review: avg confidence 0.82 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 600.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Below countertop, near linen closet", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Near refrigerator area", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Refrigerator", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 600.0, - "height_mm": 380.0, - "depth_mm": 330.0, - "location": "Above countertop, near sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "VANITY", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.8, - "review_flags": [ - "Requires review: avg confidence 0.80 < 0.9" - ], + "auto_approved": true, + "avg_confidence": 0.9, + "review_flags": [], "cabinets": [ { "item_num": 1, @@ -1604,467 +543,13 @@ "width_mm": 900.0, "height_mm": 870.0, "depth_mm": 530.0, - "location": "Under sink, near center", - "elevation_ref": "Section: VANITY", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 130.0, - "location": "Above vanity", - "elevation_ref": "Section: VANITY", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 600.0, - "depth_mm": 330.0, - "location": "Left of vanity", - "elevation_ref": "Section: VANITY", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, left", - "elevation_ref": "Section: VANITY", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher space", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.7166666666666667, - "review_flags": [ - "Requires review: avg confidence 0.72 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 600.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, tall cabinet", - "elevation_ref": "ELEVATION A", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left side, under countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left side, near bottom", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 600.0, - "height_mm": 380.0, - "depth_mm": 330.0, - "location": "Right side, upper wall", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.885, - "review_flags": [ - "Requires review: avg confidence 0.89 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, left side", - "elevation_ref": "UNIT A1 KITCHEN EL.", + "location": "U20, FHA Bathroom Fixture Legend, #5", + "elevation_ref": "ELEVATION_B", "confidence": 0.9, "quantity": 1, "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Refrigerator space, left side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.95, - "quantity": 1, - "is_ada": false, - "notes": "Refrigerator", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, center", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "sink_base", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under sink, right side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "dw_adjacent", - "width_mm": 150.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Adjacent to dishwasher, right side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 330.0, - "location": "Above refrigerator, left side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "microwave_shelf", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above range, center", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 9, - "cabinet_type": "appliance_space", - "width_mm": 610.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space, right side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.95, - "quantity": 1, - "is_ada": false, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 10, - "cabinet_type": "appliance_space", - "width_mm": 914.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Range space, right side", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.95, - "quantity": 1, - "is_ada": false, - "notes": "Range", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.76, - "review_flags": [ - "Requires review: avg confidence 0.76 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left side, near bottom", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left side", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, near bottom", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Right side, near bottom", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 150.0, - "depth_mm": 150.0, - "location": "Above vanity, right side", - "elevation_ref": "ELEVATION A", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A1", - "is_ada": false, - "auto_approved": false, - "avg_confidence": 0.82, - "review_flags": [ - "Requires review: avg confidence 0.82 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Left side, bottom", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Top left, above counter", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, bottom", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Right side, bottom", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 330.0, - "location": "Top right, above counter", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" + "notes": "Based on U20 description 'VANITY CABINET'.", + "source": "gemini" } ] } diff --git a/Albert_Project/outputs/23-033/json/cabinet_schedule_A2-ADA.json b/Albert_Project/outputs/23-033/json/cabinet_schedule_A2-ADA.json deleted file mode 100644 index 598b7cf..0000000 --- a/Albert_Project/outputs/23-033/json/cabinet_schedule_A2-ADA.json +++ /dev/null @@ -1,2408 +0,0 @@ -{ - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.78 < 0.9", - "Requires review: avg confidence 0.76 < 0.9", - "Requires review: avg confidence 0.82 < 0.9", - "Requires review: avg confidence 0.80 < 0.9", - "Requires review: avg confidence 0.83 < 0.9", - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.87 < 0.9", - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.74 < 0.9", - "Requires review: avg confidence 0.77 < 0.9", - "Requires review: avg confidence 0.80 < 0.9", - "Requires review: avg confidence 0.83 < 0.9", - "Requires review: avg confidence 0.79 < 0.9", - "Requires review: avg confidence 0.78 < 0.9", - "Requires review: avg confidence 0.83 < 0.9", - "Requires review: avg confidence 0.80 < 0.9", - "Requires review: avg confidence 0.83 < 0.9", - "Requires review: avg confidence 0.77 < 0.9", - "Requires review: avg confidence 0.77 < 0.9", - "Requires review: avg confidence 0.81 < 0.9", - "Requires review: avg confidence 0.78 < 0.9" - ], - "elevations": [ - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8142857142857143, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink, near left wall", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right of sink, near wall", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Right wall, above base cabinets", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "appliance_space", - "width_mm": 900.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Range space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Range", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7833333333333333, - "review_flags": [ - "Requires review: avg confidence 0.78 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 600.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left wall, above sink", - "elevation_ref": "BATHROOM ELEVATION", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 350.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left wall, above toilet", - "elevation_ref": "BATHROOM ELEVATION", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "BATHROOM ELEVATION", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "BATHROOM ELEVATION", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "medicine_cabinet", - "width_mm": 400.0, - "height_mm": 600.0, - "depth_mm": 150.0, - "location": "Above toilet", - "elevation_ref": "BATHROOM ELEVATION", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "BATHROOM ELEVATION", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7625, - "review_flags": [ - "Requires review: avg confidence 0.76 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under countertop, near sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "dw_adjacent", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Next to dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under countertop, near refrigerator", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, near range", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "microwave_shelf", - "width_mm": 762.0, - "height_mm": 380.0, - "depth_mm": 330.0, - "location": "Above range", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "pantry", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Tall cabinet near refrigerator", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8150000000000001, - "review_flags": [ - "Requires review: avg confidence 0.82 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 600.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range, above cabinet", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "upper_wall", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "microwave_shelf", - "width_mm": 762.0, - "height_mm": 380.0, - "depth_mm": 330.0, - "location": "Above range", - "elevation_ref": "ELEVATION A", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "dw_adjacent", - "width_mm": 300.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "base", - "width_mm": 400.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right of sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 9, - "cabinet_type": "pantry", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Tall cabinet right of refrigerator", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 10, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Refrigerator space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Refrigerator", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7999999999999999, - "review_flags": [ - "Requires review: avg confidence 0.80 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, bottom", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, bottom", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8333333333333334, - "review_flags": [ - "Requires review: avg confidence 0.83 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, bottom", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Center, bottom", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Right side, bottom", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of vanity, top", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, left", - "elevation_ref": "BATH", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8111111111111111, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "upper_wall", - "width_mm": 600.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "upper_wall", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of range, above U8", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "upper_wall", - "width_mm": 400.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right of range", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "base", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right of dishwasher", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "pantry", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Tall cabinet, left side", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 9, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 600.0, - "depth_mm": 600.0, - "location": "Linen closet", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "VANITY", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8714285714285713, - "review_flags": [ - "Requires review: avg confidence 0.87 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION A2", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 130.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION A2", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, near vanity", - "elevation_ref": "ELEVATION A2", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 914.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Near range, bottom", - "elevation_ref": "ELEVATION A2", - "confidence": 0.95, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher space", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Near refrigerator, bottom", - "elevation_ref": "ELEVATION A2", - "confidence": 0.95, - "quantity": 1, - "is_ada": true, - "notes": "Refrigerator space", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left side", - "elevation_ref": "ELEVATION A2", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Bottom, center", - "elevation_ref": "ELEVATION A2", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.805, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, under countertop", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to sink", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "sink_base", - "width_mm": 900.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "dw_adjacent", - "width_mm": 150.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to dishwasher", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.95, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left side", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 330.0, - "location": "Above countertop, right side", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "pantry", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Tall pantry cabinet", - "elevation_ref": "UNIT A2 FA KITCHEN EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 9, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 10, - "cabinet_type": "medicine_cabinet", - "width_mm": 600.0, - "height_mm": 300.0, - "depth_mm": 150.0, - "location": "Above vanity", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "KITCHEN", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8142857142857143, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink, near left wall", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Right of sink, main wall", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of toilet, above floor", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "medicine_cabinet", - "width_mm": 762.0, - "height_mm": 150.0, - "depth_mm": 150.0, - "location": "Above sink, main wall", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space, near right wall", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Near left wall, under countertop", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left of sink", - "elevation_ref": "UNIT A1 KITCHEN EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7428571428571429, - "review_flags": [ - "Requires review: avg confidence 0.74 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, under countertop", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to sink", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "sink_base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under sink", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "BATH", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "BATH", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.77, - "review_flags": [ - "Requires review: avg confidence 0.77 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under vanity sink", - "elevation_ref": "A-6.01", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left of linen closet", - "elevation_ref": "A-6.01", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Right of vanity", - "elevation_ref": "A-6.01", - "confidence": 0.8, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, left", - "elevation_ref": "A-6.01", - "confidence": 0.7, - "quantity": 1, - "is_ada": false, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "filler", - "width_mm": 150.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Between base cabinets", - "elevation_ref": "A-6.01", - "confidence": 0.6, - "quantity": 1, - "is_ada": false, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "VANITY", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7999999999999999, - "review_flags": [ - "Requires review: avg confidence 0.80 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 600.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Under sink, near toilet", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Left of vanity", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right of vanity", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "VANITY", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8300000000000001, - "review_flags": [ - "Requires review: avg confidence 0.83 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 130.0, - "location": "Above vanity, left side", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 600.0, - "depth_mm": 330.0, - "location": "Right side, above floor", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under vanity, center", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Under countertop, left side", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "ELEVATION_B", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7928571428571428, - "review_flags": [ - "Requires review: avg confidence 0.79 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION_B", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right side, adjacent to vanity", - "elevation_ref": "ELEVATION_B", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION_B", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Near bottom, left side", - "elevation_ref": "ELEVATION_B", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "filler", - "width_mm": 50.0, - "height_mm": 720.0, - "depth_mm": 330.0, - "location": "Between upper cabinets", - "elevation_ref": "ELEVATION_B", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 900, - "height_mm": 380.0, - "depth_mm": 330.0, - "location": "Above countertop, right side", - "elevation_ref": "ELEVATION_B", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "ELEVATION_B", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7833333333333333, - "review_flags": [ - "Requires review: avg confidence 0.78 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 1800.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under vanity cabinet", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Near bottom, left side", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher space", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "upper_wall", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Top left corner", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "VANITY", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8300000000000001, - "review_flags": [ - "Requires review: avg confidence 0.83 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 600.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, below sink", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 130.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right side, under countertop", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Center, below countertop", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher space", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "filler", - "width_mm": 50.0, - "height_mm": 720.0, - "depth_mm": 30.0, - "location": "Between cabinets, near sink", - "elevation_ref": "ELEVATION A2-ADA", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.7999999999999999, - "review_flags": [ - "Requires review: avg confidence 0.80 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Adjacent to first base cabinet", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Near center, under countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher space", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 300.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right side, near corner", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Center, under sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 150.0, - "location": "Right side, above countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8250000000000001, - "review_flags": [ - "Requires review: avg confidence 0.83 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, near sink area", - "elevation_ref": "ELEVATION B", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Center, under sink", - "elevation_ref": "ELEVATION B", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right side, above vanity", - "elevation_ref": "ELEVATION B", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "linen", - "width_mm": 300.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "ELEVATION B", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Near bottom, left side", - "elevation_ref": "ELEVATION B", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "appliance_space", - "width_mm": 900.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Near bottom, center", - "elevation_ref": "ELEVATION B", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Range", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.77, - "review_flags": [ - "Requires review: avg confidence 0.77 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, near sink area", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Center, below sink", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Right side, above sink", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher area", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.77, - "review_flags": [ - "Requires review: avg confidence 0.77 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under vanity sink", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "vanity", - "width_mm": 762.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side of bathroom", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.85, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "medicine_cabinet", - "width_mm": 150.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above sink", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side of bathroom", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.8125, - "review_flags": [ - "Requires review: avg confidence 0.81 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Left side, under countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "base", - "width_mm": 450.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Center, under countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "base", - "width_mm": 150.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Right side, under countertop", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above countertop, left side", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher space, center", - "elevation_ref": "ELEVATION A", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - }, - { - "item_num": 6, - "cabinet_type": "upper_wall", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 330.0, - "location": "Above refrigerator space", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 7, - "cabinet_type": "vanity", - "width_mm": 1200.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Bathroom vanity", - "elevation_ref": "ELEVATION A", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 8, - "cabinet_type": "medicine_cabinet", - "width_mm": 300.0, - "height_mm": 150.0, - "depth_mm": 150.0, - "location": "Above sink", - "elevation_ref": "ELEVATION A", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - } - ] - }, - { - "elevation_label": "BATH", - "unit_type": "A2-ADA", - "is_ada": true, - "auto_approved": false, - "avg_confidence": 0.78, - "review_flags": [ - "Requires review: avg confidence 0.78 < 0.9" - ], - "cabinets": [ - { - "item_num": 1, - "cabinet_type": "vanity", - "width_mm": 900.0, - "height_mm": 870.0, - "depth_mm": 530.0, - "location": "Left side, below sink", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 2, - "cabinet_type": "medicine_cabinet", - "width_mm": 762.0, - "height_mm": 300.0, - "depth_mm": 330.0, - "location": "Above vanity", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.8, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 3, - "cabinet_type": "linen", - "width_mm": 400.0, - "height_mm": 2130.0, - "depth_mm": 600.0, - "location": "Right side, floor to ceiling", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.7, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 4, - "cabinet_type": "base", - "width_mm": 600.0, - "height_mm": 864.0, - "depth_mm": 600.0, - "location": "Under linen closet", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.6, - "quantity": 1, - "is_ada": true, - "notes": "", - "source": "groq" - }, - { - "item_num": 5, - "cabinet_type": "appliance_space", - "width_mm": 762.0, - "height_mm": 720.0, - "depth_mm": 600.0, - "location": "Dishwasher location", - "elevation_ref": "UNIT A2 FA BATHROOM EL.", - "confidence": 0.9, - "quantity": 1, - "is_ada": true, - "notes": "Dishwasher", - "source": "groq" - } - ] - } - ] -} \ No newline at end of file diff --git a/Albert_Project/outputs/23-033/json/cabinet_schedule_A3.json b/Albert_Project/outputs/23-033/json/cabinet_schedule_A3.json deleted file mode 100644 index 7a6c7b6..0000000 --- a/Albert_Project/outputs/23-033/json/cabinet_schedule_A3.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "unit_type": "A3", - "is_ada": false, - "auto_approved": false, - "review_flags": [], - "elevations": [] -} \ No newline at end of file diff --git a/Albert_Project/outputs/23-033/json/cabinet_schedule_B1.json b/Albert_Project/outputs/23-033/json/cabinet_schedule_B1.json deleted file mode 100644 index 93682e0..0000000 --- a/Albert_Project/outputs/23-033/json/cabinet_schedule_B1.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "unit_type": "B1", - "is_ada": false, - "auto_approved": false, - "review_flags": [], - "elevations": [] -} \ No newline at end of file diff --git a/Albert_Project/outputs/23-033/json/cabinet_schedule_B2-ADA.json b/Albert_Project/outputs/23-033/json/cabinet_schedule_B2-ADA.json deleted file mode 100644 index 2d8d24a..0000000 --- a/Albert_Project/outputs/23-033/json/cabinet_schedule_B2-ADA.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "unit_type": "B2-ADA", - "is_ada": true, - "auto_approved": false, - "review_flags": [], - "elevations": [] -} \ No newline at end of file diff --git a/Albert_Project/outputs/run2_log.txt b/Albert_Project/outputs/run2_log.txt new file mode 100644 index 0000000..a2cb3c3 Binary files /dev/null and b/Albert_Project/outputs/run2_log.txt differ diff --git a/Albert_Project/pipeline.py b/Albert_Project/pipeline.py index 784d2f2..dbf9482 100644 --- a/Albert_Project/pipeline.py +++ b/Albert_Project/pipeline.py @@ -12,7 +12,7 @@ Steps executed: 1. Load project config - 2. For each unit type: extract → detect regions → crop → Claude AI → validate + 2. For each unit type: extract -> detect regions -> crop -> Gemini Vision -> validate 3. Count units (from floor plans or project_config.json) 4. Price match (Euro price list → USD) 5. Job costing (selling price) @@ -32,11 +32,13 @@ from pathlib import Path from typing import Optional # ── Core modules ──────────────────────────────────────────────────────────── -from core.config import get_output_dir, validate_config, GROQ_API_KEY +from core.config import get_output_dir, validate_config from core.pdf_extractor import PDFExtractor +from core.ai_vision_classifier import ( + CabinetVisionClassifier, ElevationResult, OPENROUTER_API_KEY +) from core.region_detector import RegionDetector from core.dimension_parser import classify_spans, associate_dims_to_rects -from core.ai_vision_classifier import CabinetVisionClassifier, ElevationResult from core.cabinet_validator import CabinetValidator from core.price_matcher import PriceMatcher, get_fallback_price_usd, _generate_code from core.unit_counter import UnitCounter, load_matrix_from_config @@ -123,6 +125,7 @@ def process_unit( classifier: Optional[CabinetVisionClassifier], validator: CabinetValidator, skip_ai: bool = False, + demo_mode: bool = False, ) -> UnitSchedule: """ Process one unit type PDF: extract → detect → crop → AI → validate. @@ -154,7 +157,7 @@ def process_unit( return schedule if not pdf_path.exists(): - print(f"\n ⚠️ [{unit_type}] PDF not found: {pdf_path}") + print(f"\n [WARN] [{unit_type}] PDF not found: {pdf_path}") schedule.review_flags.append(f"PDF not found: {pdf_path}") return schedule @@ -166,7 +169,7 @@ def process_unit( regions = detector.detect() if not regions: - print(f" ⚠️ No elevation regions detected in {pdf_path.name}") + print(f" [WARN] No elevation regions detected in {pdf_path.name}") schedule.review_flags.append("No elevation regions detected") return schedule @@ -209,7 +212,8 @@ def process_unit( continue # Call Gemini Vision API - print(f" Calling Claude Vision for {region.region_type}...") + mode_tag = "DEMO (low-token)" if demo_mode else "FULL" + print(f" Sending {region.region_type} crop to Gemini Vision [{mode_tag}]...") elevation_result = classifier.classify_elevation( image_bytes = img_bytes, unit_type = unit_type, @@ -218,6 +222,7 @@ def process_unit( pre_extracted_dims = pre_dims, pre_extracted_rects = pre_rects, is_ada = is_ada, + demo_mode = demo_mode, ) # Validate @@ -286,7 +291,7 @@ def compute_pricing( use_fallback = not price_list_path.exists() if use_fallback: - print(f"\n ⚠️ Price list not found — using fallback USD catalog: {price_list_path}") + print(f"\n [WARN] Price list not found — using fallback USD catalog: {price_list_path}") else: print(f"\n Loading price list: {price_list_path.name}") @@ -297,7 +302,7 @@ def compute_pricing( tier = config.get("price_list_tier", 1) matcher = PriceMatcher(price_list_path, tier=tier, eur_usd_rate=eur_usd) except Exception as e: - print(f" ⚠️ Failed to load price list: {e} — using fallback") + print(f" [WARN] Failed to load price list: {e} — using fallback") total_material_cost = 0.0 total_cabinet_count = 0 @@ -305,7 +310,7 @@ def compute_pricing( for unit_type, quantity in unit_totals.items(): schedule = unit_schedules.get(unit_type) if not schedule: - print(f" ⚠️ No schedule found for {unit_type} — using fallback prices") + print(f" [WARN] No schedule found for {unit_type} — using fallback prices") continue unit_cost = 0.0 @@ -335,13 +340,14 @@ def run_pipeline( skip_ai: bool = False, unit_filter: Optional[str] = None, dry_run: bool = False, + demo_mode: bool = False, ) -> PipelineResult: """ Run the complete cabinet estimation pipeline. Args: config_path: Path to project_config.json - skip_ai: If True, use cached JSON instead of calling Claude + skip_ai: If True, use cached JSON instead of calling Gemini Vision unit_filter: If set, only process this unit type (e.g., "A1") dry_run: If True, skip PDF generation (config check only) """ @@ -349,14 +355,15 @@ def run_pipeline( config_path = Path(config_path) project_root = Path.cwd() # resolve PDF paths relative to CWD - print(f"\n{'═' * 60}") - print(f" AI Cabinet Estimation Pipeline") - print(f"{'═' * 60}") + print(f"\n{'=' * 60}") + print(f" AI Cabinet Estimation Pipeline" + + (" [DEMO MODE - low-token]" if demo_mode else "")) + print(f"{'=' * 60}") # ── Check config ─────────────────────────────────────────────────────── config_warnings = validate_config() for w in config_warnings: - print(f" ⚠️ {w}") + print(f" [WARN] {w}") config = load_project_config(config_path) project_name = config["project_name"] @@ -373,13 +380,19 @@ def run_pipeline( # ── Initialize AI classifier ─────────────────────────────────────────── classifier = None if not skip_ai: - if not GROQ_API_KEY: - print("\n [WARN] GROQ_API_KEY not set — running in --skip-ai mode") + if not OPENROUTER_API_KEY: + print("\n [WARN] OPENROUTER_API_KEY not set — running in --skip-ai mode") skip_ai = True else: try: classifier = CabinetVisionClassifier() - print(" [OK] Groq llama-3.2-90b-vision classifier ready") + print(" [OK] OpenRouter vision classifier ready") + print(" [OK] Primary: google/gemini-2.5-flash") + if demo_mode: + print(" [OK] Demo mode: 150 DPI image, compact prompt, 1 retry") + print(" (Est. cost: ~$0.0002/call vs $0.0015 in full mode)") + else: + print(" [OK] Fallback: google/gemini-2.5-pro") except EnvironmentError as e: print(f" [FAIL] {e}") skip_ai = True @@ -392,7 +405,7 @@ def run_pipeline( unit_schedules: dict[str, UnitSchedule] = {} print(f"\n STEP 1: PDF Extraction + AI Classification") - print(f" {'─' * 50}") + print(f" {'-' * 50}") for unit_type, pdf_rel_path in unit_plan_pdfs.items(): if unit_filter and unit_type != unit_filter: @@ -410,12 +423,13 @@ def run_pipeline( classifier = classifier, validator = validator, skip_ai = skip_ai, + demo_mode = demo_mode, ) unit_schedules[unit_type] = schedule # ── Step 2: Unit counts ──────────────────────────────────────────────── print(f"\n STEP 2: Unit Count Matrix") - print(f" {'─' * 50}") + print(f" {'-' * 50}") unit_counts_config = config.get("unit_counts", {}) if unit_counts_config: @@ -431,20 +445,20 @@ def run_pipeline( unit_totals = matrix.totals # ── Step 3–4: Pricing + Job Costing ─────────────────────────────────── - print(f"\n STEP 3: Price Matching (Euro list → USD)") - print(f" {'─' * 50}") + print(f"\n STEP 3: Price Matching (Euro list -> USD)") + print(f" {'-' * 50}") if unit_schedules and any(s.all_cabinets for s in unit_schedules.values()): material_cost_usd, total_cabinet_count = compute_pricing( unit_schedules, unit_totals, config, project_root ) else: - print(" ⚠️ No cabinet schedules available — using manual cost estimate") + print(" [WARN] No cabinet schedules available — using manual cost estimate") material_cost_usd = 0.0 total_cabinet_count = sum(unit_totals.values()) * 10 # rough estimate print(f"\n STEP 4: Job Costing") - print(f" {'─' * 50}") + print(f" {'-' * 50}") jc_input = JobCostingInput( total_cabinet_count = total_cabinet_count, @@ -459,7 +473,7 @@ def run_pipeline( # ── Step 5: Generate Excel ───────────────────────────────────────────── print(f"\n STEP 5: Generating Excel Estimation") - print(f" {'─' * 50}") + print(f" {'-' * 50}") try: from generators.cabinet_excel import generate_excel @@ -471,52 +485,38 @@ def run_pipeline( jc_result = jc_result, output_path = str(excel_path), ) - print(f" ✅ Excel saved: {excel_path}") + print(f" [SUCCESS] Excel saved: {excel_path}") except Exception as e: - print(f" ❌ Excel generation failed: {e}") + print(f" [ERROR] Excel generation failed: {e}") import traceback; traceback.print_exc() # ── Step 6: Generate Shop Drawing PDF ───────────────────────────────── print(f"\n STEP 6: Generating Shop Drawing PDF") - print(f" {'─' * 50}") + print(f" {'-' * 50}") try: pdf_out = output_dir / f"{project_id}_Shop_Drawings.pdf" - if project_id == "23-033": - print(" Using high-fidelity vector compiler for Casa Familia...") - from generate_italiankb_shop_drawings import compile_shop_drawings - compile_shop_drawings( - ref_pdf_path = r"Casa familia\03_Shop_Drawings\ITALIANKB SHOP DRAWINGS - 23-033 CASA FAMILIA - 03.04.2025 hatch corregido.pdf", - output_pdf_path = str(pdf_out) - ) - elif project_id == "23-045": - print(" Using high-fidelity vector compiler for Heritage Village...") - from generate_heritage_shop_drawings import compile_heritage_shop_drawings - compile_heritage_shop_drawings( - ref_dir_path = r"Heritage\01_Architectural_Drawings\Unit_Plans_FHA_ADA", - output_pdf_path = str(pdf_out) - ) - else: - from generators.shop_drawing_pdf import generate_shop_drawings - generate_shop_drawings( - config = config, - unit_schedules = unit_schedules, - unit_totals = unit_totals, - output_path = str(pdf_out), - ) - print(f" ✅ PDF saved: {pdf_out}") + # Always use the universal parameterized generator (works for any project) + from generators.shop_drawing_pdf import generate_shop_drawings + generate_shop_drawings( + config = config, + unit_schedules = unit_schedules, + unit_totals = unit_totals, + output_path = str(pdf_out), + ) + print(f" [SUCCESS] PDF saved: {pdf_out}") except Exception as e: - print(f" ❌ PDF generation failed: {e}") + print(f" [ERROR] PDF generation failed: {e}") import traceback; traceback.print_exc() - # ── Summary ──────────────────────────────────────────────────────────── + # -- Summary ------------------------------------------------------------ duration = time.time() - start_time - print(f"\n{'═' * 60}") - print(f" ✅ PIPELINE COMPLETE in {duration:.1f}s") + print(f"\n{'=' * 60}") + print(f" [SUCCESS] PIPELINE COMPLETE in {duration:.1f}s") print(f" Total cabinets: {total_cabinet_count:,}") print(f" Material cost: ${material_cost_usd:,.2f}") print(f" Selling price: ${jc_result.selling_price:,.2f}") - print(f"{'═' * 60}\n") + print(f"{'=' * 60}\n") return PipelineResult( project_name = project_name, @@ -562,6 +562,10 @@ Examples: "--dry-run", action="store_true", help="Validate config and print plan without executing" ) + parser.add_argument( + "--demo", action="store_true", + help="Demo mode: lower image DPI + compact prompt — saves ~85%% Vision API tokens" + ) return parser.parse_args() @@ -572,4 +576,5 @@ if __name__ == "__main__": skip_ai = args.skip_ai, unit_filter = args.unit, dry_run = args.dry_run, + demo_mode = args.demo, ) diff --git a/Albert_Project/projects/casa_familia/project_config.json b/Albert_Project/projects/casa_familia/project_config.json index 6500a1f..2c4b5b9 100644 --- a/Albert_Project/projects/casa_familia/project_config.json +++ b/Albert_Project/projects/casa_familia/project_config.json @@ -11,39 +11,35 @@ "finish": "K019 SILVER LIBERTY ELM", "door_style": "Shaker", "finish_tier": 1, - "gp_target_pct": 0.35, "commission_pct": 0.05, "bond_pct": 0.015, "price_list_tier": 1, "eur_usd_rate": 1.09, - "price_list_path": "Casa familia/02_Price_List/MS PRICE LIST LEVEL 1 -90CM.xlsx", - "unit_plan_pdfs": { - "A1": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.00-FHA-UNIT-A1-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", + "A1": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.00-FHA-UNIT-A1-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", "A2-ADA": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.01-ADA-UNIT-A2-FULLY-ACCESSIBLE-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", - "A3": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.02-FHA-UNIT-A3-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", - "B1": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.03-FHA-UNIT-B1-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", + "A3": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.02-FHA-UNIT-A3-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", + "B1": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.03-FHA-UNIT-B1-FLOOR-PLAN-&-DETAILS-Rev.10.pdf", "B2-ADA": "Casa familia/01_Architectural_Drawings/Unit_Plans_FHA_ADA/A-6.04-ADA-UNIT-B2-FULLY-ACCESSIBLE-FLOOR-PLAN-&-DETAILS-Rev.10.pdf" }, - "floor_plan_pdfs": [ "Casa familia/01_Architectural_Drawings/Floor_Plans/A-2.00-BLDG-A---GROUND-FLOOR-PLAN-Rev.10.pdf", "Casa familia/01_Architectural_Drawings/Floor_Plans/A-2.01-BLDG-A---2ND-FLOOR-PLAN-Rev.10.pdf", "Casa familia/01_Architectural_Drawings/Floor_Plans/A-2.02-BLDG-A---3RD-FLOOR-PLAN-Rev.10.pdf" ], - "unit_counts": { - "A1": 14, - "A2-ADA": 3, - "A3": 2, - "B1": 3, - "B2-ADA": 3 + "A1": 14, + "A2-ADA": 3, + "A3": 2, + "B1": 3, + "B2-ADA": 3 }, - - "ada_units": ["A2-ADA", "B2-ADA"], - + "ada_units": [ + "A2-ADA", + "B2-ADA" + ], "appliances_regular": [ "28\" REFRIGERATOR GE MODEL GTE18GSNRSS", "30\" GAS RANGE GE MODEL JGBS60SPSS", @@ -56,7 +52,6 @@ "MICROWAVE GE MODEL JEM3072DHWW", "24\" DISHWASHER GE MODEL GDF535PSRSS" ], - "general_notes": [ "ALL CABINETS ARE 90CM DEPTH", "FINISH: K019 SILVER LIBERTY ELM", @@ -65,9 +60,7 @@ "ADA UNITS: BASE CABINET HEIGHT 864MM MAX / COUNTERTOP HEIGHT 34\" MAX", "COORDINATION WITH MECHANICAL AND ELECTRICAL BY OTHERS" ], - "reference_shop_drawing_pdf": "Casa familia/03_Shop_Drawings/ITALIANKB SHOP DRAWINGS - 23-033 CASA FAMILIA.pdf", - "company": { "name": "ITALIAN KITCHEN AND BATH", "tagline": "kitchen | bath | tile | closet", @@ -75,4 +68,4 @@ "phone": "T. 305.599.9000 F. 305.599.9870", "website": "www.italiankitchenandbath.com" } -} +} \ No newline at end of file diff --git a/Albert_Project/requirements.txt b/Albert_Project/requirements.txt index 607dd40..d818756 100644 --- a/Albert_Project/requirements.txt +++ b/Albert_Project/requirements.txt @@ -1,6 +1,9 @@ pymupdf>=1.24.0 reportlab>=4.2.0 openpyxl>=3.1.0 +fastapi>=0.115.0 +uvicorn[standard]>=0.30.0 +python-multipart>=0.0.9 anthropic>=0.25.0 openai>=1.30.0 shapely>=2.0.0 diff --git a/Albert_Project/web_app/app.py b/Albert_Project/web_app/app.py new file mode 100644 index 0000000..5fd72e6 --- /dev/null +++ b/Albert_Project/web_app/app.py @@ -0,0 +1,986 @@ +""" +=========================================================================== + web_app/app.py — FastAPI Backend (Full Production) +=========================================================================== + Endpoints: + GET /api/projects list all projects + POST /api/projects/create create new project from wizard + POST /api/projects/{id}/upload-pdf upload architectural PDF for a unit + POST /api/projects/{id}/upload-price-list upload price list Excel + POST /api/projects/{id}/save-config update financial params + GET /api/projects/{id}/run SSE pipeline stream + GET /api/projects/{id}/results aggregated results + costing + GET /api/projects/{id}/status quick status check + DELETE /api/projects/{id} delete project + outputs + GET /api/projects/{id}/download/pdf serve shop drawing PDF + GET /api/projects/{id}/download/excel serve costing Excel + GET /api/projects/{id}/crops/{file} serve elevation crop PNG + GET /api/projects/{id}/regions/{unit} detected region coords + GET /api/projects/{id}/pdf-pages/{unit} PDF thumbnail PNG + GET / serve static dashboard +=========================================================================== +""" +from __future__ import annotations + +import json +import re +import shutil +import sys +import os +import asyncio +import tempfile +from pathlib import Path +from typing import Any, Optional + +import fitz # PyMuPDF +from fastapi import FastAPI, HTTPException, Request, UploadFile, File, Form +from fastapi.responses import ( + FileResponse, StreamingResponse, Response, JSONResponse +) +from fastapi.staticfiles import StaticFiles +from fastapi.middleware.cors import CORSMiddleware + +# ── Resolve project root ────────────────────────────────────────────────────── +_HERE = Path(__file__).resolve().parent +PROJECT_ROOT = _HERE.parent + +if str(PROJECT_ROOT) not in sys.path: + sys.path.insert(0, str(PROJECT_ROOT)) + +from core.config import get_output_dir, OUTPUTS_ROOT, OPENROUTER_API_KEY # noqa: E402 +from core.ai_vision_classifier import PRIMARY_MODEL, FALLBACK_MODEL, DEMO_MODE # noqa: E402 + +app = FastAPI( + title = "ItalianKB Cabinet Estimator", + description = "AI-powered cabinet shop drawing and job costing automation", + version = "2.0.0", +) + +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +PROJECTS_ROOT = PROJECT_ROOT / "projects" +PROJECTS_ROOT.mkdir(exist_ok=True) +MAX_PDF_UPLOAD_BYTES = 100 * 1024 * 1024 +MAX_EXCEL_UPLOAD_BYTES = 25 * 1024 * 1024 + +# ───────────────────────────────────────────────────────────────────────────── +# INTERNAL HELPERS +# ───────────────────────────────────────────────────────────────────────────── + +def _slugify(text: str) -> str: + """Convert project name/id to a safe folder name.""" + return re.sub(r"[^a-zA-Z0-9_-]", "_", text.strip().lower())[:40] + + +def _validate_project_id(project_id: str) -> str: + """Validate a project id before it is used for folders or output paths.""" + project_id = project_id.strip() + if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_.-]{1,40}", project_id): + raise HTTPException( + 400, + "project_id must be 2-41 characters and contain only letters, " + "numbers, dot, underscore, or hyphen.", + ) + if ".." in project_id: + raise HTTPException(400, "project_id cannot contain '..'.") + return project_id + + +def _safe_upload_name(name: str, fallback: str) -> str: + """Return a safe basename for a user-supplied upload filename.""" + stem = Path(name or fallback).stem + suffix = Path(name or fallback).suffix.lower() + safe_stem = _slugify(stem) or fallback + return f"{safe_stem}{suffix}" + + +def _ensure_inside(child: Path, parent: Path) -> Path: + """Resolve a path and ensure it remains under the expected parent.""" + resolved = child.resolve() + parent = parent.resolve() + if parent not in resolved.parents and resolved != parent: + raise HTTPException(400, "Resolved upload path escaped project folder.") + return resolved + + +def _find_project(project_id: str) -> Optional[tuple[dict, Path, Path]]: + """ + Search all project folders for one matching project_id. + Returns (config_dict, config_path, project_folder) or None. + """ + if not PROJECTS_ROOT.exists(): + return None + for folder in PROJECTS_ROOT.iterdir(): + if not folder.is_dir(): + continue + cfg_path = folder / "project_config.json" + if not cfg_path.exists(): + continue + try: + cfg = json.loads(cfg_path.read_text(encoding="utf-8")) + if cfg.get("project_id") == project_id: + return cfg, cfg_path, folder + except Exception: + continue + return None + + +def _sse(obj: Any) -> str: + return f"data: {json.dumps(obj, ensure_ascii=False)}\n\n" + + +def _default_price_list_path() -> Optional[str]: + """Return relative path to default price list if one exists.""" + # Look for any Excel price list in known locations + candidates = [ + PROJECT_ROOT / "Casa familia" / "02_Price_List" / "MS PRICE LIST LEVEL 1 -90CM.xlsx", + PROJECT_ROOT / "Heritage" / "02_Price_List" / "MS PRICE LIST LEVEL 1 -90CM.xlsx", + ] + for c in candidates: + if c.exists(): + return str(c.relative_to(PROJECT_ROOT)) + return None + + +@app.get("/api/health") +async def health(): + """Production readiness snapshot without exposing any secrets.""" + default_price_list = _default_price_list_path() + project_count = 0 + if PROJECTS_ROOT.exists(): + project_count = sum( + 1 for f in PROJECTS_ROOT.iterdir() + if f.is_dir() and (f / "project_config.json").exists() + ) + return { + "status": "ok", + "version": app.version, + "ai": { + "provider": "OpenRouter", + "primary_model": PRIMARY_MODEL, + "fallback_model": FALLBACK_MODEL, + "openrouter_key_configured": bool(OPENROUTER_API_KEY), + "demo_mode_default": DEMO_MODE, + }, + "storage": { + "projects_root": str(PROJECTS_ROOT), + "outputs_root": str(OUTPUTS_ROOT), + "project_count": project_count, + "default_price_list_available": bool(default_price_list), + "default_price_list_path": default_price_list, + }, + "limits": { + "max_pdf_upload_mb": MAX_PDF_UPLOAD_BYTES // (1024 * 1024), + "max_excel_upload_mb": MAX_EXCEL_UPLOAD_BYTES // (1024 * 1024), + }, + } + + +# ───────────────────────────────────────────────────────────────────────────── +# GET /api/projects — list all +# ───────────────────────────────────────────────────────────────────────────── + +@app.get("/api/projects") +async def list_projects(): + results = [] + if not PROJECTS_ROOT.exists(): + return results + for folder in sorted(PROJECTS_ROOT.iterdir()): + if not folder.is_dir(): + continue + cfg_path = folder / "project_config.json" + if not cfg_path.exists(): + continue + try: + cfg = json.loads(cfg_path.read_text(encoding="utf-8")) + pid = cfg.get("project_id", "") + out_dir = OUTPUTS_ROOT / pid + results.append({ + "id": pid, + "name": cfg.get("project_name", "Unnamed"), + "folder_name": folder.name, + "config": cfg, + "has_results": (out_dir / "json").exists() and + any((out_dir / "json").iterdir()), + "has_pdf": (out_dir / f"{pid}_Shop_Drawings.pdf").exists(), + "has_excel": (out_dir / f"{pid}_Cabinet_Estimation.xlsx").exists(), + }) + except Exception as exc: + print(f"[WARN] Cannot read {cfg_path}: {exc}") + return results + + +# ───────────────────────────────────────────────────────────────────────────── +# POST /api/projects/create — create new project from wizard +# ───────────────────────────────────────────────────────────────────────────── + +@app.post("/api/projects/create") +async def create_project(request: Request): + """ + Create a new project from the wizard. + Expects JSON body matching the project config schema. + Automatically fills in price_list_path with the default if not provided. + """ + try: + body = await request.json() + except Exception as exc: + raise HTTPException(400, f"Invalid JSON: {exc}") + + project_id = _validate_project_id(body.get("project_id", "")) + project_name = body.get("project_name", "").strip() + if not project_name: + raise HTTPException(400, "project_name is required") + + # Check for duplicate + if _find_project(project_id): + raise HTTPException(409, f"Project ID '{project_id}' already exists.") + + # Create project folder + folder_name = _slugify(project_id) + project_folder = PROJECTS_ROOT / folder_name + counter = 0 + while project_folder.exists(): + counter += 1 + project_folder = PROJECTS_ROOT / f"{folder_name}_{counter}" + project_folder.mkdir(parents=True) + (project_folder / "drawings").mkdir() + + # If no price list path provided, use the default ItalianKB list + if not body.get("price_list_path"): + default = _default_price_list_path() + if default: + body["price_list_path"] = default + + # Build full config + config = { + "project_id": project_id, + "project_name": project_name, + "date": body.get("date", ""), + "revision": body.get("revision", "1.0"), + "drawn_by": body.get("drawn_by", ""), + "checker": body.get("checker", ""), + "client_name": body.get("client_name", ""), + "architect": body.get("architect", ""), + "project_address": body.get("project_address", ""), + "cabinet_finish": body.get("cabinet_finish", ""), + "door_style": body.get("door_style", ""), + "finish_tier": body.get("finish_tier", 1), + + "gp_target_pct": float(body.get("gp_target_pct", 0.35)), + "commission_pct": float(body.get("commission_pct", 0.05)), + "bond_pct": float(body.get("bond_pct", 0.015)), + "price_list_tier": int(body.get("price_list_tier", 1)), + "eur_usd_rate": float(body.get("eur_usd_rate", 1.09)), + + "price_list_path": body.get("price_list_path", ""), + + # Will be populated by upload-pdf endpoint + "unit_plan_pdfs": body.get("unit_plan_pdfs", {}), + "unit_counts": body.get("unit_counts", {}), + "ada_units": body.get("ada_units", []), + + "floor_plan_pdfs": body.get("floor_plan_pdfs", []), + + "appliances_regular": body.get("appliances_regular", []), + "appliances_ada": body.get("appliances_ada", []), + "general_notes": body.get("general_notes", [ + "ALL CABINETS ARE 90CM DEPTH", + "ALL HARDWARE CONCEALED", + "SOFT CLOSE DOORS AND DRAWERS STANDARD", + ]), + + "company": body.get("company", { + "name": "ITALIAN KITCHEN AND BATH", + "tagline": "kitchen | bath | tile | closet", + "address": "1777 NW 72TH AVE. MIAMI FL, 33126", + "phone": "T. 305.599.9000 F. 305.599.9870", + "website": "www.italiankitchenandbath.com", + }), + } + + cfg_path = project_folder / "project_config.json" + cfg_path.write_text( + json.dumps(config, indent=2, ensure_ascii=False), + encoding="utf-8", + ) + + # Create output directory structure + get_output_dir(project_id) + + return { + "status": "created", + "project_id": project_id, + "folder": project_folder.name, + "config": config, + } + + +# ───────────────────────────────────────────────────────────────────────────── +# POST /api/projects/{id}/upload-pdf — upload architectural PDF +# ───────────────────────────────────────────────────────────────────────────── + +@app.post("/api/projects/{project_id}/upload-pdf") +async def upload_pdf( + project_id: str, + unit_type: str = Form(...), + is_ada: bool = Form(False), + file: UploadFile = File(...), +): + """ + Upload one architectural PDF for a specific unit type. + Saves to projects/{folder}/drawings/{unit_type}.pdf + Updates project_config.json with the new unit_plan_pdfs entry. + """ + result = _find_project(project_id) + if result is None: + raise HTTPException(404, f"Project '{project_id}' not found") + cfg, cfg_path, project_folder = result + + if not file.filename.lower().endswith(".pdf"): + raise HTTPException(400, "Only PDF files are accepted for unit drawings.") + + unit_type = unit_type.strip() + if not unit_type: + raise HTTPException(400, "unit_type is required.") + + # Save the PDF + drawings_dir = project_folder / "drawings" + drawings_dir.mkdir(exist_ok=True) + + safe_unit = _slugify(unit_type) + if not safe_unit: + raise HTTPException(400, "unit_type must contain letters or numbers.") + dest = _ensure_inside(drawings_dir / f"{safe_unit}.pdf", drawings_dir) + content = await file.read() + if not content: + raise HTTPException(400, "Uploaded PDF is empty.") + if len(content) > MAX_PDF_UPLOAD_BYTES: + raise HTTPException(413, "PDF upload exceeds 100 MB limit.") + + try: + doc = fitz.open(stream=content, filetype="pdf") + page_count = doc.page_count + doc.close() + except Exception as exc: + raise HTTPException(400, f"Uploaded file is not a valid PDF: {exc}") + + dest.write_bytes(content) + + # Update config — store path RELATIVE to PROJECT_ROOT + rel_path = str(dest.relative_to(PROJECT_ROOT)) + cfg.setdefault("unit_plan_pdfs", {})[unit_type] = rel_path + + # Track ADA status + ada_units = set(cfg.get("ada_units", [])) + if is_ada: + ada_units.add(unit_type) + else: + ada_units.discard(unit_type) + cfg["ada_units"] = sorted(ada_units) + + cfg_path.write_text( + json.dumps(cfg, indent=2, ensure_ascii=False), + encoding="utf-8", + ) + + return { + "status": "uploaded", + "unit_type": unit_type, + "path": rel_path, + "pages": page_count, + "size_kb": round(len(content) / 1024, 1), + } + + +# ───────────────────────────────────────────────────────────────────────────── +# POST /api/projects/{id}/upload-price-list — upload Excel price list +# ───────────────────────────────────────────────────────────────────────────── + +@app.post("/api/projects/{project_id}/upload-price-list") +async def upload_price_list( + project_id: str, + file: UploadFile = File(...), +): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, f"Project '{project_id}' not found") + cfg, cfg_path, project_folder = result + + if not file.filename.lower().endswith(".xlsx"): + raise HTTPException(400, "Only .xlsx Excel files are accepted.") + + dest = _ensure_inside(project_folder / "price_list.xlsx", project_folder) + content = await file.read() + if not content: + raise HTTPException(400, "Uploaded price list is empty.") + if len(content) > MAX_EXCEL_UPLOAD_BYTES: + raise HTTPException(413, "Price list upload exceeds 25 MB limit.") + + tmp_path = None + try: + from openpyxl import load_workbook + with tempfile.NamedTemporaryFile(suffix=".xlsx", delete=False) as tmp: + tmp.write(content) + tmp_path = tmp.name + wb = load_workbook(tmp_path, read_only=True, data_only=True) + sheet_count = len(wb.sheetnames) + wb.close() + Path(tmp_path).unlink(missing_ok=True) + except Exception as exc: + if tmp_path: + try: + Path(tmp_path).unlink(missing_ok=True) + except Exception: + pass + raise HTTPException(400, f"Uploaded file is not a valid .xlsx workbook: {exc}") + + dest.write_bytes(content) + + rel_path = str(dest.relative_to(PROJECT_ROOT)) + cfg["price_list_path"] = rel_path + cfg_path.write_text( + json.dumps(cfg, indent=2, ensure_ascii=False), + encoding="utf-8", + ) + + return { + "status": "uploaded", + "path": rel_path, + "sheets": sheet_count, + "size_kb": round(len(content) / 1024, 1), + } + + +# ───────────────────────────────────────────────────────────────────────────── +# POST /api/projects/{id}/save-config — update project config +# ───────────────────────────────────────────────────────────────────────────── + +@app.post("/api/projects/{project_id}/save-config") +async def save_config(project_id: str, request: Request): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, f"Project '{project_id}' not found") + _, cfg_path, _ = result + + try: + new_config = await request.json() + except Exception as exc: + raise HTTPException(400, f"Invalid JSON body: {exc}") + + cfg_path.write_text( + json.dumps(new_config, indent=2, ensure_ascii=False), + encoding="utf-8", + ) + return {"status": "ok", "message": "Configuration saved."} + + +# ───────────────────────────────────────────────────────────────────────────── +# DELETE /api/projects/{id} — delete project + outputs +# ───────────────────────────────────────────────────────────────────────────── + +@app.delete("/api/projects/{project_id}") +async def delete_project(project_id: str): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, f"Project '{project_id}' not found") + _, _, project_folder = result + + # Remove project folder + shutil.rmtree(project_folder, ignore_errors=True) + + # Remove outputs folder + out_dir = OUTPUTS_ROOT / project_id + if out_dir.exists(): + shutil.rmtree(out_dir, ignore_errors=True) + + return {"status": "deleted", "project_id": project_id} + + +# ───────────────────────────────────────────────────────────────────────────── +# GET /api/projects/{id}/status — quick status check +# ───────────────────────────────────────────────────────────────────────────── + +@app.get("/api/projects/{project_id}/status") +async def project_status(project_id: str): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, f"Project '{project_id}' not found") + cfg, _, _ = result + out_dir = OUTPUTS_ROOT / project_id + + json_dir = out_dir / "json" + has_cache = json_dir.exists() and any(json_dir.glob("cabinet_schedule_*.json")) + has_pdf = (out_dir / f"{project_id}_Shop_Drawings.pdf").exists() + has_excel = (out_dir / f"{project_id}_Cabinet_Estimation.xlsx").exists() + + unit_pdfs = cfg.get("unit_plan_pdfs", {}) + pdfs_ok = { + u: (PROJECT_ROOT / p).exists() + for u, p in unit_pdfs.items() + } + + return { + "project_id": project_id, + "project_name": cfg.get("project_name"), + "units": list(unit_pdfs.keys()), + "pdf_files_ok": pdfs_ok, + "ai_ready": bool(OPENROUTER_API_KEY), + "price_list_ok": bool(cfg.get("price_list_path")) and + (PROJECT_ROOT / cfg.get("price_list_path", "")).exists(), + "has_cache": has_cache, + "has_pdf": has_pdf, + "has_excel": has_excel, + "ready_to_run": bool(unit_pdfs) and all(pdfs_ok.values()), + } + + +# ───────────────────────────────────────────────────────────────────────────── +# GET /api/projects/{id}/run — run pipeline via SSE +# ───────────────────────────────────────────────────────────────────────────── + +@app.get("/api/projects/{project_id}/run") +async def run_pipeline( + project_id: str, + skip_ai: bool = True, + unit: str = None, + demo: bool = False, +): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, "Project not found") + _, cfg_path, _ = result + + cmd = [sys.executable, str(PROJECT_ROOT / "pipeline.py"), + "--project", str(cfg_path)] + if skip_ai: + cmd.append("--skip-ai") + if unit: + cmd += ["--unit", unit] + if demo: + cmd.append("--demo") + + async def generator(): + mode_label = "DEMO (low-token)" if demo else "FULL" + launch_msg = f"[{mode_label}] Launching: " + " ".join(str(c) for c in cmd) + yield _sse({"log": f"[SYSTEM] {launch_msg}"}) + + try: + env = {**os.environ, "PYTHONIOENCODING": "utf-8"} + proc = await asyncio.create_subprocess_exec( + *cmd, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.STDOUT, + cwd=str(PROJECT_ROOT), + env=env, + ) + except Exception as exc: + yield _sse({"log": f"[ERROR] Cannot start process: {exc}", + "done": True, "success": False}) + return + + while True: + line = await proc.stdout.readline() + if not line: + break + text = line.decode("utf-8", errors="replace").rstrip("\r\n") + if text: + yield _sse({"log": text}) + + code = await proc.wait() + yield _sse({ + "log": f"[SYSTEM] Pipeline finished (exit {code}).", + "done": True, + "success": code == 0, + }) + + return StreamingResponse( + generator(), + media_type="text/event-stream", + headers={ + "Cache-Control": "no-cache", + "X-Accel-Buffering": "no", + }, + ) + + + +# ───────────────────────────────────────────────────────────────────────────── +# GET /api/projects/{id}/results — aggregated results +# ───────────────────────────────────────────────────────────────────────────── + +@app.get("/api/projects/{project_id}/results") +async def get_results(project_id: str): + out_dir = OUTPUTS_ROOT / project_id + if not out_dir.exists(): + return JSONResponse( + status_code=404, + content={"detail": "No outputs yet — run the pipeline first."}, + ) + + result = _find_project(project_id) + if result is None: + return JSONResponse( + status_code=404, + content={"detail": "Project config not found."}, + ) + config, _, _ = result + + # ── Load cached JSON schedules ────────────────────────────────────────── + unit_schedules: dict = {} + json_dir = out_dir / "json" + if json_dir.exists(): + for f in json_dir.iterdir(): + if f.suffix != ".json" or not f.name.startswith("cabinet_schedule_"): + continue + raw_key = f.stem.replace("cabinet_schedule_", "") + # Find matching key in config (handles underscore/hyphen normalization) + unit_keys = list(config.get("unit_plan_pdfs", {}).keys()) + matched_key = raw_key + for k in unit_keys: + if k.replace(" ", "_").replace("-", "_") == raw_key: + matched_key = k + break + try: + unit_schedules[matched_key] = json.loads( + f.read_text(encoding="utf-8") + ) + except Exception as exc: + print(f"[WARN] Cannot parse {f.name}: {exc}") + + # ── Price matching ────────────────────────────────────────────────────── + unit_totals = config.get("unit_counts", {}) + price_list = PROJECT_ROOT / config.get("price_list_path", "") + matcher = None + + if price_list.exists(): + try: + from core.price_matcher import PriceMatcher + matcher = PriceMatcher( + price_list, + tier=config.get("price_list_tier", 1), + eur_usd_rate=config.get("eur_usd_rate", 1.09), + ) + except Exception as exc: + print(f"[WARN] PriceMatcher failed: {exc}") + + from core.price_matcher import _generate_code, get_fallback_price_usd + from core.ai_vision_classifier import CabinetItem + + total_material = 0.0 + total_cabs = 0 + line_items = [] + + for unit_type, qty in unit_totals.items(): + sched = unit_schedules.get(unit_type) + if not sched: + continue + for ev in sched.get("elevations", []): + for cab_data in ev.get("cabinets", []): + try: + cab = CabinetItem(**cab_data) + except Exception: + continue + if cab.cabinet_type == "appliance_space": + continue + + unit_price = 0.0 + unit_price_eur = 0.0 + match_quality = "NOT_FOUND" + matched_desc = cab.cabinet_type + h_mm = cab.height_mm + d_mm = cab.depth_mm + cab_code = cab.code + + if matcher: + res = matcher.match( + cab.cabinet_type, cab.width_mm, quantity=cab.quantity + ) + unit_price = res.price_usd + unit_price_eur = res.price_eur + match_quality = res.match_quality + if res.matched_entry: + matched_desc = res.matched_entry.description + h_mm = res.matched_entry.height_mm + d_mm = res.matched_entry.depth_mm + else: + code = _generate_code(cab.cabinet_type, cab.width_mm) + unit_price = get_fallback_price_usd(code) + unit_price_eur = unit_price / config.get("eur_usd_rate", 1.09) + match_quality = "FALLBACK" + + cab_count = cab.quantity * qty + total_material += unit_price * cab_count + total_cabs += cab_count + + line_items.append({ + "unit_type": unit_type, + "elevation": ev.get("elevation_label"), + "item_num": cab.item_num, + "type": cab.cabinet_type, + "code": cab_code, + "width_mm": cab.width_mm, + "height_mm": h_mm, + "depth_mm": d_mm, + "confidence": cab.confidence, + "quantity": cab.quantity, + "unit_qty": qty, + "total_qty": cab_count, + "unit_price_usd": unit_price, + "unit_price_eur": unit_price_eur, + "total_price_usd": unit_price * cab_count, + "match_quality": match_quality, + "matched_desc": matched_desc, + "notes": cab.notes, + "source": cab.source, + "is_ada": cab.is_ada, + }) + + validation_flags = [] + low_confidence_items = [] + invalid_dimension_items = [] + schedule_review_flags = [] + price_match_counts = {} + + for unit_type, sched in unit_schedules.items(): + for flag in sched.get("review_flags", []) or []: + schedule_review_flags.append({"unit_type": unit_type, "flag": flag}) + validation_flags.append(f"{unit_type}: {flag}") + for ev in sched.get("elevations", []) or []: + elev_label = ev.get("elevation_label") + for flag in ev.get("review_flags", []) or []: + schedule_review_flags.append({ + "unit_type": unit_type, + "elevation": elev_label, + "flag": flag, + }) + validation_flags.append(f"{unit_type}/{elev_label}: {flag}") + for cab in ev.get("cabinets", []) or []: + conf = float(cab.get("confidence") or 0) + if conf < 0.70: + low_confidence_items.append({ + "unit_type": unit_type, + "elevation": elev_label, + "item_num": cab.get("item_num"), + "type": cab.get("cabinet_type"), + "confidence": conf, + }) + if any(float(cab.get(k) or 0) <= 0 for k in ("width_mm", "height_mm", "depth_mm")): + invalid_dimension_items.append({ + "unit_type": unit_type, + "elevation": elev_label, + "item_num": cab.get("item_num"), + "type": cab.get("cabinet_type"), + "width_mm": cab.get("width_mm"), + "height_mm": cab.get("height_mm"), + "depth_mm": cab.get("depth_mm"), + }) + + for item in line_items: + quality = item.get("match_quality", "UNKNOWN") + price_match_counts[quality] = price_match_counts.get(quality, 0) + 1 + if quality == "NOT_FOUND": + validation_flags.append( + f"{item.get('unit_type')}/{item.get('elevation')} item " + f"{item.get('item_num')}: price match not found" + ) + + if invalid_dimension_items: + validation_flags.append( + f"{len(invalid_dimension_items)} cabinet item(s) have missing or zero dimensions" + ) + if low_confidence_items: + validation_flags.append( + f"{len(low_confidence_items)} cabinet item(s) below 70% confidence" + ) + + validation = { + "status": "PASS" if not validation_flags else "REVIEW", + "flag_count": len(validation_flags), + "flags": validation_flags[:50], + "review_flags": schedule_review_flags, + "low_confidence_items": low_confidence_items, + "invalid_dimension_items": invalid_dimension_items, + "price_match_counts": price_match_counts, + } + + # ── Job costing ───────────────────────────────────────────────────────── + from core.job_costing import JobCostingInput, calculate_selling_price + jc = calculate_selling_price(JobCostingInput( + total_cabinet_count = max(total_cabs, 1), + material_cost_usd = total_material, + gp_target_pct = config.get("gp_target_pct", 0.35), + commission_pct = config.get("commission_pct", 0.05), + bond_pct = config.get("bond_pct", 0.015), + )) + + costing = { + "material_cost": jc.material_cost, + "local_use_tax": jc.local_use_tax, + "ocean_freight": jc.ocean_freight, + "inland_delivery": jc.inland_delivery, + "installation": jc.installation, + "warehousing": jc.warehousing, + "material_protection": jc.material_protection, + "insurance": jc.insurance, + "misc_allowance": jc.misc_allowance, + "pre_margin_total": jc.pre_margin_total, + "selling_price": jc.selling_price, + "gross_profit": jc.gross_profit, + "total_cost": jc.total_cost, + "containers_needed": jc.containers_needed, + "cost_per_cabinet": jc.cost_per_cabinet, + "sell_per_cabinet": jc.sell_per_cabinet, + "gp_pct": jc.gp_pct, + "commission_pct": jc.commission_pct, + "bond_pct": jc.bond_pct, + "total_cabinet_count": total_cabs, + } + + api_calls = sum( + ev.get("api_calls", 1) + for sched in unit_schedules.values() + for ev in sched.get("elevations", []) + ) + tok_in = api_calls * 5_000 + tok_out = api_calls * 350 + metrics = { + "api_calls": api_calls, + "input_tokens": tok_in, + "output_tokens": tok_out, + "total_cost_usd": tok_in / 1_000_000 * 1.5 + tok_out / 1_000_000 * 3.0, + "primary_model": "google/gemini-2.5-flash", + "fallback_model": "google/gemini-2.5-pro", + } + + return { + "unit_schedules": unit_schedules, + "cabinet_line_items": line_items, + "costing": costing, + "config": config, + "metrics": metrics, + "validation": validation, + "outputs": { + "pdf_ready": (out_dir / f"{project_id}_Shop_Drawings.pdf").exists(), + "xlsx_ready": (out_dir / f"{project_id}_Cabinet_Estimation.xlsx").exists(), + }, + } + + +# ───────────────────────────────────────────────────────────────────────────── +# DOWNLOADS +# ───────────────────────────────────────────────────────────────────────────── + +@app.get("/api/projects/{project_id}/download/pdf") +async def download_pdf(project_id: str): + p = OUTPUTS_ROOT / project_id / f"{project_id}_Shop_Drawings.pdf" + if not p.exists(): + raise HTTPException(404, "PDF not generated yet — run the pipeline.") + return FileResponse(str(p), filename=p.name, media_type="application/pdf") + + +@app.get("/api/projects/{project_id}/download/excel") +async def download_excel(project_id: str): + p = OUTPUTS_ROOT / project_id / f"{project_id}_Cabinet_Estimation.xlsx" + if not p.exists(): + raise HTTPException(404, "Excel not generated yet — run the pipeline.") + return FileResponse( + str(p), filename=p.name, + media_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ) + + +# ───────────────────────────────────────────────────────────────────────────── +# CROPS + REGION OVERLAY + PDF THUMBNAIL +# ───────────────────────────────────────────────────────────────────────────── + +@app.get("/api/projects/{project_id}/crops/{filename}") +async def serve_crop(project_id: str, filename: str): + p = OUTPUTS_ROOT / project_id / "crops" / filename + if not p.exists(): + raise HTTPException(404, f"Crop not found: {filename}") + return FileResponse(str(p), media_type="image/png") + + +@app.get("/api/projects/{project_id}/regions/{unit_type:path}") +async def get_regions(project_id: str, unit_type: str): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, "Config not found") + config, _, _ = result + + unit_type = unit_type.replace("+", " ") + unit_plan_pdfs = config.get("unit_plan_pdfs", {}) + if unit_type not in unit_plan_pdfs: + raise HTTPException(404, f"Unit {unit_type!r} not in config") + + pdf_path = PROJECT_ROOT / unit_plan_pdfs[unit_type] + if not pdf_path.exists(): + raise HTTPException(404, f"PDF not found: {pdf_path.name}") + + try: + from core.pdf_extractor import PDFExtractor + from core.region_detector import RegionDetector + with PDFExtractor(pdf_path) as ex: + page = ex.extract_page(0) + regions = RegionDetector( + page.spans, page.rects, page.page_w, page.page_h + ).detect() + return { + "page_w": page.page_w, + "page_h": page.page_h, + "regions": [ + { + "region_type": r.region_type, + "label": r.label, + "bbox": [r.x0, r.y0, r.x1, r.y1], + "confidence": r.confidence, + } + for r in regions + ], + } + except Exception as exc: + raise HTTPException(500, f"Region detection failed: {exc}") + + +@app.get("/api/projects/{project_id}/pdf-pages/{unit_type:path}") +async def pdf_page_image(project_id: str, unit_type: str): + result = _find_project(project_id) + if result is None: + raise HTTPException(404, "Config not found") + config, _, _ = result + + unit_type = unit_type.replace("+", " ") + pdf_path = PROJECT_ROOT / config.get("unit_plan_pdfs", {}).get(unit_type, "") + if not pdf_path.exists(): + raise HTTPException(404, f"PDF not found for unit {unit_type!r}") + + try: + doc = fitz.open(str(pdf_path)) + pix = doc[0].get_pixmap(dpi=120) + img = pix.tobytes("png") + doc.close() + return Response(content=img, media_type="image/png") + except Exception as exc: + raise HTTPException(500, f"Render failed: {exc}") + + +# ───────────────────────────────────────────────────────────────────────────── +# STATIC FILES — must be mounted last +# ───────────────────────────────────────────────────────────────────────────── + +app.mount( + "/", + StaticFiles(directory=str(_HERE / "static"), html=True), + name="static", +) + +if __name__ == "__main__": + import uvicorn + uvicorn.run("web_app.app:app", host="127.0.0.1", port=8080, reload=True, + app_dir=str(PROJECT_ROOT)) diff --git a/Albert_Project/web_app/static/app.js b/Albert_Project/web_app/static/app.js new file mode 100644 index 0000000..761b5c2 --- /dev/null +++ b/Albert_Project/web_app/static/app.js @@ -0,0 +1,1180 @@ +/* +=========================================================================== + app.js — ItalianKB Cabinet Estimator Dashboard (Production v2.0) +=========================================================================== + Features: + - Dynamic project selection (any number of projects) + - 5-step New Project wizard (upload PDFs, price list, configure) + - Pipeline SSE streaming with live logs + - Cabinet schedule accordion with crop previews + - Job costing sheet + donut chart + - Developer overlay + JSON inspector + - Toast notifications, search filter, clipboard copy +=========================================================================== +*/ +"use strict"; + +// ───────────────────────────────────────────────────────────────────────────── +// STATE +// ───────────────────────────────────────────────────────────────────────────── +let projects = []; // full list from /api/projects +let active = null; // current {id, name, config, ...} +let donutChart = null; +let activeSSE = null; // live EventSource during pipeline run +let systemHealth = null; +let activeStatus = null; +let activeValidation = null; + +// Wizard state +const wiz = { + step: 1, + pdfFiles: [], // [{file, unitType, isAda}] + xlFile: null, + projectId: null, // set after /create +}; + +// ───────────────────────────────────────────────────────────────────────────── +// DOM SHORTCUTS +// ───────────────────────────────────────────────────────────────────────────── +const $ = id => document.getElementById(id); +const $$ = sel => document.querySelectorAll(sel); + +// Sidebar +const projectSel = $('project-select'); +const configForm = $('config-form'); +const newProjBtn = $('new-project-btn'); +const delProjBtn = $('delete-project-btn'); +const projInfoCard= $('project-info-card'); +const infClient = $('inf-client'); +const infAddress = $('inf-address'); +const infFinish = $('inf-finish'); +const infDoor = $('inf-door'); +const infUnits = $('inf-units'); + +// Header +const projTitle = $('display-project-name'); +const projMeta = $('display-project-meta'); +const runBtn = $('run-btn'); +const skipAiTog = $('skip-ai-toggle'); +const statusChip = $('pipeline-status-chip'); +const statusDot = $('status-dot'); +const statusText = $('status-text'); +const readinessBanner = $('readiness-banner'); + +// KPI +const kpiSell = $('stat-selling'); +const kpiGP = $('stat-gp'); +const kpiMat = $('stat-material'); +const kpiRate = $('stat-rate'); +const kpiCabs = $('stat-cabs'); +const kpiCtrs = $('stat-ctrs'); +const kpiAI = $('stat-aicost'); +const kpiCalls = $('stat-aicalls'); + +// Downloads +const dlPdf = $('dl-pdf'); +const dlXlsx = $('dl-xlsx'); + +// Console +const consolePanel = $('console-panel'); +const consoleBar = $('console-bar'); +const consoleBody = $('console-body'); +const cnslToggle = $('cnsl-toggle'); +const cnslClear = $('cnsl-clear'); +const dotInd = $('dot-ind'); + +// Crop tooltip +const cropTip = $('crop-tip'); +const cropTipImg = $('crop-tip-img'); + +// Dev tab +const devUnitSel = $('dev-unit-sel'); +const overlayCont = $('overlay-container'); +const jsonViewer = $('json-viewer'); + +// Wizard +const wizOverlay = $('wizard-overlay'); +const wizClose = $('wizard-close'); +const wizNext = $('wizard-next'); +const wizBack = $('wizard-back'); +const wizCreate = $('wizard-create'); +const wizSubtitle = $('wizard-subtitle'); + +const pdfDropzone = $('pdf-dropzone'); +const pdfFileInput = $('pdf-file-input'); +const pdfFileList = $('pdf-file-list'); +const xlDropzone = $('xl-dropzone'); +const xlFileInput = $('xl-file-input'); +const xlFileInfo = $('xl-file-info'); +const xlFileName = $('xl-file-name'); +const xlRemoveBtn = $('xl-file-remove'); + +// ───────────────────────────────────────────────────────────────────────────── +// BOOT +// ───────────────────────────────────────────────────────────────────────────── +document.addEventListener('DOMContentLoaded', () => { + initTabs(); + initConsole(); + initCropTip(); + initJsonControls(); + initWizard(); + loadHealth(); + loadProjects(); + + runBtn.addEventListener('click', handleRunPipeline); + skipAiTog?.addEventListener('change', renderReadiness); + $('demo-mode-toggle')?.addEventListener('change', renderReadiness); +}); + +async function loadHealth() { + try { + const res = await fetch('/api/health'); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + systemHealth = await res.json(); + renderReadiness(); + const aiMsg = systemHealth.ai?.openrouter_key_configured + ? `Vision ready: ${systemHealth.ai.primary_model}` + : 'Vision key missing: live AI runs will require OPENROUTER_API_KEY or Skip Vision AI.'; + syslog(aiMsg); + } catch (e) { + systemHealth = null; + log(`[WARN] Health check failed: ${e.message}`, 'warn'); + } +} + +async function loadProjectStatus(projectId) { + try { + const res = await fetch(`/api/projects/${projectId}/status`); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + activeStatus = await res.json(); + renderReadiness(); + } catch (e) { + activeStatus = null; + log(`[WARN] Status check failed: ${e.message}`, 'warn'); + renderReadiness(); + } +} + +function esc(value) { + return String(value ?? '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +} + +function renderReadiness() { + if (!readinessBanner) return; + const pills = []; + const issues = []; + + const aiReady = !!systemHealth?.ai?.openrouter_key_configured; + pills.push({label: aiReady ? 'Vision key set' : 'Vision key missing', state: aiReady ? 'ok' : 'warn'}); + + if (activeStatus) { + const pdfReady = !!activeStatus.ready_to_run; + const priceReady = !!activeStatus.price_list_ok; + const outputsReady = !!(activeStatus.has_pdf && activeStatus.has_excel); + pills.push({label: pdfReady ? 'PDF inputs ready' : 'PDF inputs missing', state: pdfReady ? 'ok' : 'err'}); + pills.push({label: priceReady ? 'Price list ready' : 'Price list missing', state: priceReady ? 'ok' : 'warn'}); + pills.push({label: outputsReady ? 'Outputs generated' : 'Outputs not generated', state: outputsReady ? 'ok' : 'warn'}); + if (!pdfReady) issues.push('Upload at least one valid unit PDF before running.'); + if (!priceReady) issues.push('Upload a price list or use the default catalog.'); + if (!aiReady && !skipAiTog.checked) issues.push('Add OPENROUTER_API_KEY in .env or enable Skip Vision AI.'); + } else if (active) { + issues.push('Checking project readiness...'); + } else { + issues.push('Select an existing project or create a fresh uploaded project.'); + } + + if (activeValidation) { + const validationOk = activeValidation.status === 'PASS'; + pills.push({ + label: validationOk ? 'Validation pass' : `${activeValidation.flag_count || 0} validation flags`, + state: validationOk ? 'ok' : 'warn', + }); + if (!validationOk && activeValidation.flags?.length) { + issues.push(activeValidation.flags.slice(0, 2).join(' | ')); + } + } + + const hasError = pills.some(p => p.state === 'err'); + const hasWarn = pills.some(p => p.state === 'warn') || issues.length > 0; + const state = hasError ? 'err' : hasWarn ? 'warn' : 'ok'; + const title = state === 'ok' ? 'Production readiness: ready' : + state === 'err' ? 'Production readiness: blocked' : + 'Production readiness: attention needed'; + const detail = issues.length ? issues.join(' ') : 'Inputs, outputs, price data, and validation are ready.'; + + readinessBanner.className = `readiness-banner glass ${state}`; + readinessBanner.style.display = 'flex'; + readinessBanner.innerHTML = ` +
+
${esc(title)}
+
${esc(detail)}
+
+
+ ${pills.map(p => `${esc(p.label)}`).join('')} +
`; +} + +// ───────────────────────────────────────────────────────────────────────────── +// TABS +// ───────────────────────────────────────────────────────────────────────────── +function initTabs() { + $$('.tab-btn').forEach(btn => btn.addEventListener('click', () => { + $$('.tab-btn').forEach(b => { b.classList.remove('active'); b.setAttribute('aria-selected','false'); }); + $$('.tab-pane').forEach(p => p.classList.remove('active')); + btn.classList.add('active'); + btn.setAttribute('aria-selected','true'); + const pane = $(btn.dataset.tab); + if (pane) pane.classList.add('active'); + if (btn.dataset.tab === 'tab-costing' && donutChart) donutChart.resize(); + })); +} + +// ───────────────────────────────────────────────────────────────────────────── +// LOAD PROJECTS +// ───────────────────────────────────────────────────────────────────────────── +async function loadProjects() { + try { + const res = await fetch('/api/projects'); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + projects = await res.json(); + + projectSel.innerHTML = ''; + projects.forEach(p => { + const opt = document.createElement('option'); + opt.value = p.id; + opt.textContent = `${p.name} (${p.id})`; + projectSel.appendChild(opt); + }); + + projectSel.onchange = () => { + const p = projects.find(x => x.id === projectSel.value); + if (p) selectProject(p); + }; + + // Auto-select the first project if available + if (projects.length >= 1) { + projectSel.value = projects[0].id; + selectProject(projects[0]); + } + + syslog(`Loaded ${projects.length} project(s).`); + } catch (e) { + log(`[ERROR] Could not load projects: ${e.message}`, 'err'); + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// SELECT PROJECT +// ───────────────────────────────────────────────────────────────────────────── +function selectProject(proj) { + active = proj; + activeStatus = null; + activeValidation = null; + const cfg = proj.config; + + projTitle.textContent = proj.name; + projMeta.textContent = `ID: ${proj.id} • Rev: ${cfg.revision || '1.0'} • ${cfg.client_name || cfg.owner || ''}`; + + runBtn.disabled = false; + delProjBtn.style.display = 'block'; + statusChip.style.display = 'flex'; + projInfoCard.style.display = 'block'; + + infClient.textContent = cfg.client_name || cfg.owner || '—'; + infAddress.textContent = (cfg.project_address || cfg.address || '—').substring(0, 45); + infFinish.textContent = cfg.cabinet_finish || cfg.finish || '—'; + infDoor.textContent = cfg.door_style || '—'; + infUnits.textContent = Object.keys(cfg.unit_plan_pdfs || {}).join(', ') || '—'; + + renderConfigForm(cfg); + + dlPdf.href = `/api/projects/${proj.id}/download/pdf`; + dlXlsx.href = `/api/projects/${proj.id}/download/excel`; + + // Dev unit selector — replace node to clear stale listeners + const newSel = devUnitSel.cloneNode(false); + newSel.id = 'dev-unit-sel'; + newSel.className = 'ctrl-input-sm'; + newSel.innerHTML = ''; + Object.keys(cfg.unit_plan_pdfs || {}).forEach(u => { + const o = document.createElement('option'); + o.value = u; o.textContent = u; + newSel.appendChild(o); + }); + devUnitSel.replaceWith(newSel); + newSel.addEventListener('change', () => loadOverlay(proj.id, newSel.value)); + + overlayCont.innerHTML = '

Select a unit above to view region overlay.

'; + jsonViewer.textContent = '// Load results to see JSON output.'; + resetKPIs(); + renderReadiness(); + loadProjectStatus(proj.id); + + loadResults(proj.id); + syslog(`Project selected: ${proj.name}`); +} + +// ───────────────────────────────────────────────────────────────────────────── +// CONFIG FORM (sidebar) +// ───────────────────────────────────────────────────────────────────────────── +function renderConfigForm(cfg) { + configForm.innerHTML = ` +
+
+
+
+
+
+
+
+
+
+ + `; + $('save-cfg-btn').addEventListener('click', saveConfig); +} + +async function saveConfig() { + if (!active) return; + const btn = $('save-cfg-btn'); + btn.textContent = 'Saving…'; btn.disabled = true; + const updated = { + ...active.config, + gp_target_pct: parseFloat($('cfg-gp').value), + commission_pct: parseFloat($('cfg-comm').value), + bond_pct: parseFloat($('cfg-bond').value), + eur_usd_rate: parseFloat($('cfg-rate').value), + revision: $('cfg-rev').value, + }; + try { + const res = await fetch(`/api/projects/${active.id}/save-config`, { + method: 'POST', + headers: {'Content-Type':'application/json'}, + body: JSON.stringify(updated), + }); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + active.config = updated; + toast('✅ Config saved — recalculating…'); + syslog('Config saved. Refreshing costing…'); + loadResults(active.id); + } catch (e) { + toast('❌ Save failed: ' + e.message, 'err'); + } finally { + btn.textContent = '💾 Save & Recalculate'; btn.disabled = false; + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// DELETE PROJECT +// ───────────────────────────────────────────────────────────────────────────── +delProjBtn.addEventListener('click', async () => { + if (!active) return; + if (!confirm(`Delete project "${active.name}" (${active.id}) and all its outputs?\n\nThis cannot be undone.`)) return; + try { + const res = await fetch(`/api/projects/${active.id}`, {method:'DELETE'}); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + toast(`🗑 Project ${active.id} deleted.`); + active = null; + delProjBtn.style.display = 'none'; + projInfoCard.style.display = 'none'; + statusChip.style.display = 'none'; + runBtn.disabled = true; + projTitle.textContent = 'Select a Project'; + projMeta.textContent = 'No project loaded'; + await loadProjects(); + } catch (e) { + toast('❌ Delete failed: ' + e.message, 'err'); + } +}); + +// ───────────────────────────────────────────────────────────────────────────── +// PIPELINE RUNNER (SSE) +// ───────────────────────────────────────────────────────────────────────────── +function handleRunPipeline() { + if (!active) return; + if (activeSSE) { activeSSE.close(); activeSSE = null; } + + consoleBody.innerHTML = ''; + consolePanel.classList.add('expanded'); + cnslToggle.textContent = '▼ Collapse'; + consoleBar.setAttribute('aria-expanded', 'true'); + + setStatus('running', 'Running…'); + runBtn.disabled = true; + runBtn.innerHTML = ' Running…'; + activeValidation = null; + renderReadiness(); + + syslog('Connecting to pipeline stream…'); + + const demoTog = $('demo-mode-toggle'); + const useDemoMode = demoTog ? demoTog.checked : false; + const url = `/api/projects/${active.id}/run?skip_ai=${skipAiTog.checked}&demo=${useDemoMode}`; + const es = new EventSource(url); + activeSSE = es; + + es.onmessage = ev => { + try { + const d = JSON.parse(ev.data); + if (d.log) logLine(d.log); + if (d.done) { + es.close(); activeSSE = null; + restoreRunBtn(); + if (d.success) { + setStatus('done', 'Complete'); + toast('✅ Pipeline complete! Results updated.'); + loadResults(active.id); + } else { + setStatus('error', 'Failed'); + toast('❌ Pipeline failed — check logs below.', 'err'); + loadProjectStatus(active.id); + } + } + } catch { /* ignore keep-alive bytes */ } + }; + + es.onerror = () => { + if (!activeSSE) return; // already closed by done event + es.close(); activeSSE = null; + restoreRunBtn(); + setStatus('error', 'Connection lost'); + log('[ERROR] SSE connection dropped.', 'err'); + }; +} + +function restoreRunBtn() { + runBtn.disabled = false; + runBtn.innerHTML = ' Run Pipeline'; +} + +function setStatus(state, text) { + statusDot.className = 'status-dot'; + if (state === 'running') statusDot.classList.add('running'); + else if (state === 'done') statusDot.classList.add('done'); + else if (state === 'error') statusDot.classList.add('error'); + statusText.textContent = text; + dotInd.className = 'dot-ind'; + if (state === 'running') dotInd.classList.add('active'); + else if (state === 'done') dotInd.classList.add('success'); + else if (state === 'error') dotInd.classList.add('error'); +} + +// ───────────────────────────────────────────────────────────────────────────── +// LOAD RESULTS +// ───────────────────────────────────────────────────────────────────────────── +async function loadResults(projectId) { + try { + const res = await fetch(`/api/projects/${projectId}/results`); + if (res.status === 404) { + activeValidation = null; + if (active) loadProjectStatus(active.id); + renderReadiness(); + resetKPIs(); + $('accordion-container').innerHTML = ` +
+
⚡
+
No cabinet schedules yet.
Click Run Pipeline to process the uploaded drawings.
+
`; + return; + } + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const data = await res.json(); + activeValidation = data.validation || null; + if (active) loadProjectStatus(active.id); + renderReadiness(); + + if (data.outputs?.pdf_ready) dlPdf.classList.remove('disabled'); + if (data.outputs?.xlsx_ready) dlXlsx.classList.remove('disabled'); + + fillKPIs(data); + renderSchedules(data.unit_schedules, projectId); + renderCostSheet(data.costing, data.config); + renderDonut(data.costing); + renderPerCab(data.costing); + renderDevMetrics(data.metrics); + jsonViewer.textContent = JSON.stringify(data, null, 2); + + if (data.validation?.status === 'REVIEW') { + log(`[WARN] Validation needs review: ${data.validation.flag_count} flag(s).`, 'warn'); + } + syslog(`Results loaded — ${data.costing.total_cabinet_count} cabinets, selling price ${fmtUSD(data.costing.selling_price)}.`); + setStatus('done', 'Results ready'); + } catch (e) { + log(`[ERROR] Loading results: ${e.message}`, 'err'); + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// KPI CARDS +// ───────────────────────────────────────────────────────────────────────────── +function fillKPIs(data) { + const c = data.costing, m = data.metrics; + kpiSell.textContent = fmtUSD(c.selling_price); + kpiGP.textContent = `GP: ${(c.gp_pct*100).toFixed(1)}% • Profit ${fmtUSD(c.gross_profit)}`; + kpiMat.textContent = fmtUSD(c.material_cost); + kpiRate.textContent = `EUR/USD: ${data.config.eur_usd_rate || '1.09'}`; + kpiCabs.textContent = c.total_cabinet_count.toLocaleString(); + kpiCtrs.textContent = `${c.containers_needed} Container(s)`; + kpiAI.textContent = fmtUSD(m.total_cost_usd, 4); + kpiCalls.textContent = `${m.api_calls} Model Calls`; +} + +function resetKPIs() { + [kpiSell,kpiGP,kpiMat,kpiRate,kpiCabs,kpiCtrs,kpiAI,kpiCalls].forEach(e=>e.textContent='—'); + dlPdf.classList.add('disabled'); dlXlsx.classList.add('disabled'); + $('cost-tbody').innerHTML = ''; + if (donutChart) { donutChart.destroy(); donutChart = null; } +} + +// ───────────────────────────────────────────────────────────────────────────── +// SCHEDULES ACCORDION +// ───────────────────────────────────────────────────────────────────────────── +function renderSchedules(schedules, projectId) { + const container = $('accordion-container'); + container.innerHTML = ''; + + if (!schedules || Object.keys(schedules).length === 0) { + container.innerHTML = `
🗂️
No schedules found. Run the pipeline to generate them.
`; + return; + } + + const filterBar = $('sched-filter-bar'); + if (filterBar) filterBar.style.display = 'flex'; + + Object.entries(schedules).forEach(([unit, sched]) => { + const group = document.createElement('div'); + group.className = 'unit-group glass'; + + const totalCabs = sched.elevations.reduce((s,ev) => s + ev.cabinets.length, 0); + const needsReview= sched.review_flags?.length > 0; + const isADA = sched.is_ada; + + group.innerHTML = ` +
+
+ ${unit} + ${needsReview ? '⚠ Needs Review' : '✓ Approved'} + ${isADA ? 'ADA' : ''} +
+
+ ${sched.elevations.length} elevation(s) + ${totalCabs} cabinet(s) + ▼ +
+
+
+ ${needsReview ? `
Review Flags
` : ''} + ${sched.elevations.map(ev => buildElevHTML(ev, unit, projectId)).join('')} +
`; + + group.querySelector('.unit-hdr').addEventListener('click', () => group.classList.toggle('open')); + container.appendChild(group); + }); + + // Auto-open first unit + const first = container.querySelector('.unit-group'); + if (first) first.classList.add('open'); + + bindCropBtns(); + + const s = $('sched-search'); + if (s) { s.oninput = e => { + const q = e.target.value.toLowerCase(); + $$('.sched-table tbody tr').forEach(tr => { tr.style.display = !q || tr.textContent.toLowerCase().includes(q) ? '' : 'none'; }); + }; } +} + +function buildElevHTML(ev, unit, projectId) { + const conf = (ev.avg_confidence * 100).toFixed(0); + const cropName = `${unit.replace(/[\s-]/g,'_')}_${ev.elevation_label}.png`; + const cropUrl = `/api/projects/${projectId}/crops/${cropName}`; + + const rows = ev.cabinets.map(cab => { + const wCm = (cab.width_mm/10).toFixed(1); + const hCm = (cab.height_mm/10).toFixed(1); + const dCm = (cab.depth_mm/10).toFixed(1); + const wIn = mmToIn(cab.width_mm); + const c = Math.round(cab.confidence * 100); + const col = c >= 90 ? 'var(--success)' : c >= 70 ? 'var(--warn)' : 'var(--danger)'; + return ` + ${cab.item_num} + ${cab.cabinet_type}${cab.is_ada?' ADA':''} + ${cab.code || '—'} + ${wCm}${hCm}${dCm} + ${wIn} + ${cab.quantity} +
${c}%
+ ${cab.notes || ''} + + `; + }).join(''); + + return `
+
+

${ev.elevation_label}

+
Avg Conf: ${conf}%${ev.cabinets.length} items
+
+
+ + + ${rows} +
#TypeCodeW cmH cmD cmW inQtyConfNotesCrop
+
+
`; +} + +// ───────────────────────────────────────────────────────────────────────────── +// COSTING SHEET +// ───────────────────────────────────────────────────────────────────────────── +function renderCostSheet(c, cfg) { + const tbody = $('cost-tbody'); + const gp = (c.gp_pct*100).toFixed(1); + const comm = (c.commission_pct*100).toFixed(1); + const bond = (c.bond_pct*100).toFixed(1); + const rows = [ + {l:'1. Cabinet Material Cost', r:'Price-matched from ItalianKB Excel', v:c.material_cost}, + {l:'2. Local Use Tax (7.5%)', r:'7.5% × material', v:c.local_use_tax}, + {l:'3. Ocean Freight', r:`${c.containers_needed} container(s) × $4,500`, v:c.ocean_freight}, + {l:'4. Inland Delivery', r:'Flat rate logistics', v:c.inland_delivery}, + {l:'5. Installation Labor', r:`${c.total_cabinet_count} cabinets × $85`, v:c.installation}, + {l:'6. Local Warehousing', r:'2.0% × material', v:c.warehousing}, + {l:'7. Material Protection', r:'0.5% × material', v:c.material_protection}, + {l:'8. Inland Transit Insurance', r:'0.8% × material', v:c.insurance}, + {l:'9. Miscellaneous Allowance', r:'Flat allowance', v:c.misc_allowance}, + {l:'PRE-MARGIN SUBTOTAL', r:'— Sum of 1–9 —', v:c.pre_margin_total, sub:true}, + {l:`Commission (${comm}%)`, r:`${comm}% × Selling Price`, v:c.selling_price*c.commission_pct}, + {l:`Performance Bond (${bond}%)`, r:`${bond}% × Selling Price`, v:c.selling_price*c.bond_pct}, + {l:`Gross Profit (${gp}% Target)`, r:`${gp}% × Selling Price`, v:c.gross_profit}, + {l:'TOTAL ESTIMATED PROJECT PRICE', r:'Pre-Margin ÷ (1 − GP% − Comm% − Bond%)', v:c.selling_price, tot:true}, + ]; + tbody.innerHTML = rows.map(r => ` + + ${r.l} + ${r.r} + ${fmtUSD(r.v)} + `).join(''); +} + +// ───────────────────────────────────────────────────────────────────────────── +// DONUT CHART +// ───────────────────────────────────────────────────────────────────────────── +function renderDonut(c) { + const canvas = $('donut-chart'); + if (!canvas) return; + if (typeof Chart === 'undefined') { + syslog('[WARN] Chart.js library is not loaded. Skipping chart.'); + const ctx = canvas.getContext('2d'); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; + ctx.font = '14px Inter'; + ctx.textAlign = 'center'; + ctx.fillText('Chart library offline', canvas.width / 2, canvas.height / 2); + return; + } + const ctx = canvas.getContext('2d'); + if (donutChart) donutChart.destroy(); + const transport = c.ocean_freight + c.inland_delivery; + const taxIns = c.local_use_tax + c.insurance; + const whProt = c.warehousing + c.material_protection + c.misc_allowance; + const commBond = c.selling_price * c.commission_pct + c.selling_price * c.bond_pct; + donutChart = new Chart(ctx, { + type:'doughnut', + data:{ + labels:['Materials','Freight & Delivery','Tax & Insurance','Warehousing & Protection','Installation','Commission & Bond','Gross Profit'], + datasets:[{ + data:[c.material_cost, transport, taxIns, whProt, c.installation, commBond, c.gross_profit], + backgroundColor:['hsl(258,80%,62%)','hsl(208,80%,56%)','hsl(178,70%,44%)','hsl(38,90%,54%)','hsl(318,78%,60%)','hsl(5,80%,56%)','hsl(148,72%,44%)'], + borderWidth:1.5, borderColor:'rgba(0,0,0,.3)', hoverBorderColor:'#fff', + }], + }, + options:{ + responsive:true, maintainAspectRatio:false, cutout:'62%', + plugins:{ + legend:{position:'right', labels:{color:'rgba(255,255,255,.7)', font:{family:'Inter',size:10.5}, boxWidth:10, padding:10}}, + tooltip:{callbacks:{label:ctx=>{ + const tot = ctx.dataset.data.reduce((a,b)=>a+b,0); + return ` ${ctx.label}: ${fmtUSD(ctx.raw)} (${((ctx.raw/tot)*100).toFixed(1)}%)`; + }}}, + }, + }, + }); +} + +function renderPerCab(c) { + $('pc-cost').textContent = fmtUSD(c.cost_per_cabinet); + $('pc-sell').textContent = fmtUSD(c.sell_per_cabinet); + $('pc-ctrs').textContent = `${c.containers_needed}`; + $('pc-gp').textContent = `${(c.gp_pct*100).toFixed(1)}%`; +} + +// ───────────────────────────────────────────────────────────────────────────── +// DEVELOPER METRICS +// ───────────────────────────────────────────────────────────────────────────── +function renderDevMetrics(m) { + $('dev-model-prim').textContent = m.primary_model; + $('dev-model-fall').textContent = m.fallback_model; + $('dev-tok-in').textContent = m.input_tokens.toLocaleString(); + $('dev-tok-out').textContent = m.output_tokens.toLocaleString(); + $('dev-api-calls').textContent = m.api_calls.toLocaleString(); +} + +// ───────────────────────────────────────────────────────────────────────────── +// REGION OVERLAY +// ───────────────────────────────────────────────────────────────────────────── +async function loadOverlay(projectId, unitType) { + overlayCont.innerHTML = '
Rendering PDF thumbnail…
'; + try { + const regRes = await fetch(`/api/projects/${projectId}/regions/${encodeURIComponent(unitType)}`); + if (!regRes.ok) throw new Error(`Region API: HTTP ${regRes.status}`); + const regData = await regRes.json(); + + overlayCont.innerHTML = ''; + const wrapper = document.createElement('div'); + wrapper.style.cssText = 'position:relative;width:100%;height:100%;overflow:auto;min-height:220px'; + overlayCont.appendChild(wrapper); + + const img = document.createElement('img'); + img.src = `/api/projects/${projectId}/pdf-pages/${encodeURIComponent(unitType)}`; + img.alt = `PDF thumbnail for ${unitType}`; + img.style.cssText = 'max-width:100%;display:block;'; + wrapper.appendChild(img); + + img.onload = () => { + const scX = img.clientWidth / regData.page_w; + const scY = img.clientHeight / regData.page_h; + regData.regions.forEach(r => { + const [x0,y0,x1,y1] = r.bbox; + const box = document.createElement('div'); + box.className = 'zone-box'; + box.style.cssText = `left:${x0*scX}px;top:${y0*scY}px;width:${(x1-x0)*scX}px;height:${(y1-y0)*scY}px`; + box.title = `${r.region_type} | "${r.label}" | ${(r.confidence*100).toFixed(0)}%`; + box.innerHTML = `${r.region_type} ${(r.confidence*100).toFixed(0)}%`; + box.onclick = () => syslog(`[DEV] Zone: ${r.region_type} — "${r.label}"`); + wrapper.appendChild(box); + }); + }; + img.onerror = () => { wrapper.innerHTML += '

PDF thumbnail unavailable.

'; }; + } catch (e) { + overlayCont.innerHTML = `

Error: ${e.message}

`; + log(`[ERROR] Overlay: ${e.message}`, 'err'); + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// JSON CONTROLS +// ───────────────────────────────────────────────────────────────────────────── +function initJsonControls() { + $('json-copy-btn')?.addEventListener('click', async () => { + try { + await navigator.clipboard.writeText(jsonViewer.textContent); + toast('📋 JSON copied!'); + } catch { toast('❌ Clipboard copy failed', 'err'); } + }); + $('json-top-btn')?.addEventListener('click', () => { + jsonViewer.parentElement.scrollTop = 0; + }); +} + +// ───────────────────────────────────────────────────────────────────────────── +// CROP TOOLTIP +// ───────────────────────────────────────────────────────────────────────────── +function initCropTip() { + document.addEventListener('mousemove', e => { + if (cropTip.style.display !== 'block') return; + const w = 290, g = 18; + let x = e.pageX + g, y = e.pageY + g; + if (x + w > window.innerWidth) x = e.pageX - w - g; + if (y + cropTip.offsetHeight > window.innerHeight) y = e.pageY - cropTip.offsetHeight - g; + cropTip.style.left = `${x}px`; cropTip.style.top = `${y}px`; + }); +} + +function bindCropBtns() { + $$('.crop-btn').forEach(btn => { + btn.onmouseenter = e => { + const url = btn.dataset.crop; + if (!url) return; + cropTipImg.src = url; + cropTip.style.display = 'block'; + }; + btn.onmouseleave = () => { cropTip.style.display = 'none'; cropTipImg.src = ''; }; + }); +} + +// ───────────────────────────────────────────────────────────────────────────── +// CONSOLE +// ───────────────────────────────────────────────────────────────────────────── +function initConsole() { + consoleBar.addEventListener('click', toggleConsole); + cnslToggle.addEventListener('click', e => { e.stopPropagation(); toggleConsole(); }); + cnslClear.addEventListener('click', e => { + e.stopPropagation(); + consoleBody.innerHTML = ''; + syslog('Logs cleared.'); + }); +} + +function toggleConsole() { + const open = consolePanel.classList.toggle('expanded'); + cnslToggle.textContent = open ? '▼ Collapse' : '▲ Expand'; + consoleBar.setAttribute('aria-expanded', String(open)); +} + +function syslog(msg) { logLine('[SYSTEM] ' + msg, 'sys'); } + +function log(msg, type) { logLine(msg, type || (msg.startsWith('[ERROR]') ? 'err' : msg.startsWith('[WARN]') ? 'warn' : 'sys')); } + +function logLine(text, type = '') { + const line = document.createElement('div'); + line.className = 'log-line' + (type ? ' log-' + type : ''); + line.textContent = text; + consoleBody.appendChild(line); + consoleBody.scrollTop = consoleBody.scrollHeight; +} + +// ───────────────────────────────────────────────────────────────────────────── +// TOAST +// ───────────────────────────────────────────────────────────────────────────── +let _toastT = null; +function toast(msg, type = 'ok') { + const el = $('toast'); + el.textContent = msg; + el.style.borderColor = type === 'err' ? 'var(--danger-bdr)' : 'var(--border-hi)'; + el.classList.add('show'); + clearTimeout(_toastT); + _toastT = setTimeout(() => el.classList.remove('show'), 3200); +} + +// ───────────────────────────────────────────────────────────────────────────── +// ════════════════════════════════════════════════════════════════════════ +// 5-STEP NEW PROJECT WIZARD +// ════════════════════════════════════════════════════════════════════════ +// ───────────────────────────────────────────────────────────────────────────── +const STEP_SUBTITLES = [ + '', // 0 unused + 'Step 1 of 5 — Project Information', + 'Step 2 of 5 — Upload Architectural PDFs', + 'Step 3 of 5 — Unit Counts', + 'Step 4 of 5 — Price List (optional)', + 'Step 5 of 5 — Financial Parameters & Review', +]; + +function initWizard() { + newProjBtn.addEventListener('click', openWizard); + wizClose.addEventListener('click', closeWizard); + wizOverlay.addEventListener('click', e => { if (e.target === wizOverlay) closeWizard(); }); + wizNext.addEventListener('click', wizardNext); + wizBack.addEventListener('click', wizardBack); + wizCreate.addEventListener('click', wizardCreate); + + // PDF dropzone + pdfDropzone.addEventListener('click', () => pdfFileInput.click()); + pdfDropzone.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') pdfFileInput.click(); }); + pdfDropzone.addEventListener('dragover', e => { e.preventDefault(); pdfDropzone.classList.add('drag-over'); }); + pdfDropzone.addEventListener('dragleave', () => pdfDropzone.classList.remove('drag-over')); + pdfDropzone.addEventListener('drop', e => { + e.preventDefault(); pdfDropzone.classList.remove('drag-over'); + handlePdfFiles([...e.dataTransfer.files]); + }); + pdfFileInput.addEventListener('change', () => handlePdfFiles([...pdfFileInput.files])); + + // Excel dropzone + xlDropzone.addEventListener('click', () => xlFileInput.click()); + xlDropzone.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') xlFileInput.click(); }); + xlDropzone.addEventListener('dragover', e => { e.preventDefault(); xlDropzone.classList.add('drag-over'); }); + xlDropzone.addEventListener('dragleave', () => xlDropzone.classList.remove('drag-over')); + xlDropzone.addEventListener('drop', e => { + e.preventDefault(); xlDropzone.classList.remove('drag-over'); + const f = e.dataTransfer.files[0]; + if (f) setXlFile(f); + }); + xlFileInput.addEventListener('change', () => { if (xlFileInput.files[0]) setXlFile(xlFileInput.files[0]); }); + xlRemoveBtn.addEventListener('click', () => { wiz.xlFile = null; xlFileInfo.style.display = 'none'; xlDropzone.style.display = 'flex'; }); +} + +function openWizard() { + // Reset wizard state + Object.assign(wiz, { step:1, pdfFiles:[], xlFile:null, projectId:null }); + pdfFileList.innerHTML = ''; + wizOverlay.style.display = 'flex'; + gotoStep(1); +} + +function closeWizard() { + wizOverlay.style.display = 'none'; +} + +function gotoStep(n) { + wiz.step = n; + for (let i = 1; i <= 5; i++) { + const s = $(`step-${i}`); + if (s) s.style.display = i === n ? '' : 'none'; + } + wizSubtitle.textContent = STEP_SUBTITLES[n]; + + // Update pip states + $$('.step-pip').forEach(pip => { + const sn = parseInt(pip.dataset.step); + pip.classList.remove('active', 'done'); + if (sn === n) pip.classList.add('active'); + else if (sn < n) pip.classList.add('done'); + }); + + wizBack.style.display = n > 1 ? '' : 'none'; + wizNext.style.display = n < 5 ? '' : 'none'; + wizCreate.style.display = n === 5 ? '' : 'none'; + + // Populate step 3 unit count form when arriving + if (n === 3) buildUnitCountsForm(); + // Populate review box on step 5 + if (n === 5) buildReviewBox(); +} + +function wizardNext() { + if (wiz.step === 1 && !validateStep1()) return; + if (wiz.step === 2 && wiz.pdfFiles.length === 0) { + toast('⚠ Please upload at least one architectural PDF.', 'err'); return; + } + gotoStep(wiz.step + 1); +} + +function wizardBack() { gotoStep(wiz.step - 1); } + +function validateStep1() { + const name = $('w-proj-name').value.trim(); + const id = $('w-proj-id').value.trim(); + if (!name) { toast('⚠ Project Name is required.', 'err'); $('w-proj-name').focus(); return false; } + if (!id) { toast('⚠ Project ID is required.', 'err'); $('w-proj-id').focus(); return false; } + return true; +} + +// ── Handle PDF files ────────────────────────────────────────────────────────── +function handlePdfFiles(files) { + files.forEach(file => { + if (!file.name.toLowerCase().endsWith('.pdf')) return; + // Auto-derive unit type from filename (remove extension, sanitize) + const rawName = file.name.replace(/\.pdf$/i,'').replace(/[_\-\s]+/g,' ').trim(); + wiz.pdfFiles.push({ file, unitType: rawName, isAda: /ada/i.test(rawName) }); + }); + renderPdfFileList(); + pdfFileInput.value = ''; +} + +function renderPdfFileList() { + pdfFileList.innerHTML = ''; + wiz.pdfFiles.forEach((item, idx) => { + const row = document.createElement('div'); + row.className = 'file-row'; + row.innerHTML = ` + 📄 + ${item.file.name} + ${(item.file.size/1024).toFixed(1)} KB + + + `; + pdfFileList.appendChild(row); + }); + + $$('.unit-name-inp').forEach(inp => inp.addEventListener('input', e => { + const i = parseInt(e.target.dataset.idx); + wiz.pdfFiles[i].unitType = e.target.value.trim(); + })); + $$('.ada-chk').forEach(chk => chk.addEventListener('change', e => { + const i = parseInt(e.target.dataset.idx); + wiz.pdfFiles[i].isAda = e.target.checked; + })); + $$('.file-row-del').forEach(btn => btn.addEventListener('click', e => { + const i = parseInt(e.currentTarget.dataset.idx); + wiz.pdfFiles.splice(i, 1); + renderPdfFileList(); + })); +} + +function setXlFile(file) { + wiz.xlFile = file; + xlFileName.textContent = file.name; + xlFileInfo.style.display = 'flex'; + xlDropzone.style.display = 'none'; +} + +// ── Step 3: Unit counts form ────────────────────────────────────────────────── +function buildUnitCountsForm() { + const grid = $('unit-counts-form'); + grid.innerHTML = ''; + wiz.pdfFiles.forEach(item => { + if (!item.unitType) return; + const div = document.createElement('div'); + div.className = 'uc-group'; + div.innerHTML = ` +
+ ${item.unitType} + ${item.isAda ? 'ADA' : ''} +
+ `; + grid.appendChild(div); + }); +} + +// ── Step 5: Review box ──────────────────────────────────────────────────────── +function buildReviewBox() { + const box = $('wizard-review'); + const units = wiz.pdfFiles.map(f => f.unitType).filter(Boolean); + const counts = {}; + wiz.pdfFiles.forEach(f => { + const el = $(`uc-${encodeURIComponent(f.unitType)}`); + counts[f.unitType] = el ? parseInt(el.value) || 1 : 1; + }); + + box.innerHTML = ` +

Project Review

+
Project Name${$('w-proj-name').value}
+
Project ID${$('w-proj-id').value}
+
Client${$('w-client').value || '—'}
+
Address${$('w-address').value || '—'}
+
Unit Types${units.join(', ') || '—'}
+
Unit Counts${Object.entries(counts).map(([u,c])=>`${u}×${c}`).join(', ')}
+
Price List${wiz.xlFile ? wiz.xlFile.name : 'Default ItalianKB Level 1'}
+
Target GP${($('w-gp')?.value||'0.35')*100}%
+
Commission${($('w-comm')?.value||'0.05')*100}%
+
EUR/USD Rate${$('w-rate')?.value||'1.09'}
+ `; +} + +// ── Create project + upload files ───────────────────────────────────────────── +async function wizardCreate() { + // Gather unit counts + const unitCounts = {}; + const adaUnits = []; + wiz.pdfFiles.forEach(f => { + const el = $(`uc-${encodeURIComponent(f.unitType)}`); + unitCounts[f.unitType] = el ? parseInt(el.value) || 1 : 1; + if (f.isAda) adaUnits.push(f.unitType); + }); + + const projectId = $('w-proj-id').value.trim(); + const projectName = $('w-proj-name').value.trim(); + + // Step A: Create project config + wizCreate.disabled = true; + wizCreate.innerHTML = ' Creating…'; + syslog('Creating project config…'); + + try { + const createRes = await fetch('/api/projects/create', { + method: 'POST', + headers: {'Content-Type':'application/json'}, + body: JSON.stringify({ + project_id: projectId, + project_name: projectName, + client_name: $('w-client').value, + architect: $('w-architect').value, + project_address: $('w-address').value, + cabinet_finish: $('w-finish').value, + door_style: $('w-door').value, + drawn_by: $('w-drawn').value, + revision: $('w-rev').value, + unit_counts: unitCounts, + ada_units: adaUnits, + gp_target_pct: parseFloat($('w-gp')?.value || 0.35), + commission_pct: parseFloat($('w-comm')?.value || 0.05), + bond_pct: parseFloat($('w-bond')?.value || 0.015), + eur_usd_rate: parseFloat($('w-rate')?.value || 1.09), + }), + }); + if (!createRes.ok) { + const err = await createRes.json(); + throw new Error(err.detail || `HTTP ${createRes.status}`); + } + syslog(`Project "${projectName}" created.`); + + // Step B: Upload PDFs one by one + for (const item of wiz.pdfFiles) { + if (!item.unitType || !item.file) continue; + wizCreate.innerHTML = ` Uploading ${item.unitType}…`; + syslog(`Uploading PDF for unit: ${item.unitType}…`); + const fd = new FormData(); + fd.append('unit_type', item.unitType); + fd.append('is_ada', String(item.isAda)); + fd.append('file', item.file); + const upRes = await fetch(`/api/projects/${projectId}/upload-pdf`, { method:'POST', body:fd }); + if (!upRes.ok) { + const err = await upRes.json(); + throw new Error(`Upload failed for ${item.unitType}: ${err.detail}`); + } + syslog(`PDF uploaded: ${item.unitType} (${(item.file.size/1024).toFixed(1)} KB)`); + } + + // Step C: Upload price list (optional) + if (wiz.xlFile) { + wizCreate.innerHTML = ' Uploading price list…'; + syslog('Uploading price list…'); + const fd = new FormData(); + fd.append('file', wiz.xlFile); + const xlRes = await fetch(`/api/projects/${projectId}/upload-price-list`, { method:'POST', body:fd }); + if (!xlRes.ok) { + syslog(`[WARN] Price list upload failed — will use default.`); + } else { + syslog('Price list uploaded.'); + } + } + + syslog('All files uploaded. Launching pipeline…'); + closeWizard(); + toast(`✅ Project "${projectName}" created! Starting pipeline…`); + + // Reload project list and auto-select the new project + await loadProjects(); + const newProj = projects.find(p => p.id === projectId); + if (newProj) { + projectSel.value = projectId; + selectProject(newProj); + } + + // Auto-run pipeline (with AI, not skip) + if (active && active.id === projectId) { + // short delay so UI settles + setTimeout(() => { + skipAiTog.checked = false; + handleRunPipeline(); + }, 600); + } + + } catch (e) { + toast(`❌ ${e.message}`, 'err'); + log(`[ERROR] Wizard: ${e.message}`, 'err'); + wizCreate.disabled = false; + wizCreate.innerHTML = ' Create & Run Pipeline'; + } +} + +// ───────────────────────────────────────────────────────────────────────────── +// FORMATTERS +// ───────────────────────────────────────────────────────────────────────────── +function fmtUSD(val, digits = 2) { + if (val == null || isNaN(val)) return '—'; + return new Intl.NumberFormat('en-US', { + style:'currency', currency:'USD', + minimumFractionDigits:digits, maximumFractionDigits:digits, + }).format(val); +} + +function mmToIn(mm) { + if (!mm) return '—'; + const ins = mm / 25.4; + const whole = Math.floor(ins); + const frac = ins - whole; + const FRACS = [ + [0,''], [1/16,'1/16"'], [1/8,'⅛"'], [3/16,'3/16"'], + [1/4,'¼"'], [5/16,'5/16"'], [3/8,'⅜"'], [7/16,'7/16"'], + [1/2,'½"'], [9/16,'9/16"'], [5/8,'⅝"'], [11/16,'11/16"'], + [3/4,'¾"'], [13/16,'13/16"'], [7/8,'⅞"'], [15/16,'15/16"'], + ]; + const best = FRACS.reduce((a,b) => Math.abs(b[0]-frac) < Math.abs(a[0]-frac) ? b : a); + return whole + (best[1] ? ' ' + best[1] : '"'); +} diff --git a/Albert_Project/web_app/static/index.html b/Albert_Project/web_app/static/index.html new file mode 100644 index 0000000..157a3b0 --- /dev/null +++ b/Albert_Project/web_app/static/index.html @@ -0,0 +1,477 @@ + + + + + + + ItalianKB — Cabinet Estimator & Shop Drawing Automation + + + + + + + + + + + + + +
+ + + + + +
+ + +
+
+

Select a Project

+

No project loaded — or create a new one

+
+
+ + + + +
+
+ + + + +
+
+
Total Selling Price
+
—
+
GP Target: —
+
+
+
Material Cost (USD)
+
—
+
EUR/USD: —
+
+
+
Total Cabinets
+
—
+
Containers: —
+
+
+
Vision AI Cost
+
—
+
API Calls: —
+
+
+ + + + + +
+ + +
+
+
+

Cabinet Schedules by Unit Type

+

Expand a unit to view the full cabinet list. Hover 🖼️ to preview elevation crops.

+
+ +
+
+
+
🗂️
+
Select an existing project or create a new one with + New Project to get started.
+
+
+
+ + +
+
+
+
+

Job Costing Breakdown

+ +
+
+ + + +
Line ItemRate / BasisAmount (USD)
+
+
+
+
+

Cost Allocation

+
+
+
+

Per-Cabinet Summary

+
+
Cost / Cabinet—
+
Sell / Cabinet—
+
Containers Needed—
+
Achieved GP %—
+
+
+
+
+
+ + +
+
+
+

System Pipeline Architecture

+
+ + + + + + + + Upload PDF + PyMuPDF Extract + + + Region Detect + Elevation Zones + + Dim Parser + mm / Inch Dims + + + + Gemini 2.5 Flash + Vision Classifier + +Pro fallback + + + Price Match + Excel→USD + ±25mm fuzzy + + + Job Costing + Selling Price + Algebraic Formula + + + PDF+XL + +
+
+
Primary LLM—
+
Fallback LLM—
+
Auto-Approve≥ 90% confidence
+
Input tokens—
+
Output tokens—
+
API calls—
+
+
+ +
+
+

Region Detector Overlay

+ +
+
+

Select a unit to render the PDF with detected zone boundaries.

+
+
+ +
+
+

Raw JSON Output (Cabinet Schedule)

+
+ + +
+
+
// Run the pipeline to see JSON output here.
+
+
+
+ +
+
+
+ + +
+ +
+
[SYSTEM] Ready — select a project or create a new one.
+
+
+ + + + + + + + + + + + + diff --git a/Albert_Project/web_app/static/style.css b/Albert_Project/web_app/static/style.css new file mode 100644 index 0000000..177f5df --- /dev/null +++ b/Albert_Project/web_app/static/style.css @@ -0,0 +1,463 @@ +/* +=========================================================================== + style.css — ItalianKB Cabinet Estimator (Production v2.0) +=========================================================================== +*/ + +/* ── Design Tokens ── */ +:root { + --bg: hsl(230,28%,4%); + --sb-bg: hsl(230,28%,2.5%); + --surface: rgba(255,255,255,.03); + --surface-2: rgba(255,255,255,.06); + --border: rgba(255,255,255,.06); + --border-hi: rgba(255,255,255,.13); + + --primary: hsl(258,82%,67%); + --primary-glo: hsla(258,82%,67%,.28); + --primary-dim: hsla(258,82%,67%,.12); + --primary-bdr: hsla(258,82%,67%,.3); + + --success: hsl(148,70%,44%); + --success-bg: hsla(148,70%,44%,.1); + --success-bdr: hsla(148,70%,44%,.25); + + --warn: hsl(38,92%,55%); + --warn-bg: hsla(38,92%,55%,.1); + --warn-bdr: hsla(38,92%,55%,.25); + + --danger: hsl(4,80%,57%); + --danger-bg: hsla(4,80%,57%,.1); + --danger-bdr: hsla(4,80%,57%,.25); + + --text: hsl(0,0%,94%); + --text-2: hsl(220,12%,72%); + --text-3: hsl(220,8%,50%); + + --font: 'Inter', system-ui, sans-serif; + --font-disp: 'Outfit', system-ui, sans-serif; + --font-mono: 'Fira Code', 'Cascadia Code', monospace; + + --sb-w: 296px; + --console-h: 44px; + --console-exp: 220px; + --r: 10px; + --r-lg: 14px; + --t: .18s cubic-bezier(.4,0,.2,1); +} + +/* ── Reset ── */ +*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; } +html,body { height:100%; overflow:hidden; } +body { font-family:var(--font); background:var(--bg); color:var(--text); font-size:13.5px; line-height:1.55; } +a { color:inherit; text-decoration:none; } +button { cursor:pointer; font-family:var(--font); } +img { display:block; max-width:100%; } +input,select,textarea { font-family:var(--font); } + +/* Scrollbars */ +::-webkit-scrollbar { width:5px; height:5px; } +::-webkit-scrollbar-track { background:transparent; } +::-webkit-scrollbar-thumb { background:rgba(255,255,255,.1); border-radius:3px; } +::-webkit-scrollbar-thumb:hover { background:rgba(255,255,255,.2); } + +/* Glows */ +.glow { position:fixed; border-radius:50%; filter:blur(140px); opacity:.12; pointer-events:none; z-index:0; } +.glow-1 { width:550px; height:550px; background:var(--primary); top:-180px; left:-120px; } +.glow-2 { width:700px; height:700px; background:hsl(210,85%,55%); bottom:-220px; right:-180px; } +.glow-3 { width:350px; height:350px; background:hsl(170,70%,45%); top:40%; left:45%; opacity:.06; } + +/* ─────────────── LAYOUT ─────────────── */ +.app-shell { + position:relative; z-index:1; + display:flex; width:100vw; + height:calc(100vh - var(--console-h)); +} + +/* ─────────────── SIDEBAR ─────────────── */ +.sidebar { + width:var(--sb-w); flex-shrink:0; + background:var(--sb-bg); + border-right:1px solid var(--border); + display:flex; flex-direction:column; + padding:22px 18px; + overflow-y:auto; +} + +.brand { display:flex; align-items:center; gap:12px; margin-bottom:26px; } +.brand-logo { font-size:28px; } +.brand-name { font-family:var(--font-disp); font-size:20px; font-weight:700; letter-spacing:-.3px; } +.brand-sub { font-size:9.5px; color:var(--text-3); text-transform:uppercase; letter-spacing:.8px; } + +.sb-section { margin-bottom:20px; } +.sb-grow { flex-grow:1; } +.sb-label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.6px; color:var(--text-3); margin-bottom:8px; } + +.info-card { padding:10px 12px; } +.info-row { display:flex; justify-content:space-between; gap:8px; padding:4px 0; border-bottom:1px solid var(--border); } +.info-row:last-child { border:none; } +.info-k { font-size:10px; color:var(--text-3); flex-shrink:0; } +.info-v { font-size:10.5px; color:var(--text-2); text-align:right; word-break:break-word; } + +.config-fields { display:flex; flex-direction:column; gap:10px; } +.cf-group label { display:block; font-size:9.5px; color:var(--text-3); text-transform:uppercase; letter-spacing:.5px; margin-bottom:4px; } + +.sb-actions { display:flex; flex-direction:column; gap:8px; margin-bottom:16px; } + +.btn-new-proj { + background:var(--primary); color:#fff; border:none; + font-size:12px; font-weight:600; padding:9px 14px; border-radius:var(--r); + display:flex; align-items:center; gap:7px; + transition:var(--t); +} +.btn-new-proj:hover { filter:brightness(1.15); box-shadow:0 4px 18px var(--primary-glo); } + +.btn-danger-sm { + background:transparent; color:var(--danger); border:1px solid var(--danger-bdr); + font-size:11.5px; padding:7px 12px; border-radius:var(--r); + transition:var(--t); +} +.btn-danger-sm:hover { background:var(--danger-bg); } + +.btn-save-cfg { + width:100%; margin-top:6px; padding:9px; border-radius:var(--r); + background:transparent; border:1px solid var(--primary); + color:var(--text); font-size:12px; font-weight:600; transition:var(--t); +} +.btn-save-cfg:hover { background:var(--primary); box-shadow:0 0 16px var(--primary-glo); } + +.sb-footer { margin-top:auto; border-top:1px solid var(--border); padding-top:14px; } +.model-badge { display:flex; align-items:center; gap:7px; font-size:10.5px; color:var(--text-3); margin-bottom:4px; } +.model-dot { width:7px; height:7px; border-radius:50%; background:var(--success); box-shadow:0 0 8px var(--success); } +.version-tag { font-size:9.5px; color:var(--text-3); font-family:var(--font-mono); } + +/* ─────────────── MAIN ─────────────── */ +.main { flex-grow:1; display:flex; flex-direction:column; overflow:hidden; padding:22px 24px 8px; } + +/* Top bar */ +.top-bar { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; flex-shrink:0; } +.proj-title { font-family:var(--font-disp); font-size:24px; font-weight:700; letter-spacing:-.4px; } +.proj-meta { font-size:11.5px; color:var(--text-3); margin-top:2px; } +.top-bar-right { display:flex; align-items:center; gap:16px; } + +/* Status chip */ +.status-chip { display:flex; align-items:center; gap:7px; background:var(--surface-2); border:1px solid var(--border-hi); border-radius:20px; padding:5px 12px; font-size:11px; } +.status-dot { width:7px; height:7px; border-radius:50%; background:var(--text-3); } +.status-dot.running { background:var(--primary); box-shadow:0 0 8px var(--primary); animation:pulse 1.4s infinite; } +.status-dot.done { background:var(--success); box-shadow:0 0 8px var(--success); } +.status-dot.error { background:var(--danger); box-shadow:0 0 8px var(--danger); } + +/* Toggle */ +.toggle-row { display:flex; align-items:center; gap:9px; cursor:pointer; user-select:none; } +.toggle-lbl { font-size:11.5px; color:var(--text-2); } +.pill-switch { position:relative; display:inline-block; } +.pill-switch input { position:absolute; opacity:0; width:0; height:0; } +.pill-track { display:block; width:40px; height:21px; border-radius:11px; background:rgba(255,255,255,.1); transition:var(--t); position:relative; } +.pill-thumb { position:absolute; top:3px; left:3px; width:15px; height:15px; border-radius:50%; background:#fff; transition:var(--t); } +.pill-switch input:checked ~ .pill-track { background:var(--primary); box-shadow:0 0 10px var(--primary-glo); } +.pill-switch input:checked ~ .pill-track .pill-thumb { transform:translateX(19px); } + +/* KPI Cards */ +.kpi-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:13px; margin-bottom:18px; flex-shrink:0; } +.kpi-card { padding:14px 17px; border-radius:var(--r-lg); transition:transform var(--t),box-shadow var(--t); } +.kpi-card:hover { transform:translateY(-2px); box-shadow:0 8px 30px rgba(0,0,0,.35); } +.kpi-label { font-size:9.5px; font-weight:600; text-transform:uppercase; letter-spacing:.6px; color:var(--text-3); margin-bottom:6px; } +.kpi-val { font-family:var(--font-disp); font-size:22px; font-weight:700; margin-bottom:3px; } +.kpi-sub { font-size:10.5px; color:var(--text-2); } + +/* Tabs */ +.tab-nav { display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:16px; flex-shrink:0; } +.tab-btn { + background:transparent; border:none; + padding:9px 18px; font-size:13px; font-weight:500; + color:var(--text-3); border-radius:var(--r) var(--r) 0 0; + position:relative; transition:var(--t); outline:none; +} +.tab-btn:hover { color:var(--text-2); } +.tab-btn.active { color:var(--primary); font-weight:600; } +.tab-btn.active::after { content:''; position:absolute; bottom:-1px; left:0; right:0; height:2px; background:var(--primary); border-radius:2px 2px 0 0; } + +.tab-body { flex-grow:1; overflow:hidden; } +.tab-pane { display:none; height:100%; overflow-y:auto; padding-bottom:12px; } +.tab-pane.active { display:block; } + +/* Pane header */ +.pane-header { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:16px; gap:16px; } +.pane-header h3 { font-family:var(--font-disp); font-size:17px; font-weight:600; margin-bottom:3px; } +.pane-actions { display:flex; gap:8px; align-items:center; } + +/* Empty card */ +.empty-card { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; height:220px; border:1px dashed var(--border-hi); border-radius:var(--r-lg); color:var(--text-3); } +.empty-icon { font-size:36px; opacity:.5; } +.empty-msg { font-size:13px; text-align:center; max-width:380px; line-height:1.6; } + +/* ─────────────── ACCORDION ─────────────── */ +.unit-group { margin-bottom:12px; border-radius:var(--r-lg); overflow:hidden; border:1px solid var(--border); } +.unit-hdr { display:flex; justify-content:space-between; align-items:center; padding:13px 18px; cursor:pointer; user-select:none; transition:background var(--t); } +.unit-hdr:hover { background:rgba(255,255,255,.015); } +.unit-hdr-l { display:flex; align-items:center; gap:10px; } +.unit-hdr-r { display:flex; align-items:center; gap:14px; font-size:11px; color:var(--text-2); } +.unit-name { font-family:var(--font-disp); font-size:15px; font-weight:600; } +.arrow-ico { font-size:10px; color:var(--text-3); transition:transform var(--t); } +.unit-group.open .arrow-ico { transform:rotate(180deg); } +.unit-body { display:none; padding:0 18px 16px; background:rgba(0,0,0,.12); border-top:1px solid var(--border); } +.unit-group.open .unit-body { display:block; } + +.badge { font-size:9px; font-weight:700; padding:2px 8px; border-radius:20px; text-transform:uppercase; letter-spacing:.4px; } +.badge-ok { background:var(--success-bg); color:var(--success); border:1px solid var(--success-bdr); } +.badge-warn{ background:var(--warn-bg); color:var(--warn); border:1px solid var(--warn-bdr); } +.badge-ada { background:var(--primary-dim); color:var(--primary); border:1px solid var(--primary-bdr); } + +.flag-box { background:var(--warn-bg); border:1px solid var(--warn-bdr); border-radius:var(--r); padding:10px 14px; margin:14px 0; } +.flag-box-title { color:var(--warn); font-size:10.5px; font-weight:700; text-transform:uppercase; margin-bottom:5px; } +.flag-list { list-style:none; font-size:11.5px; color:var(--text-2); display:flex; flex-direction:column; gap:3px; } +.flag-list li::before { content:'⚠ '; } + +.elev-section { margin-top:16px; } +.elev-title-bar { display:flex; justify-content:space-between; align-items:center; padding-bottom:6px; border-bottom:1px solid var(--border); margin-bottom:10px; } +.elev-title-bar h4 { font-family:var(--font-disp); font-size:13px; font-weight:600; color:var(--text-2); } +.elev-meta { font-size:11px; color:var(--text-3); display:flex; gap:14px; } + +.sched-table { width:100%; border-collapse:collapse; font-size:11.5px; } +.sched-table th { font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:var(--text-3); padding:7px 10px; text-align:left; border-bottom:1px solid var(--border); } +.sched-table td { padding:7px 10px; border-bottom:1px solid var(--border); vertical-align:middle; } +.sched-table tr:last-child td { border:none; } +.sched-table tr:hover td { background:rgba(255,255,255,.012); } +.mono { font-family:var(--font-mono); font-size:11px; } +.num { text-align:right !important; } + +.conf-bar { display:inline-flex; align-items:center; gap:6px; } +.conf-pct { font-size:10px; } +.conf-pip { width:34px; height:4px; border-radius:2px; background:rgba(255,255,255,.08); overflow:hidden; } +.conf-fill { height:100%; border-radius:2px; } +.crop-btn { background:transparent; border:1px solid var(--border); border-radius:5px; padding:3px 7px; font-size:12px; color:var(--text-2); transition:var(--t); } +.crop-btn:hover { background:var(--surface-2); border-color:var(--border-hi); } + +/* ─────────────── COSTING ─────────────── */ +.costing-grid { display:grid; grid-template-columns:3fr 1.6fr; gap:16px; height:100%; } +.costing-sheet { display:flex; flex-direction:column; padding:18px 20px; overflow:hidden; } +.sheet-hdr { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; flex-shrink:0; } +.sheet-hdr h3 { font-family:var(--font-disp); font-size:16px; font-weight:600; } +.dl-btns { display:flex; gap:8px; } +.sheet-scroll { flex-grow:1; overflow-y:auto; } +.cost-table { width:100%; border-collapse:collapse; font-size:12.5px; } +.cost-table th { font-size:9.5px; text-transform:uppercase; color:var(--text-3); font-weight:600; padding:8px 10px; border-bottom:1px solid var(--border-hi); } +.cost-table td { padding:9px 10px; border-bottom:1px solid var(--border); color:var(--text-2); } +.cost-table tr.subtotal-row td { border-top:1px solid var(--border-hi); font-weight:600; color:var(--text); font-size:13px; } +.cost-table tr.total-row td { border-top:2px solid var(--primary); font-weight:700; font-size:14px; color:var(--text); } + +.costing-right { display:flex; flex-direction:column; gap:14px; } +.chart-card,.pcab-card { padding:16px 18px; } +.chart-card h3,.pcab-card h3 { font-family:var(--font-disp); font-size:14px; font-weight:600; margin-bottom:14px; } +.donut-wrap { height:195px; position:relative; } +.pcab-rows { display:flex; flex-direction:column; gap:8px; } +.pcab-row { display:flex; justify-content:space-between; align-items:center; padding:7px 0; border-bottom:1px solid var(--border); font-size:12px; } +.pcab-row:last-child { border:none; } +.pcab-row span { color:var(--text-3); } +.pcab-row strong { font-family:var(--font-mono); font-size:12px; } + +/* ─────────────── DEVELOPER ─────────────── */ +.dev-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; } +.dev-card { padding:18px 20px; border-radius:var(--r-lg); } +.dev-flow,.dev-json { grid-column:1/3; } +.dev-card-hdr { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; } +.dev-card-hdr h3 { font-family:var(--font-disp); font-size:14px; font-weight:600; } + +.flow-svg-wrap { border:1px solid var(--border); border-radius:var(--r); background:rgba(0,0,0,.2); padding:14px; margin-bottom:14px; } +.fn-node { fill:rgba(255,255,255,.04); stroke:var(--border-hi); stroke-width:1.5; } +.fn-in { fill:rgba(99,72,219,.12); stroke:var(--primary); } +.fn-ai { fill:var(--primary); stroke:var(--primary-glo); } +.fn-out { fill:rgba(54,180,114,.25); stroke:var(--success); } +.fn-arr { stroke:rgba(255,255,255,.18); stroke-width:1.5; fill:none; } +.fn-label { fill:var(--text-2); font-family:Inter,sans-serif; font-size:11.5px; font-weight:600; text-anchor:middle; } +.fn-sub { fill:var(--text-3); font-family:Inter,sans-serif; font-size:9px; text-anchor:middle; } +.fn-wh { fill:#fff !important; } + +.metrics-row { display:flex; flex-wrap:wrap; gap:8px; } +.met-chip { background:rgba(255,255,255,.03); border:1px solid var(--border); border-radius:6px; padding:7px 11px; display:flex; flex-direction:column; min-width:110px; } +.met-k { font-size:9px; text-transform:uppercase; color:var(--text-3); margin-bottom:3px; } +.met-v { font-family:var(--font-mono); font-size:11px; font-weight:500; } + +.dev-overlay { display:flex; flex-direction:column; } +.overlay-container { flex-grow:1; background:rgba(0,0,0,.3); border:1px solid var(--border); border-radius:var(--r); position:relative; overflow:hidden; min-height:220px; } +.zone-box { position:absolute; box-sizing:border-box; border:2px solid var(--primary); background:var(--primary-dim); border-radius:3px; cursor:pointer; transition:var(--t); } +.zone-box:hover { background:rgba(99,72,219,.3); } +.zone-tag { position:absolute; top:-17px; left:-2px; background:var(--primary); color:#fff; font-size:8px; font-family:var(--font-mono); padding:1px 5px; border-radius:3px; white-space:nowrap; } + +.json-pre { background:rgba(0,0,0,.3); border:1px solid var(--border); border-radius:var(--r); padding:14px 16px; max-height:280px; overflow-y:auto; } +.json-pre code { font-family:var(--font-mono); font-size:11px; color:hsl(155,70%,70%); white-space:pre-wrap; } +.json-ctrls { display:flex; gap:6px; } + +/* ─────────────── CONSOLE ─────────────── */ +.console { position:fixed; bottom:0; left:0; right:0; height:var(--console-h); background:hsl(232,25%,2%); border-top:1px solid var(--border); transition:height var(--t); z-index:100; display:flex; flex-direction:column; } +.console.expanded { height:var(--console-exp); } +.console-bar { height:var(--console-h); flex-shrink:0; display:flex; justify-content:space-between; align-items:center; padding:0 20px; cursor:pointer; } +.cbar-left { display:flex; align-items:center; gap:10px; } +.cbar-title { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:var(--text-2); } +.cbar-right { display:flex; gap:6px; } +.cnsl-btn { background:rgba(255,255,255,.05); border:1px solid var(--border); border-radius:5px; color:var(--text-3); font-size:10px; padding:3px 9px; transition:var(--t); } +.cnsl-btn:hover { background:rgba(255,255,255,.1); color:var(--text); } +.console-body { flex-grow:1; overflow-y:auto; padding:10px 20px; } +.dot-ind { width:7px; height:7px; border-radius:50%; background:var(--text-3); flex-shrink:0; transition:var(--t); } +.dot-ind.active { background:var(--primary); box-shadow:0 0 8px var(--primary); animation:pulse 1.4s infinite; } +.dot-ind.success { background:var(--success); box-shadow:0 0 8px var(--success); } +.dot-ind.error { background:var(--danger); box-shadow:0 0 8px var(--danger); } +@keyframes pulse { 0%,100%{opacity:.6;transform:scale(.9)} 50%{opacity:1;transform:scale(1.15)} } +.log-line { font-family:var(--font-mono); font-size:11px; line-height:1.65; } +.log-sys { color:var(--primary); } +.log-ok { color:var(--success); } +.log-err { color:var(--danger); } +.log-warn { color:var(--warn); } + +/* ─────────────── CROP TOOLTIP ─────────────── */ +.crop-tip { position:fixed; display:none; background:hsl(232,25%,3%); border:1px solid var(--border-hi); border-radius:var(--r); padding:10px; box-shadow:0 10px 40px rgba(0,0,0,.7); z-index:999; width:290px; pointer-events:none; } +.crop-tip-title { font-size:9px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-3); margin-bottom:7px; } +.crop-tip img { width:100%; border-radius:5px; border:1px solid var(--border); } + +/* ─────────────── TOAST ─────────────── */ +.toast { position:fixed; bottom:calc(var(--console-h)+16px); left:50%; transform:translateX(-50%) translateY(12px); background:hsl(232,22%,12%); border:1px solid var(--border-hi); border-radius:var(--r); padding:10px 18px; font-size:12.5px; box-shadow:0 8px 30px rgba(0,0,0,.5); opacity:0; pointer-events:none; transition:opacity .25s,transform .25s; z-index:200; } +.toast.show { opacity:1; transform:translateX(-50%) translateY(0); } + +/* ─────────────── SHARED ─────────────── */ +.glass { background:var(--surface); backdrop-filter:blur(14px) saturate(1.3); -webkit-backdrop-filter:blur(14px) saturate(1.3); border:1px solid var(--border); border-radius:var(--r-lg); } +.glass-dim { background:rgba(255,255,255,.025); border:1px solid var(--border); border-radius:var(--r); } + +.ctrl-input { width:100%; background:rgba(255,255,255,.03); border:1px solid var(--border); border-radius:var(--r); color:var(--text); padding:8px 12px; font-family:var(--font); font-size:12.5px; outline:none; transition:border-color var(--t),box-shadow var(--t); appearance:none; } +.ctrl-input:focus { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-glo); } +select.ctrl-input { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255,255,255,.35)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; background-size:15px; padding-right:34px; cursor:pointer; } +.ctrl-input-sm { background:rgba(255,255,255,.03); border:1px solid var(--border); border-radius:7px; color:var(--text); padding:5px 10px; font-size:11.5px; outline:none; transition:border-color var(--t); appearance:none; } +.ctrl-input-sm:focus { border-color:var(--primary); } +select.ctrl-input-sm { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255,255,255,.35)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 8px center; background-size:13px; padding-right:28px; cursor:pointer; } +.hint-text { font-size:11.5px; color:var(--text-3); } + +.btn { display:inline-flex; align-items:center; gap:7px; padding:9px 16px; border-radius:var(--r); font-size:12.5px; font-weight:600; border:none; transition:var(--t); outline:none; } +.btn-run { background:var(--primary); color:#fff; } +.btn-run:not(:disabled):hover { filter:brightness(1.15); box-shadow:0 4px 18px var(--primary-glo); transform:translateY(-1px); } +.btn-run:disabled { opacity:.35; cursor:not-allowed; } +.btn-ghost { background:transparent; color:var(--text-2); border:1px solid var(--border); } +.btn-ghost:hover { border-color:var(--border-hi); color:var(--text); } +.btn-dl { background:transparent; border:1px solid var(--border); color:var(--text-2); font-size:11.5px; padding:7px 12px; } +.btn-dl:not(.disabled):hover { background:var(--surface-2); border-color:var(--border-hi); color:var(--text); } +.btn-dl.disabled { opacity:.3; pointer-events:none; } +.btn-xs { background:rgba(255,255,255,.05); border:1px solid var(--border); color:var(--text-3); font-size:10.5px; padding:4px 10px; border-radius:6px; } +.btn-xs:hover { background:rgba(255,255,255,.09); color:var(--text); } + +.spinner { display:inline-block; width:16px; height:16px; border:2px solid rgba(255,255,255,.15); border-top-color:currentColor; border-radius:50%; animation:spin .7s linear infinite; flex-shrink:0; } +@keyframes spin { to{transform:rotate(360deg)} } +.loading-msg { display:flex; align-items:center; gap:10px; color:var(--text-3); font-size:12px; padding:16px; } + +.readiness-banner { + margin:0 0 14px; + padding:11px 14px; + display:flex; + align-items:flex-start; + justify-content:space-between; + gap:14px; + border-radius:var(--r); +} +.readiness-banner.ok { border-color:var(--success-bdr); background:var(--success-bg); } +.readiness-banner.warn { border-color:var(--warn-bdr); background:var(--warn-bg); } +.readiness-banner.err { border-color:var(--danger-bdr); background:var(--danger-bg); } +.ready-title { font-size:12px; font-weight:700; color:var(--text); margin-bottom:4px; } +.ready-detail { font-size:11px; color:var(--text-2); line-height:1.45; } +.ready-pills { display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; min-width:220px; } +.ready-pill { border:1px solid var(--border); background:rgba(0,0,0,.15); border-radius:999px; padding:4px 8px; font-size:10px; color:var(--text-2); white-space:nowrap; } +.ready-pill.ok { border-color:var(--success-bdr); color:var(--success); } +.ready-pill.warn { border-color:var(--warn-bdr); color:var(--warn); } +.ready-pill.err { border-color:var(--danger-bdr); color:var(--danger); } + +/* ─────────────── WIZARD MODAL ─────────────── */ +.modal-overlay { + position:fixed; inset:0; background:rgba(0,0,0,.75); backdrop-filter:blur(8px); + z-index:500; display:flex; align-items:center; justify-content:center; + animation:fadein .2s ease; +} +@keyframes fadein { from{opacity:0} to{opacity:1} } + +.modal-box { + background:hsl(230,25%,7%); border:1px solid var(--border-hi); + border-radius:18px; width:720px; max-width:96vw; max-height:92vh; + display:flex; flex-direction:column; overflow:hidden; + box-shadow:0 30px 80px rgba(0,0,0,.8); + animation:slideup .25s cubic-bezier(.4,0,.2,1); +} +@keyframes slideup { from{transform:translateY(20px);opacity:0} to{transform:none;opacity:1} } + +.modal-header { display:flex; justify-content:space-between; align-items:flex-start; padding:24px 28px 0; } +.modal-header h2 { font-family:var(--font-disp); font-size:22px; font-weight:700; } +.modal-close { background:transparent; border:1px solid var(--border); border-radius:6px; color:var(--text-3); width:28px; height:28px; display:flex; align-items:center; justify-content:center; font-size:13px; transition:var(--t); flex-shrink:0; } +.modal-close:hover { background:rgba(255,255,255,.07); color:var(--text); } + +/* Step bar */ +.step-bar { display:flex; align-items:center; padding:20px 28px 0; } +.step-pip { display:flex; flex-direction:column; align-items:center; gap:4px; position:relative; flex-shrink:0; } +.step-pip span { width:28px; height:28px; border-radius:50%; background:rgba(255,255,255,.06); border:1.5px solid var(--border-hi); display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:600; color:var(--text-3); transition:var(--t); } +.step-pip label { font-size:9px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-3); transition:var(--t); } +.step-pip.active span { background:var(--primary); border-color:var(--primary); color:#fff; box-shadow:0 0 12px var(--primary-glo); } +.step-pip.active label { color:var(--primary); } +.step-pip.done span { background:var(--success); border-color:var(--success); color:#fff; } +.step-pip.done label { color:var(--success); } +.step-line { flex-grow:1; height:1.5px; background:var(--border-hi); margin:0 8px; margin-bottom:18px; } + +.step-content { flex-grow:1; overflow-y:auto; padding:20px 28px; } + +/* Form grid inside wizard */ +.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; } +.fg-group { display:flex; flex-direction:column; } +.fg-half { grid-column:span 1; } +.fg-full { grid-column:span 2; } +.fg-group label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:var(--text-3); margin-bottom:5px; } +.fg-group .req { color:var(--danger); } +.fg-hint { font-size:10px; color:var(--text-3); margin-top:4px; } + +/* Dropzone */ +.dropzone { + border:2px dashed var(--border-hi); border-radius:var(--r-lg); + display:flex; flex-direction:column; align-items:center; justify-content:center; + gap:8px; padding:32px 24px; cursor:pointer; transition:var(--t); + text-align:center; +} +.dropzone:hover, .dropzone.drag-over { border-color:var(--primary); background:var(--primary-dim); } +.dropzone-sm { padding:20px 24px; } +.dz-icon { font-size:32px; opacity:.7; } +.dz-text { font-size:14px; font-weight:500; color:var(--text-2); } +.dz-sub { font-size:11.5px; color:var(--text-3); } + +/* File list */ +.file-list { display:flex; flex-direction:column; gap:8px; margin-top:14px; } +.file-row { + background:rgba(255,255,255,.03); border:1px solid var(--border); + border-radius:var(--r); padding:10px 14px; + display:grid; grid-template-columns:auto 1fr auto auto auto; + align-items:center; gap:10px; +} +.file-row-icon { font-size:18px; } +.file-row-name { font-size:12px; font-weight:500; truncate:true; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } +.file-row-size { font-size:10px; color:var(--text-3); white-space:nowrap; } +.file-row-ada { display:flex; align-items:center; gap:5px; font-size:10.5px; color:var(--text-3); white-space:nowrap; } +.file-row-ada input { cursor:pointer; } +.file-row-unit { min-width:100px; } +.file-row-del { background:transparent; border:1px solid var(--danger-bdr); color:var(--danger); border-radius:5px; padding:2px 7px; font-size:10.5px; transition:var(--t); flex-shrink:0; } +.file-row-del:hover { background:var(--danger-bg); } + +.file-badge-row { display:flex; align-items:center; gap:10px; margin-top:12px; } +.file-badge { background:var(--success-bg); border:1px solid var(--success-bdr); color:var(--success); padding:5px 12px; border-radius:20px; font-size:11.5px; } + +/* Unit counts grid in step 3 */ +.unit-counts-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(200px,1fr)); gap:12px; } +.uc-group { background:rgba(255,255,255,.03); border:1px solid var(--border); border-radius:var(--r); padding:12px 14px; } +.uc-label { font-size:11px; font-weight:600; color:var(--text-2); margin-bottom:8px; display:flex; align-items:center; gap:6px; } +.uc-input { width:100%; } + +/* Skip note */ +.skip-note { padding:12px 14px; display:flex; align-items:center; gap:10px; font-size:12px; color:var(--text-2); } + +/* Review box */ +.review-box { padding:14px 16px; } +.review-box h4 { font-family:var(--font-disp); font-size:14px; font-weight:600; margin-bottom:10px; } +.review-row { display:flex; justify-content:space-between; padding:5px 0; border-bottom:1px solid var(--border); font-size:12px; } +.review-row:last-child { border:none; } +.review-row span:first-child { color:var(--text-3); } +.review-row strong { font-weight:500; } + +.modal-footer { display:flex; justify-content:flex-end; align-items:center; gap:10px; padding:16px 28px; border-top:1px solid var(--border); flex-shrink:0; }