zidane-ui/ models/ headless
import { … } from 'zidane-ui/models/headless'ui/src/models/headless/index.ts
Functions#
compactWindowFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function compactWindow(tokens: number): stringParameters
| Name | Type | Description |
|---|---|---|
| tokens | number | A context window size in tokens. |
Returns
stringgroupKeyOfFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function groupKeyOf(entry: Pick<ModelCatalogRow, 'providerKey' | 'account'>): stringParameters
| Name | Type | Description |
|---|---|---|
| entry | Pick<ModelCatalogRow, 'providerKey' | 'account'> | A row, or any object with its |
Returns
stringlineupKeyOfFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function lineupKeyOf(entry: ModelCatalogRow): stringParameters
| Name | Type | Description |
|---|---|---|
| entry | ModelCatalogRow | The catalog row. |
Returns
stringmodelLineupFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function modelLineup(catalog: readonly ModelCatalogRow[]): ReadonlySet<string>Parameters
| Name | Type | Description |
|---|---|---|
| catalog | readonly ModelCatalogRow[] | The catalog rows. The result is cached per array. |
Returns
ReadonlySet<string>modelNameOfFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function modelNameOf(
catalog: readonly ModelCatalogRow[] | null,
modelId: string,
providerKey?: string | null,
): stringParameters
| Name | Type | Default | Description |
|---|---|---|---|
| catalog | readonly ModelCatalogRow[] | null | The catalog rows, or | |
| modelId | string | The model id to name. | |
| providerKey? | string | null | null | Limits the lookup to one provider. Defaults to |
Returns
stringmodelNamesOfFunction#
The one ModelNamesStore over a host's models (this computer's catalog, and its providers when listed).
Without models, every model keeps its readable id.
function modelNamesOf(models: ComposerModels | undefined): ModelNamesStoreParameters
| Name | Type | Description |
|---|---|---|
| models | ComposerModels | undefined | The host's member. |
Returns
modelSearchScoreFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function modelSearchScore(
entry: ModelCatalogRow,
terms: readonly string[],
): number | nullParameters
| Name | Type | Description |
|---|---|---|
| entry | ModelCatalogRow | The catalog row. |
| terms | readonly string[] | The lower-cased search terms. Every term must match. |
Returns
number | nullnamerForFunction#
A namer reading catalog: the entry of that provider first, then any provider listing the id.
function namerFor(
catalog: readonly Pick<ModelCatalogRow, 'providerKey' | 'modelId' | 'modelName'>[],
): ModelNamerParameters
| Name | Type | Description |
|---|---|---|
| catalog | readonly Pick<ModelCatalogRow, 'providerKey' | 'modelId' | 'modelName'>[] | The catalog rows. |
Returns
ModelNameroffCatalogRowsFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function offCatalogRows(
catalog: readonly ModelCatalogRow[],
query: string,
currentProviderKey: string | null,
catalogMatched: boolean,
): ModelCatalogRow[]Parameters
| Name | Type | Description |
|---|---|---|
| catalog | readonly ModelCatalogRow[] | The catalog rows. |
| query | string | What the user typed in the search field. |
| currentProviderKey | string | null | Key of the provider in use, listed after the one the query names. |
| catalogMatched | boolean | Whether the catalog already matched the query. If so, only an id-shaped query gets typed routes. |
Returns
pickerGroupsFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function pickerGroups<E extends ModelCatalogRow>(
catalog: readonly E[],
query: string,
chain: readonly ModelPickRef[],
showLegacy: boolean,
current: ReadonlySet<string>,
): PickerGroup<E>[]Type parameters
| Name | Type | Description |
|---|---|---|
| E | extends ModelCatalogRow |
Parameters
| Name | Type | Description |
|---|---|---|
| catalog | readonly E[] | The catalog rows. |
| query | string | What the user typed in the search field. Blank lists by provider. |
| chain | readonly ModelPickRef[] | The chain in force. Its models lead the list as "In use". |
| showLegacy | boolean | Lists every model instead of only the current ones. |
| current | ReadonlySet<string> | The lineup keys of the current models, from |
Returns
PickerGroup<E>[]pickRefOfFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function pickRefOf(entry: ModelCatalogRow): ModelPickRefParameters
| Name | Type | Description |
|---|---|---|
| entry | ModelCatalogRow | The catalog row. |
Returns
providerAccountLabelFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function providerAccountLabel(
entry: Pick<ModelCatalogRow, 'providerLabel' | 'account'>,
): stringParameters
| Name | Type | Description |
|---|---|---|
| entry | Pick<ModelCatalogRow, 'providerLabel' | 'account'> | A row, or any object with its |
Returns
stringrefKeyFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function refKey(entry: ModelPickRef): stringParameters
| Name | Type | Description |
|---|---|---|
| entry | ModelPickRef | The pick. |
Returns
stringresolveChainFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function resolveChain(
chain: readonly ModelPickRef[],
catalog: readonly ModelCatalogRow[],
): readonly ModelPickRef[]Parameters
| Name | Type | Description |
|---|---|---|
| chain | readonly ModelPickRef[] | The chain: the primary, then its fallbacks. |
| catalog | readonly ModelCatalogRow[] | The catalog rows. |
Returns
readonly ModelPickRef[]resolvePickFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function resolvePick(
pick: ModelPickRef,
catalog: readonly ModelCatalogRow[],
): ModelPickRefParameters
| Name | Type | Description |
|---|---|---|
| pick | ModelPickRef | A pick of the chain. |
| catalog | readonly ModelCatalogRow[] | The catalog rows. |
Returns
rowKeyFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function rowKey(entry: ModelCatalogRow): stringParameters
| Name | Type | Description |
|---|---|---|
| entry | ModelCatalogRow | The catalog row. |
Returns
stringunresolveChainFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function unresolveChain(
next: readonly ModelPickRef[],
chain: readonly ModelPickRef[],
shown: readonly ModelPickRef[],
): ModelPickRef[]Parameters
| Name | Type | Description |
|---|---|---|
| next | readonly ModelPickRef[] | The edited resolved chain. |
| chain | readonly ModelPickRef[] | The chain before the edit. |
| shown | readonly ModelPickRef[] |
|
Returns
withPrimaryFunction#
zidane-ui/models/headless: the model catalog, React-free. The rows a host
lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick
(ModelPickRef), what a host offers of its catalogs (ComposerModels), the
rules a picker lists, searches and edits a chain by, and the names a model
goes by (modelNamesOf). The composer's pickers and the model rows of
Settings both read it.
function withPrimary(chain: readonly ModelPickRef[], pick: ModelPickRef): ModelPickRef[]Parameters
| Name | Type | Description |
|---|---|---|
| chain | readonly ModelPickRef[] | The current chain: the primary, then its fallbacks. |
| pick | ModelPickRef | The model to make the primary. |
Returns
Interfaces#
ComposerModelEntryInterface#
A catalog row with the options its model declares: what ComposerModels.catalog lists.
interface ComposerModelEntry extends ModelCatalogRowProperties
| Name | Type | Description |
|---|---|---|
account?from ModelCatalogRow | { active?: boolean; id: string; label: string } | The provider's stored account this row runs on, when it has several. Absent: its only one. |
contextWindowfrom ModelCatalogRow | number | null | Context window in tokens, or |
details?from ModelCatalogRow | readonly string[] | Short facts shown beside the name, before the window ( |
isDefault?from ModelCatalogRow | boolean | The provider's default model: what a new chat falls back to on this provider. |
modelIdfrom ModelCatalogRow | string | Model id within the provider. |
modelNamefrom ModelCatalogRow | string | The catalog's display name ( |
modelProvider?from ModelCatalogRow | string | Attribution for an aggregator's row ( |
offCatalog?from ModelCatalogRow | boolean | A typed id the catalog does not know: used as typed, no metadata. |
| options? | readonly ComposerModelOption[] | The feature toggles the model declares. Absent or empty: none. |
providerKeyfrom ModelCatalogRow | string | Key of the provider that serves the model. |
providerLabelfrom ModelCatalogRow | string | Provider name shown as the group heading. |
references?from ModelCatalogRow | boolean | An image model that takes reference images (to edit, or to match a style). |
searchCorpus?from ModelCatalogRow | string | Pre-lowercased search text. Default: provider key and label, account, id, name, attribution. |
supportsAdaptive?from ModelCatalogRow | boolean | The model's provider has an adaptive thinking mode, so the effort pickers offer |
supportsReasoningfrom ModelCatalogRow | boolean | The model supports reasoning effort. |
transparency?from ModelCatalogRow | boolean | An image model that can make a transparent background. |
unavailable?from ModelCatalogRow | string | Why the row cannot be picked with the current credentials. The row shows, greyed out, and picking it does nothing. |
ComposerModelOptionInterface#
A feature toggle a model declares (fast mode, …).
interface ComposerModelOptionProperties
| Name | Type | Description |
|---|---|---|
| description? | string | What it does. |
| id | string | The option's id, a key of the session's enabled options. |
| label | string | Its name. |
ComposerModelsInterface#
The model catalogs, kept current.
interface ComposerModelsProperties
| Name | Type | Description |
|---|---|---|
| catalog | (cwd: string | undefined, hostId: string | null) => Readable<ResourceSnapshot<readonly ComposerModelEntry[]>> | The chat models a folder ( |
| images? | (cwd: string | null) => Readable<ResourceSnapshot<readonly ImageModelRow[]>> | The image models for a folder. Absent: the picker has no Image tab. |
| providers? | () => Readable<ResourceSnapshot<readonly { key: string; label: string }[]>> | Every provider this computer knows, signed in or not (labels for model names). |
ImageModelRowInterface#
One image model, as the host lists it.
interface ImageModelRowProperties
| Name | Type | Description |
|---|---|---|
| available | boolean | The provider's credentials can generate with it. |
| isDefault? | boolean | The model |
| modelId | string | The model's id at the provider. |
| modelName | string | The model's display name. |
| providerKey | string | The provider's key, for example |
| providerLabel | string | The provider's display name. |
| reason? | string | Why it is not available. |
| references | boolean | The model takes reference images. |
| transparency | boolean | The model can return a transparent background. |
ModelCatalogRowInterface#
One row of the catalog.
interface ModelCatalogRowProperties
| Name | Type | Description |
|---|---|---|
| account? | { active?: boolean; id: string; label: string } | The provider's stored account this row runs on, when it has several. Absent: its only one. |
| contextWindow | number | null | Context window in tokens, or |
| details? | readonly string[] | Short facts shown beside the name, before the window ( |
| isDefault? | boolean | The provider's default model: what a new chat falls back to on this provider. |
| modelId | string | Model id within the provider. |
| modelName | string | The catalog's display name ( |
| modelProvider? | string | Attribution for an aggregator's row ( |
| offCatalog? | boolean | A typed id the catalog does not know: used as typed, no metadata. |
| providerKey | string | Key of the provider that serves the model. |
| providerLabel | string | Provider name shown as the group heading. |
| references? | boolean | An image model that takes reference images (to edit, or to match a style). |
| searchCorpus? | string | Pre-lowercased search text. Default: provider key and label, account, id, name, attribution. |
| supportsAdaptive? | boolean | The model's provider has an adaptive thinking mode, so the effort pickers offer |
| supportsReasoning | boolean | The model supports reasoning effort. |
| transparency? | boolean | An image model that can make a transparent background. |
| unavailable? | string | Why the row cannot be picked with the current credentials. The row shows, greyed out, and picking it does nothing. |
ModelNamesInterface#
How models and providers are named.
interface ModelNamesProperties
| Name | Type | Description |
|---|---|---|
| model | ModelNamer | A model's name. |
| provider | (providerKey: string) => string | A provider's label ( |
ModelNamesProviderInterface#
A provider as the sign-in report lists it.
interface ModelNamesProviderProperties
| Name | Type | Description |
|---|---|---|
| key | string | The provider's key. |
| label | string | Its label. |
ModelNamesStoreInterface#
The live names.
interface ModelNamesStoreProperties
| Name | Type | Description |
|---|---|---|
| get | () => ModelNames | The names now (a new object when the catalog changes). |
| subscribe | (listener: () => void) => () => void | Registers a listener (the first one starts reading). Returns the unsubscribe. |
ModelPickRefInterface#
A model pick: provider, model and, when the provider has several, the stored account it runs on.
interface ModelPickRefProperties
| Name | Type | Description |
|---|---|---|
| account? | string | Id of the stored account the pick runs on. Only set when the provider has several. |
| modelId | string | Model id within the provider. |
| providerKey | string | Key of the provider, for example |
PickerGroupInterface#
One section of the model picker list.
interface PickerGroup<E extends ModelCatalogRow = ModelCatalogRow>Type parameters
| Name | Type | Default | Description |
|---|---|---|---|
| E | extends ModelCatalogRow | ModelCatalogRow |
Properties
| Name | Type | Description |
|---|---|---|
| detail? | string | Shown after the label as typed (not uppercased): the typed id of the routes group. |
| key | string | Provider key ( |
| label | string | Heading of the section. |
| providerKey | string | null | Provider key for coloring; |
| rows | E[] | The models listed in the section. |
| total | number | Models of this provider in the catalog, before the lineup filter. |