zylon-ai/private-gpt · error · ValueError

Unknown prompt_style='{prompt_style}'

Error message

Unknown prompt_style='{prompt_style}'

What it means

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.

Source

Thrown at private_gpt/components/llm/prompt_styles/registry.py:42


_BUILTIN_PROMPT_STYLE_FACTORIES: dict[str, PromptStyleProvider] = {
    "chat": _build_chat_template_prompt_style,
}


class PromptStyleRegistry:
    @staticmethod
    def get_prompt_style(
        prompt_style: str,
        *args: Any,
        **kwargs: Any,
    ) -> PromptStyleBase:
        factory = _EXTERNAL_PROMPT_STYLE_FACTORIES.get(
            prompt_style
        ) or _BUILTIN_PROMPT_STYLE_FACTORIES.get(prompt_style)
        if factory is None:
            raise ValueError(f"Unknown prompt_style='{prompt_style}'")
        return factory(*args, **kwargs)

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Use a registered builtin name: prompt_style='chat'.
  2. Register your custom style before lookup: register_prompt_style_factory('my-style', MyPromptStyle).
  3. Validate free-text config against the registry keys at startup so typos surface as config errors.

Example fix

// before
style = PromptStyleRegistry.get_prompt_style('default')

// after
from private_gpt.components.llm.prompt_styles.registry import register_prompt_style_factory
register_prompt_style_factory('my-style', MyPromptStyle)
style = PromptStyleRegistry.get_prompt_style('my-style', tokenizer=tok)
Defensive patterns

Strategy: validation

Validate before calling

from private_gpt.components.llm.prompt_styles import registry as ps_reg

def valid_prompt_style(name: str) -> bool:
    return name in ps_reg._EXTERNAL_PROMPT_STYLE_FACTORIES or name in ps_reg._BUILTIN_PROMPT_STYLE_FACTORIES

if not valid_prompt_style(config.prompt_style):
    raise ConfigurationError(f'prompt_style must be one of {ps_reg._BUILTIN_PROMPT_STYLE_FACTORIES.keys()} or a registered style')

Try / catch

try:
    style = PromptStyleRegistry.get_prompt_style(name, tokenizer=tok)
except ValueError as e:
    if 'Unknown prompt_style' in str(e):
        raise ConfigurationError(f'bad prompt_style: {name!r}') from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/1edc4c191658f689. Report an issue: GitHub.