{"record":{"id":"1edc4c191658f689","repo":"zylon-ai/private-gpt","slug":"unknown-prompt-style-prompt-style","errorCode":null,"errorMessage":"Unknown prompt_style='{prompt_style}'","messagePattern":"Unknown prompt_style='(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/prompt_styles/registry.py","lineNumber":42,"sourceCode":"\n\n_BUILTIN_PROMPT_STYLE_FACTORIES: dict[str, PromptStyleProvider] = {\n    \"chat\": _build_chat_template_prompt_style,\n}\n\n\nclass PromptStyleRegistry:\n    @staticmethod\n    def get_prompt_style(\n        prompt_style: str,\n        *args: Any,\n        **kwargs: Any,\n    ) -> PromptStyleBase:\n        factory = _EXTERNAL_PROMPT_STYLE_FACTORIES.get(\n            prompt_style\n        ) or _BUILTIN_PROMPT_STYLE_FACTORIES.get(prompt_style)\n        if factory is None:\n            raise ValueError(f\"Unknown prompt_style='{prompt_style}'\")\n        return factory(*args, **kwargs)\n","sourceCodeStart":24,"sourceCodeEnd":44,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/prompt_styles/registry.py#L24-L44","documentation":"PromptStyleRegistry.get_prompt_style looks the name up in the external factory dict (populated via register_prompt_style_factory) and then in the builtin dict, which currently contains only 'chat'. Any other string raises ValueError('Unknown prompt_style=...') because no factory is registered under that name.","triggerScenarios":"Calling PromptStyleRegistry.get_prompt_style('default') / get_prompt_style('Chat') / any typo or non-registered style name. Also occurs after renaming a style or when code assumes a style exists that was never registered via register_prompt_style_factory.","commonSituations":"Typo or casing mismatch ('Chat' vs 'chat'); upgrading to a version where previously available prompt styles were removed and only 'chat' remains; copy-pasting config from another project with extra styles without registering their factories.","solutions":["Use a registered builtin name: prompt_style='chat'.","Register your custom style before lookup: register_prompt_style_factory('my-style', MyPromptStyle).","Validate free-text config against the registry keys at startup so typos surface as config errors."],"exampleFix":"// before\nstyle = PromptStyleRegistry.get_prompt_style('default')\n\n// after\nfrom private_gpt.components.llm.prompt_styles.registry import register_prompt_style_factory\nregister_prompt_style_factory('my-style', MyPromptStyle)\nstyle = PromptStyleRegistry.get_prompt_style('my-style', tokenizer=tok)","handlingStrategy":"validation","validationCode":"from private_gpt.components.llm.prompt_styles import registry as ps_reg\n\ndef valid_prompt_style(name: str) -> bool:\n    return name in ps_reg._EXTERNAL_PROMPT_STYLE_FACTORIES or name in ps_reg._BUILTIN_PROMPT_STYLE_FACTORIES\n\nif not valid_prompt_style(config.prompt_style):\n    raise ConfigurationError(f'prompt_style must be one of {ps_reg._BUILTIN_PROMPT_STYLE_FACTORIES.keys()} or a registered style')","typeGuard":null,"tryCatchPattern":"try:\n    style = PromptStyleRegistry.get_prompt_style(name, tokenizer=tok)\nexcept ValueError as e:\n    if 'Unknown prompt_style' in str(e):\n        raise ConfigurationError(f'bad prompt_style: {name!r}') from e\n    raise","preventionTips":["Validate prompt_style against the registry keys when loading settings.","Register custom styles once at import time in your app's entry module.","Treat style names as an enum in config rather than free text."],"tags":["configuration","registry","prompt-style"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}