yera.config.loaders.models

Model universe loader — reads and validates model config from yera.toml.

Symbols

def get_model_config — Look up a model by id across all type lists in the universe.
def load_model_universe — Read ``[models]`` from yera.toml and build a ``ModelUniverse`` instance.
def read_pyproject_yera_model_default — Read the default model id for a single type from ``[tool.yera.model_defaults]``.
def read_pyproject_yera_model_defaults — Read per-type model defaults from ``[tool.yera.model_defaults]`` in pyproject.toml.
def resolve_default_model — Determine the effective model id for a given type using the resolution order.

get_model_config

get_model_config(
    model_id: str,
    model_type: str,
    catalog: ModelCatalogue,
) → BaseModelConfig

Look up a model by id across all type lists in the universe.

Parameters

model_id
type: str

Yera-internal dot-delimited model id.

model_type
type: str

The model type to look up, e.g. "llm".

catalog
type: ModelCatalogue

The runtime model catalogue filtered to the active Yera profile.

Returns

type: BaseModelConfig

The matching model config object.

Raises

ModelNotFoundInConfigError

If no model with the given id exists in any type list.

load_model_universe

load_model_universe() → ModelsUniverse

Read [models] from yera.toml and build a ModelUniverse instance.

Returns an empty ModelUniverse when the section or file is absent. Validation is eager — malformed model config raises immediately via Pydantic.

Returns

type: ModelsUniverse

A ModelUniverse instance populated from yera.toml, or an empty instance if the section is absent.

Raises

ModelInvalidConfigError

If the models section fails Pydantic validation.

read_pyproject_yera_model_default

read_pyproject_yera_model_default(
    model_type: str,
) → str | None

Read the default model id for a single type from [tool.yera.model_defaults].

Parameters

model_type
type: str

The model type to read the default for, e.g. "llm".

Returns

type: str | None

The model id string if present and valid, otherwise None.

read_pyproject_yera_model_defaults

read_pyproject_yera_model_defaults() → dict[str, str]

Read per-type model defaults from [tool.yera.model_defaults] in pyproject.toml.

Each key is a model type (e.g. "llm", "embeddings") and each value is a Yera-internal model id string. Only string values are included — malformed entries are silently ignored.

Returns

type: dict[str, str]

A dict mapping model type to default model id for any types configured in [tool.yera.model_defaults]. Empty dict if the section is absent.

resolve_default_model

resolve_default_model(
    model_override: str | None,
    catalog: ModelCatalogue,
    model_type: str,
    pyproject_model: str | None = None,
) → str

Determine the effective model id for a given type using the resolution order.

Priority: CLI --model override → pyproject.toml model_defaults → active profile catalog default → raise.

Parameters

model_override
type: str | None

Explicit model id from a CLI flag, or None.

catalog
type: ModelCatalogue

The runtime model catalog filtered to the active Yera profile.

model_type
type: str

The model type to resolve the default for, e.g. "llm".

pyproject_model
type: str | None = None

Default model id from pyproject.toml for this type, or None. Callers should pass the result of read_pyproject_yera_model_default(model_type).

Returns

type: str

The resolved model id string.

Raises

ModelTypeNotFoundInConfigError

If no default can be resolved for the given type.