{"record":{"id":"5a665a85ff775071","repo":"zylon-ai/private-gpt","slug":"model-target-model-not-found-available-avai","errorCode":null,"errorMessage":"Model '{target_model}' not found. Available: {available}","messagePattern":"Model '(.+?)' not found\\. Available: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/llm_component.py","lineNumber":135,"sourceCode":"                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:\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","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/llm_component.py#L117-L153","documentation":"ValueError from LLMComponent.get_llm: target_model (the passed model_id or the default) is not in the registry, and the error lists all registered aliases so you can see valid values. Registry keys are model ids plus registered aliases; anything else is rejected.","triggerScenarios":"Calling get_llm(\"foo\") with an unregistered id; requesting a model whose registration was skipped at startup due to init failure; using an alias that was never registered for the model.","commonSituations":"API/CLI consumers passing an arbitrary model name; typos in model ids; models that failed to register (check startup warnings) but are still requested.","solutions":["Use one of the ids/aliases from the error's Available list.","If the model should exist, check startup logs for 'Skipping unavailable LLM model' and fix its init failure.","Add the requested id/alias to llm.models in settings if it's genuinely missing."],"exampleFix":"# before\nllm = component.get_llm(\"gpt4o\")\n\n# after (exact registered id)\nllm = component.get_llm(\"gpt-4o\")","handlingStrategy":"validation","validationCode":"def model_is_available(component, model_id: str) -> bool:\n    return component.registry.get(model_id) is not None","typeGuard":"def is_registered_model(component, model_id: object) -> bool:\n    return isinstance(model_id, str) and component.registry.get(model_id) is not None","tryCatchPattern":"try:\n    llm = component.get_llm(model_id)\nexcept ValueError as e:\n    if 'not found. Available' in str(e):\n        available = component.registry.get_all_aliases()\n        raise ModelNotFoundError(f'{model_id} not in {available}') from e\n    raise","preventionTips":["Expose the registered alias list via an API/health endpoint so clients choose valid ids.","Validate user-supplied model ids against the registry before use.","Check startup warnings for skipped models before assuming a configured id is available."],"tags":["llm","registry","validation","configuration"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}