yera.config.loaders.models
Model universe loader — reads and validates model config from yera.toml.
Symbols
get_model_config
get_model_config(
model_id: str,
model_type: str,
catalog: ModelCatalogue,
) → BaseModelConfigLook up a model by id across all type lists in the universe.
Parameters
Yera-internal dot-delimited model id.
The model type to look up, e.g. "llm".
The runtime model catalogue filtered to the active Yera profile.
Returns
The matching model config object.
Raises
If no model with the given id exists in any type list.
load_model_universe
load_model_universe() → ModelsUniverseRead [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
A ModelUniverse instance populated from yera.toml, or an empty instance if the section is absent.
Raises
If the models section fails Pydantic validation.
read_pyproject_yera_model_default
read_pyproject_yera_model_default(
model_type: str,
) → str | NoneRead the default model id for a single type from [tool.yera.model_defaults].
Parameters
The model type to read the default for, e.g. "llm".
Returns
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
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,
) → strDetermine 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
Explicit model id from a CLI flag, or None.
The runtime model catalog filtered to the active Yera profile.
The model type to resolve the default for, e.g. "llm".
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
The resolved model id string.
Raises
If no default can be resolved for the given type.