{"record":{"id":"c50a20d220995ff8","repo":"zylon-ai/private-gpt","slug":"llm-mode-mode-is-not-supported-available-av","errorCode":null,"errorMessage":"LLM mode '{mode}' is not supported. Available: {available}","messagePattern":"LLM mode '(.+?)' is not supported\\. Available: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/factories/registry.py","lineNumber":33,"sourceCode":"}\n\n\ndef register_llm(mode: str, provider: LLMProvider) -> None:\n    _PROVIDERS[mode] = provider\n\n\nclass LLMFactoryRegistry:\n    \"\"\"Registry of LLM factories by mode.\"\"\"\n\n    def __init__(self, settings: Settings):\n        self._factories: dict[str, LLMFactory] = {\n            mode: provider(settings) for mode, provider in _PROVIDERS.items()\n        }\n\n    def get_factory(self, mode: str) -> LLMFactory:\n        if mode not in self._factories:\n            available = \", \".join(sorted(self._factories)) or \"none\"\n            raise ValueError(\n                f\"LLM mode '{mode}' is not supported. Available: {available}\"\n            )\n        return self._factories[mode]\n","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/factories/registry.py#L15-L37","documentation":"ValueError from LLMFactoryRegistry.get_factory: the requested LLM mode string is not a key in the provider registry. The registry is built from a fixed _PROVIDERS mapping; anything outside it (including typos or modes whose factory failed to register) is rejected with a list of valid modes.","triggerScenarios":"Passing an unknown mode string to get_factory — e.g. from settings (llm.mode), a CLI arg, or an API request. Typos like 'openai_completions' vs 'openai-completions', or a mode name from an older/newer version of the project, trigger it.","commonSituations":"Copying a settings.yaml from another version where mode names changed; env var LLM_MODE misspelled; default settings file lacking the mode key so a placeholder is used.","solutions":["Read the error's 'Available: ...' list and use one of those exact mode strings.","Check settings (yaml/env) for the llm mode key and fix the typo/casing.","If you expect the mode to exist, verify your project version — the registry in your checkout defines which modes are valid."],"exampleFix":"# before\nllm:\n  mode: openai-chat\n\n# after (use a mode from the error's Available list)\nllm:\n  mode: openai","handlingStrategy":"validation","validationCode":"VALID_MODES = {\"openai\", \"openai-like\"}  # mirror the registry's Available list\n\ndef mode_is_supported(mode: str, registry) -> bool:\n    return mode in registry._factories  # or keep your own allowlist in sync","typeGuard":"def is_supported_mode(mode: object) -> bool:\n    return isinstance(mode, str) and mode in KNOWN_MODES","tryCatchPattern":"try:\n    factory = registry.get_factory(mode)\nexcept ValueError as e:\n    match = re.search(r\"Available: (.+)\", str(e))\n    raise ConfigError(f\"Bad llm mode {mode!r}; valid: {match.group(1) if match else 'unknown'}\") from e","preventionTips":["Validate llm.mode against the registry's keys at config-load time with a clear error message.","Treat mode names as an API contract: add a config test that asserts your settings' mode is registered.","Re-validate settings after upgrading the library — mode sets change between versions."],"tags":["configuration","llm","registry","validation"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}