TeX 59%
Python 40.8%
1"""JSON schemas for structured extraction (strict: every field required, additionalProperties false).23IMAGE_SCHEMA — one call per image. Flat object; fields not applicable to the scene take "not_applicable".4TEXT_SCHEMA — one call per listing on the masked text (description + features + broker details).5Both schemas are versioned; the version string is stored with every raw response.6"""7from __future__ import annotations89SCHEMA_VERSION = "wp20-schema-1.0"1011NV = "not_visible"12NA = "not_applicable"1314SCENES = ["exterior_front", "exterior_rear_or_side", "exterior_aerial_or_street", "kitchen", "bathroom",15 "living_or_dining", "bedroom", "basement", "garage", "mechanical_or_utility", "yard_pool_or_deck",16 "floor_plan_or_document", "other", "unusable"]17CLADDING = ["brick", "stone", "vinyl", "wood", "aluminum_or_steel", "stucco_or_acrylic", "fiber_cement", "other"]18DEFECTS = ["water_staining", "cracking", "mold_like_staining", "peeling_paint_or_finish", "worn_roof",19 "damaged_cladding", "sagging_or_unevenness", "none_visible"]202122def _enum(vals, extra=()):23 return {"type": "string", "enum": list(vals) + list(extra)}242526def _scale(desc):27 return {"type": "integer", "enum": [0, 1, 2, 3, 4, 5], "description": desc + " 0 = not applicable / not assessable."}282930IMAGE_SCHEMA = {31 "type": "object",32 "additionalProperties": False,33 "properties": {34 "scene": _enum(SCENES),35 "photo_quality": {"type": "integer", "enum": [1, 2, 3, 4, 5],36 "description": "Technical quality: 1 blurry/dark/cropped, 3 adequate, 5 professional."},37 "staging_or_rendering": _enum(["none_apparent", "staged", "virtually_staged_or_rendered", "unsure"]),38 # exterior39 "building_type_visual": _enum(["detached", "semi_detached", "row_or_townhouse", "other"], [NV, NA]),40 "storeys_visible": _enum(["1", "1.5", "2", "2.5", "3+"], [NV, NA]),41 "cladding": {"type": "array", "description": "Up to 3 materials.", "items": _enum(CLADDING, [NV, NA])},42 "roof_form": _enum(["gable", "hip", "flat_or_low_slope", "mansard", "mixed_or_other"], [NV, NA]),43 "roof_covering": _enum(["asphalt_shingle", "metal", "membrane_flat", "other"], [NV, NA]),44 "garage_visible": _enum(["attached", "detached", "carport", "none_visible"], [NV, NA]),45 "exterior_condition": _scale("Exterior condition 1 = severe visible deterioration, 3 = average wear for an occupied house, 5 = like new."),46 # interior47 "kitchen_grade": _enum(["basic", "standard", "upgraded", "luxury"], [NV, NA]),48 "kitchen_counters": _enum(["laminate", "quartz_granite_or_stone", "wood_or_butcher_block", "other"], [NV, NA]),49 "kitchen_cabinets": _enum(["melamine_or_laminate", "painted_or_thermofoil", "wood", "modern_high_gloss", "other"], [NV, NA]),50 "bathroom_grade": _enum(["basic", "standard", "upgraded", "luxury"], [NV, NA]),51 "flooring_main": _enum(["hardwood", "laminate_or_vinyl_plank", "ceramic_or_porcelain", "carpet", "concrete_or_other"], [NV, NA]),52 "basement_finish": _enum(["finished", "partially_finished", "unfinished"], [NV, NA]),53 "interior_condition": _scale("Interior condition 1 = heavily worn/damaged, 3 = average, 5 = like new."),54 "interior_finish_quality": _scale("Finish quality of materials visible 1 = minimal builder grade, 3 = standard, 5 = luxury."),55 # cross-cutting56 "renovation_evidence": _enum(["none_apparent", "partial", "extensive", "unsure"]),57 "visible_defects": {"type": "array", "description": "Up to 4 labels.", "items": _enum(DEFECTS)},58 "confidence": {"type": "number",59 "description": "Your confidence between 0 and 1 that the scene-relevant attributes above are correct."},60 "evidence": {"type": "string",61 "description": "At most 20 words naming the visual cues used (no speculation about hidden features)."},62 },63 "required": ["scene", "photo_quality", "staging_or_rendering", "building_type_visual", "storeys_visible", "cladding",64 "roof_form", "roof_covering", "garage_visible", "exterior_condition", "kitchen_grade", "kitchen_counters",65 "kitchen_cabinets", "bathroom_grade", "flooring_main", "basement_finish", "interior_condition",66 "interior_finish_quality", "renovation_evidence", "visible_defects", "confidence", "evidence"],67}6869UNK = "not_stated"7071TEXT_SCHEMA = {72 "type": "object",73 "additionalProperties": False,74 "properties": {75 "building_type": _enum(["detached", "semi_detached", "row_or_townhouse", "other"], [UNK]),76 "storeys": _enum(["1", "1.5", "2", "2.5", "3+"], [UNK]),77 "cladding": {"type": "array", "description": "Up to 3 materials.", "items": _enum(CLADDING, [UNK])},78 "roof_covering": _enum(["asphalt_shingle", "metal", "membrane_flat", "other"], [UNK]),79 "garage": _enum(["attached", "detached", "carport", "none"], [UNK]),80 "basement_finish": _enum(["finished", "partially_finished", "unfinished", "no_basement"], [UNK]),81 "kitchen_grade": _enum(["basic", "standard", "upgraded", "luxury"], [UNK]),82 "kitchen_counters": _enum(["laminate", "quartz_granite_or_stone", "wood_or_butcher_block", "other"], [UNK]),83 "kitchen_cabinets": _enum(["melamine_or_laminate", "painted_or_thermofoil", "wood", "modern_high_gloss", "other"], [UNK]),84 "bathroom_grade": _enum(["basic", "standard", "upgraded", "luxury"], [UNK]),85 "flooring_main": _enum(["hardwood", "laminate_or_vinyl_plank", "ceramic_or_porcelain", "carpet", "concrete_or_other"], [UNK]),86 "condition_claim": _enum(["needs_work", "average", "well_maintained", "renovated_or_like_new", "new_construction"], [UNK]),87 "renovation_claim": _enum(["none", "partial", "extensive"], [UNK]),88 "renovation_items": {"type": "array", "items": {"type": "string"},89 "description": "Renovated components with year if stated, e.g. 'roof 2019', 'kitchen 2021'."},90 "year_built_claim": {"type": "integer", "description": "Four-digit year if stated, else 0."},91 "living_area_claim_sqft": {"type": "integer",92 "description": "Living/habitable area in sq ft if stated (convert m²), else 0."},93 "building_footprint_claim_sqft": {"type": "integer",94 "description": "Footprint from stated building dimensions (e.g. 30x40 ft = 1200), else 0."},95 "heating_energy": _enum(["electricity", "natural_gas", "oil", "wood_or_pellet", "heat_pump_mentioned", "other"], [UNK]),96 "pool": _enum(["inground", "above_ground", "none"], [UNK]),97 "defects_disclosed": {"type": "array", "items": {"type": "string"},98 "description": "Explicitly disclosed problems (e.g. 'pyrite', 'vermiculite', 'roof to redo'); empty if none."},99 "price_or_assessment_mentioned": {"type": "boolean",100 "description": "True if any price, tax or municipal assessment amount survives in the text."},101 "confidence": {"type": "number", "description": "Between 0 and 1."},102 },103 "required": ["building_type", "storeys", "cladding", "roof_covering", "garage", "basement_finish", "kitchen_grade",104 "kitchen_counters", "kitchen_cabinets", "bathroom_grade", "flooring_main", "condition_claim",105 "renovation_claim", "renovation_items", "year_built_claim", "living_area_claim_sqft",106 "building_footprint_claim_sqft", "heating_energy", "pool", "defects_disclosed",107 "price_or_assessment_mentioned", "confidence"],108}109