yera.models.atlas.base

Navigable tree of model context factories.

Defines BaseAtlas, the abstract base for model atlases. Atlases are built from the active Yera profile at config-load time and made available to user code through proxy singletons such as llm.

They are to be used for exploring available models and then setting them as the active context to be used within apps.

Symbols

class BaseAtlas — A navigable tree of model context factories.

BaseAtlas

Inherits: ABC
Subclasses: LLMAtlas

A navigable tree of model context factories.

Each leaf is a callable that returns a model context, ready for use in a with block. Each interior node is another atlas, holding further sub-atlases and leaves.

Yera exposes one atlas per type of model: LLMs, TTS, STT, and so on. Atlases are built from the active Yera profile and are not constructed by user code directly; users access them through proxy singletons such as llm.

Two access styles are supported:

  • Attribute access, preferred for interactive use (Jupyter, REPL): atlas.openai.gpt_4o. Dashes in configured model names become underscores in attribute form ("gpt-4o"gpt_4o).
  • Dot-path indexing, preferred for scripts: atlas["openai.gpt-4o"]. The dashed form from configuration is accepted here directly.

Atlases render as a tree when printed, so they are self-describing in interactive sessions:

Examples

print(atlas)
┌─[model-type]
├─ Default: provider1.model2
│
├── provider1/
│   ├── model1
│   └── model2
└── provider2/
    └── model1

Methods

__dir__ — List the child atlases and factories on this node.
__getitem__ — Look up a child by dot-delimited path.
get_default — Return a context for the configured default model.
__str__ — Render the atlas as a tree, showing children and the default.
__repr__ — Return a tree view of the atlas as a string.
__len__ — Number of children on this node.
__contains__ — Check whether a dot-delimited path resolves to a child.

BaseAtlas.__dir__

__dir__() → list[str]

List the child atlases and factories on this node.

Drives tab-completion in interactive environments.

BaseAtlas.__getitem__

__getitem__(
    key: str,
)

Look up a child by dot-delimited path.

Parameters

key
type: str

Dot-delimited path. Dashes in path segments are accepted and converted to underscores during lookup, so "openai.gpt-4o" and "openai.gpt_4o" are equivalent.

Returns

A child atlas (interior node) or a model context factory (leaf).

Raises

KeyError

If any segment of the path doesn't resolve.

BaseAtlas.get_default

get_default() → BaseModelContext

Return a context for the configured default model.

The default is configured at the root of the atlas only; calling this on an intermediate node raises ValueError.

Returns

type: BaseModelContext

A model context for the default model, ready to enter with a with block.

Raises

ValueError

If no default is configured, or the configured default does not resolve to a model context factory.

BaseAtlas.__str__

__str__() → str

Render the atlas as a tree, showing children and the default.

The same rendering is used for __repr__, so atlases display informatively in REPLs and notebooks.

BaseAtlas.__repr__

__repr__() → str

Return a tree view of the atlas as a string.

BaseAtlas.__len__

__len__() → int

Number of children on this node.

BaseAtlas.__contains__

__contains__(
    key: str,
) → bool

Check whether a dot-delimited path resolves to a child.