zylon-ai/private-gpt · error · ValueError

No model specified and no models are configured

Error message

No model specified and no models are configured

What it means

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.

Source

Thrown at private_gpt/components/llm/llm_component.py:130

            )

        if self._default_model_id:
            default_instance = self.registry.get(self._default_model_id)
            if not default_instance:
                raise ValueError(
                    f"Default model '{self._default_model_id}' not found in registered models"
                )

            if not self.registry.get(LLMRegistry.default()):
                self.registry.register(LLMRegistry.default(), default_instance)

            logger.info("Set default model to '%s'", self._default_model_id)

    def get_llm(self, model_id: str | None = None) -> LLM:
        target_model = model_id or self._default_model_id

        if not target_model:
            raise ValueError("No model specified and no models are configured")

        llm_instance = self.registry.get(target_model)
        if not llm_instance:
            available = self.registry.get_all_aliases()
            raise ValueError(
                f"Model '{target_model}' not found. Available: {available}"
            )

        return llm_instance.llm

    def get_alias(self, model_id: str | None = None) -> str | None:
        target_model = model_id or self._default_model_id
        if not target_model:
            return None
        aliases = self.registry.get_aliases(target_model)
        return aliases.pop() if aliases else None

    def get_config(self, model_id: str | None = None) -> LLMModelConfig:

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Configure at least one model under llm.models and (optionally) set default_model.
  2. Ensure that model initializes successfully — a default is auto-selected from registered models only when at least one registers.
  3. In calling code, pass an explicit model_id when no default is guaranteed.

Example fix

# before
llm:
  models: {}

# after
llm:
  default_model: gpt-4o
  models:
    gpt-4o: {...}
Defensive patterns

Strategy: validation

Validate before calling

def has_default_model(component) -> bool:
    return bool(component._default_model_id)

Try / catch

try:
    llm = component.get_llm()
except ValueError as e:
    if 'no models are configured' in str(e):
        raise ConfigError('Configure llm.models/default_model in settings') from e
    raise

Prevention

When it happens

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

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

Related errors


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