{"record":{"id":"40d11ed54b6553fe","repo":"rohitg00/ai-engineering-from-scratch","slug":"empty-metric","errorCode":null,"errorMessage":"empty metric","messagePattern":"empty metric","errorType":"exception","errorClass":"ParserError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/50-hypothesis-generator/code/main.py","lineNumber":95,"sourceCode":"    return [v / norm for v in vec]\n\n\ndef cosine_distance(a: list[float], b: list[float]) -> float:\n    dot = sum(x * y for x, y in zip(a, b))\n    dot = max(-1.0, min(1.0, dot))\n    return 1.0 - dot\n\n\ndef parse_response(raw: str) -> dict:\n    match = TAG_RE.search(raw)\n    if match is None:\n        raise ParserError(\"no hypothesis block found\")\n    text = match.group(\"text\").strip()\n    if not text:\n        raise ParserError(\"empty text\")\n    metric = match.group(\"metric\").strip()\n    if not metric:\n        raise ParserError(\"empty metric\")\n    raw_vars = match.group(\"variables\").strip()\n    variables = [v.strip() for v in raw_vars.split(\",\") if v.strip()]\n    if not variables:\n        raise ParserError(\"empty variables\")\n    baseline = match.group(\"baseline\")\n    baseline_ref = baseline.strip() if baseline and baseline.strip() else None\n    return {\n        \"text\": text,\n        \"variables\": variables,\n        \"metric\": metric,\n        \"baseline_ref\": baseline_ref,\n    }\n\n\ndef temperature_bucket(temperature: float) -> int:\n    \"\"\"Map a continuous temperature to a discrete bucket index.\"\"\"\n    if temperature < 0.35:\n        return 0","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/50-hypothesis-generator/code/main.py#L77-L113","documentation":"Error \"empty metric\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/50-hypothesis-generator/code/main.py:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}