{"record":{"id":"1b0491196b1ba309","repo":"zylon-ai/private-gpt","slug":"no-model-specified-and-no-models-are-configured","errorCode":null,"errorMessage":"No model specified and no models are configured","messagePattern":"No model specified and no models are configured","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/llm_component.py","lineNumber":130,"sourceCode":"            )\n\n        if self._default_model_id:\n            default_instance = self.registry.get(self._default_model_id)\n            if not default_instance:\n                raise ValueError(\n                    f\"Default model '{self._default_model_id}' not found in registered models\"\n                )\n\n            if not self.registry.get(LLMRegistry.default()):\n                self.registry.register(LLMRegistry.default(), default_instance)\n\n            logger.info(\"Set default model to '%s'\", self._default_model_id)\n\n    def get_llm(self, model_id: str | None = None) -> LLM:\n        target_model = model_id or self._default_model_id\n\n        if not target_model:\n            raise ValueError(\"No model specified and no models are configured\")\n\n        llm_instance = self.registry.get(target_model)\n        if not llm_instance:\n            available = self.registry.get_all_aliases()\n            raise ValueError(\n                f\"Model '{target_model}' not found. Available: {available}\"\n            )\n\n        return llm_instance.llm\n\n    def get_alias(self, model_id: str | None = None) -> str | None:\n        target_model = model_id or self._default_model_id\n        if not target_model:\n            return None\n        aliases = self.registry.get_aliases(target_model)\n        return aliases.pop() if aliases else None\n\n    def get_config(self, model_id: str | None = None) -> LLMModelConfig:","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/llm_component.py#L112-L148","documentation":"ValueError from LLMComponent.get_llm: model_id was None/empty and no default model was configured, so there is nothing to resolve. get_llm falls back to _default_model_id; when both the argument and the default are absent, resolution is impossible and the component fails fast.","triggerScenarios":"Calling get_llm() (or the llm property) on a component where no models registered successfully and no default was set — e.g. empty llm.models config, or all models failed initialization and none became default.","commonSituations":"Empty/disabled model config in settings; all models skipped due to missing keys or extras so auto-default never kicked in; tests instantiating the component without model config.","solutions":["Configure at least one model under llm.models and (optionally) set default_model.","Ensure that model initializes successfully — a default is auto-selected from registered models only when at least one registers.","In calling code, pass an explicit model_id when no default is guaranteed."],"exampleFix":"# before\nllm:\n  models: {}\n\n# after\nllm:\n  default_model: gpt-4o\n  models:\n    gpt-4o: {...}","handlingStrategy":"validation","validationCode":"def has_default_model(component) -> bool:\n    return bool(component._default_model_id)","typeGuard":null,"tryCatchPattern":"try:\n    llm = component.get_llm()\nexcept ValueError as e:\n    if 'no models are configured' in str(e):\n        raise ConfigError('Configure llm.models/default_model in settings') from e\n    raise","preventionTips":["Fail configuration validation at boot when llm.models is empty.","Pass explicit model_id at call sites where a default isn't guaranteed (scripts, tests).","Watch startup logs for 'Auto-selecting'/'Skipping' warnings — they precede this state."],"tags":["configuration","llm","startup","validation"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}