ooai_llm.tui.data¶
Testable data layer for the optional Textual TUI.
- Purpose:
Keep model/catalog/benchmark data shaping independent of Textual so the interactive app can be tested without a terminal.
- Design:
The TUI consumes preformatted row models, snapshot-level metrics, simple client-side filters, and a small refresh gate used to avoid accidental repeated provider/catalog calls.
Attributes¶
Classes¶
Initial state for the optional Textual model explorer. |
|
A model comparison row ready for display. |
|
A catalog row ready for display. |
|
A model suite row ready for display. |
|
A benchmark endpoint row ready for display. |
|
All data needed by the Textual app to render its main tables. |
|
Result of a TUI refresh-rate decision. |
|
Tiny in-process cooldown for expensive TUI refresh actions. |
Functions¶
|
Format optional USD values for compact terminal display. |
|
Format optional token counts for compact terminal display. |
|
Load catalog, comparison, and suite rows for the TUI. |
|
Return snapshot rows for one table-backed view. |
|
Normalize repeatable or comma-separated TUI view names. |
|
Return lowercase searchable text for any TUI display row. |
|
Filter already-loaded TUI rows by free-text query and provider. |
|
Return sorted provider names visible in the snapshot. |
|
Return compact metrics for the dashboard cards. |
Module Contents¶
- ooai_llm.tui.data.TUI_LOAD_VIEW_CHOICES: tuple[TUIViewName, Ellipsis] = ('cheapest', 'coding', 'catalog', 'suites', 'benchmarks')[source]¶
- class ooai_llm.tui.data.TUIConfig(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelInitial state for the optional Textual model explorer.
- catalog_scope: TUICatalogScope = 'supported'[source]¶
- theme: ooai_llm.tui.themes.TUIThemeName = 'paper'[source]¶
- load_views: list[TUIViewName] | None = None[source]¶
- resolved_load_views() tuple[TUIViewName, Ellipsis][source]¶
Return the table-backed views that should be loaded.
- should_load_view(view: TUIViewName) bool[source]¶
Return whether a table-backed view should be fetched.
- class ooai_llm.tui.data.TUIComparisonRow(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelA model comparison row ready for display.
- class ooai_llm.tui.data.TUICatalogRow(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelA catalog row ready for display.
- class ooai_llm.tui.data.TUISuiteRow(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelA model suite row ready for display.
- class ooai_llm.tui.data.TUIBenchmarkRow(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelA benchmark endpoint row ready for display.
- class ooai_llm.tui.data.TUISnapshot(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelAll data needed by the Textual app to render its main tables.
- cheapest: list[TUIComparisonRow] = None[source]¶
- coding: list[TUIComparisonRow] = None[source]¶
- catalog: list[TUICatalogRow] = None[source]¶
- suites: list[TUISuiteRow] = None[source]¶
- benchmarks: list[TUIBenchmarkRow] = None[source]¶
- class ooai_llm.tui.data.TUIRefreshDecision(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelResult of a TUI refresh-rate decision.
- class ooai_llm.tui.data.TUIRefreshGate(*, cooldown_seconds: float = 2.0)[source]¶
Tiny in-process cooldown for expensive TUI refresh actions.
- request(*, now: float, force: bool = False) TUIRefreshDecision[source]¶
Return whether a refresh may run and update state when allowed.
- ooai_llm.tui.data.format_money(value: decimal.Decimal | None) str[source]¶
Format optional USD values for compact terminal display.
- ooai_llm.tui.data.format_count(value: int | None) str[source]¶
Format optional token counts for compact terminal display.
- ooai_llm.tui.data.build_tui_snapshot(config: TUIConfig | None = None) TUISnapshot[source]¶
Load catalog, comparison, and suite rows for the TUI.
The function is intentionally independent of Textual so tests and future non-interactive exporters can exercise the same data path.
- ooai_llm.tui.data.rows_for_view(snapshot: TUISnapshot, view: TUIViewName) list[TUIRow][source]¶
Return snapshot rows for one table-backed view.
- ooai_llm.tui.data.normalize_tui_load_views(values: list[str] | None) list[TUIViewName] | None[source]¶
Normalize repeatable or comma-separated TUI view names.
- ooai_llm.tui.data.tui_row_search_text(row: TUIRow) str[source]¶
Return lowercase searchable text for any TUI display row.
- ooai_llm.tui.data.filter_tui_rows(rows: list[TUIRow], *, query: str = '', provider: str | None = None) list[TUIRow][source]¶
Filter already-loaded TUI rows by free-text query and provider.
- ooai_llm.tui.data.snapshot_providers(snapshot: TUISnapshot) list[str][source]¶
Return sorted provider names visible in the snapshot.
- ooai_llm.tui.data.snapshot_metrics(snapshot: TUISnapshot) dict[str, str][source]¶
Return compact metrics for the dashboard cards.