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
BaseAtlas
ABCLLMAtlasA 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/
└── model1Methods
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
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
If any segment of the path doesn't resolve.
BaseAtlas.get_default
get_default() → BaseModelContextReturn 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
A model context for the default model, ready to enter with a with block.
Raises
If no default is configured, or the configured default does not resolve to a model context factory.
BaseAtlas.__str__
__str__() → strRender 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__() → strReturn a tree view of the atlas as a string.
BaseAtlas.__len__
__len__() → intNumber of children on this node.
BaseAtlas.__contains__
__contains__(
key: str,
) → boolCheck whether a dot-delimited path resolves to a child.