{"record":{"id":"c77375241d881af2","repo":"docling-project/docling","slug":"unknown-prompt-style-prompt-style-valid-values","errorCode":null,"errorMessage":"Unknown prompt style: {prompt_style}. Valid values are {', '.join(s.value for s in TransformersPromptStyle)}","messagePattern":"Unknown prompt style: (.+?)\\. Valid values are (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"docling/models/inference_engines/vlm/_utils.py","lineNumber":192,"sourceCode":"        formatted = (\n            f\"{user_prompt_prefix}<|image_1|>{prompt}{prompt_suffix}{assistant_prompt}\"\n        )\n        _log.debug(f\"Formatted prompt for {repo_id}: {formatted}\")\n        return formatted\n    elif prompt_style == TransformersPromptStyle.CHAT:\n        # Standard chat template with image placeholder\n        messages = [\n            {\n                \"role\": \"user\",\n                \"content\": [\n                    {\"type\": \"image\"},\n                    {\"type\": \"text\", \"text\": prompt},\n                ],\n            }\n        ]\n        return processor.apply_chat_template(messages, add_generation_prompt=True)\n    else:\n        raise ValueError(\n            f\"Unknown prompt style: {prompt_style}. \"\n            f\"Valid values are {', '.join(s.value for s in TransformersPromptStyle)}\"\n        )\n","sourceCodeStart":174,"sourceCodeEnd":196,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/inference_engines/vlm/_utils.py#L174-L196","documentation":"The VLM prompt-formatting helper builds prompts according to a TransformersPromptStyle enum. Reaching the else branch — a value not matching any known style — raises ValueError listing the valid enum values. With a well-typed enum this is nearly unreachable, so it usually indicates a version skew or a raw string being passed where the enum is expected.","triggerScenarios":"Passing a prompt_style that is a plain string or an enum member from a different/older docling-core version whose values no longer match, into the VLM engine options used by format_prompt_for_vlm.","commonSituations":"Deserializing options from YAML/JSON where prompt_style stays a str instead of being coerced to TransformersPromptStyle; mixed docling/docling-core versions after a partial upgrade; user code constructing lookalike enums.","solutions":["Always pass a TransformersPromptStyle enum member (e.g. TransformersPromptStyle.CHAT_TEMPLATE) rather than a raw string.","When loading config, coerce explicitly: TransformersPromptStyle(raw_value) inside a try to fail early with a clear message.","Align docling and docling-core versions if new enum values are involved."],"exampleFix":"# before\nengine_options.prompt_style = \"chat\"  # not a valid enum value\n\n# after\nfrom docling.datamodel.vlm_model_specs import TransformersPromptStyle  # (module per installed version)\nengine_options.prompt_style = TransformersPromptStyle.CHAT_TEMPLATE","handlingStrategy":"validation","validationCode":"valid = {s.value for s in TransformersPromptStyle}\nif prompt_style not in valid:\n    raise ValueError(f\"prompt_style must be one of {valid}, got {prompt_style!r}\")","typeGuard":"def is_prompt_style(v: object) -> \"TypeGuard[TransformersPromptStyle]\":\n    return isinstance(v, TransformersPromptStyle)","tryCatchPattern":"try:\n    prompt = format_prompt_for_vlm(processor, prompt, style)\nexcept ValueError as e:\n    raise ValueError(f\"Bad prompt_style in config; valid: {[s.value for s in TransformersPromptStyle]}\") from e","preventionTips":["Pass enum members, not strings, for prompt_style.","Coerce and validate deserialized config values to the enum at load time.","Keep docling/docling-core versions aligned when new enum members appear."],"tags":["vlm","enum","configuration","validation"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}