rohitg00/ai-engineering-from-scratch · error · ValueError

unknown op {op}

Error message

unknown op {op}

What it means

Error "unknown op {op}" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/19-capstone-projects/39-instruction-tuning-sft/code/main.py:239

    ("list", "an ordered, mutable sequence of values."),
    ("dict", "a mapping from keys to values."),
    ("string", "a sequence of characters."),
    ("integer", "a whole number without a fractional part."),
    ("float", "a number with a fractional part stored in binary."),
    ("module", "a file of python code that can be imported."),
]


def _arithmetic_response(a: int, b: int, op: str) -> str:
    if op == "+":
        return f"{a} + {b} = {a + b}"
    if op == "-":
        return f"{a} - {b} = {a - b}"
    if op == "*":
        return f"{a} * {b} = {a * b}"
    if op == "/":
        return f"{a} / {b} = {a // b}"
    raise ValueError(f"unknown op {op}")


def make_dataset(seed: int = 0) -> Tuple[List[Dict[str, str]], List[str]]:
    """Returns (pairs, categories). Each pair has instruction, response."""
    rng = random.Random(seed)
    pairs: List[Dict[str, str]] = []
    categories: List[str] = []

    # Capitals (40 pairs: 10 base x 4 templates)
    cap_templates = [
        "What is the capital of {country}?",
        "Name the capital city of {country}.",
        "Capital of {country}?",
        "Tell me the capital of {country}.",
    ]
    cap_resp_templates = [
        "the capital of {country} is {city}.",
        "{city} is the capital of {country}.",

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/19-capstone-projects/39-instruction-tuning-sft/code/main.py:239 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/29b7c7b18fa408cd. Report an issue: GitHub.