Skip to content

zidane-ui/models

import { … } from 'zidane-ui/models'ui/src/models/index.ts

Components#

ModelsProviderComponent#

zidane-ui/models: the model catalog in components. ModelsProvider (which ComposerHostProvider mounts) puts a host's catalogs in context; useModelCatalog, useComposerModelName and useComposerProviderLabel read them; providerColor gives each provider its color. The React-free catalog is zidane-ui/models/headless.

TypeScript
function ModelsProvider(props: ModelsProviderProps): Element
Parameters
NameTypeDescription
propsModelsProviderProps

The models and the children.

Element
ModelsProvider props
NameTypeDescription
childrenReactNode

The app's components.

models?ComposerModels

The host's model catalogs. Absent: no catalog, and models keep their readable ids.

ui/src/models/ModelsProvider.tsx:26

Functions#

providerColorFunction#

Text / border color.

TypeScript
function providerColor(providerKey: string): string
Parameters
NameTypeDescription
providerKeystring

The provider key, matched case-insensitively.

string

ui/src/models/provider-color.ts:53

providerTintFunction#

Soft tinted fill for chips / badges.

TypeScript
function providerTint(providerKey: string, percent?: number): string
Parameters
NameTypeDefaultDescription
providerKeystring

The provider key, matched case-insensitively.

percent?number16

How much of the provider color to mix in, 0 to 100.

string

ui/src/models/provider-color.ts:66

useComposerModelNameFunction#

Names a model as the model picker does; re-renders when the catalog arrives or changes.

TypeScript
function useComposerModelName(): ModelNamer
ModelNamer

ui/src/models/use-model-catalog.ts:58

useComposerProviderLabelFunction#

A provider's label as the model picker groups it (Anthropic).

TypeScript
function useComposerProviderLabel(): (providerKey: string) => string
(providerKey: string) => string

ui/src/models/use-model-catalog.ts:63

useModelCatalogFunction#

The catalog to list: outer when the caller loaded one, else the host's for cwd on hostId.

TypeScript
function useModelCatalog(
  outer: readonly ComposerModelEntry[] | null,
  cwd?: string,
  hostId?: string | null,
): ModelCatalogState
Parameters
NameTypeDefaultDescription
outerreadonly ComposerModelEntry[] | null

A catalog the caller already holds.

cwd?string

The folder.

hostId?string | nullnull

The server, null for this computer.

ui/src/models/use-model-catalog.ts:36

useModelsFunction#

zidane-ui/models: the model catalog in components. ModelsProvider (which ComposerHostProvider mounts) puts a host's catalogs in context; useModelCatalog, useComposerModelName and useComposerProviderLabel read them; providerColor gives each provider its color. The React-free catalog is zidane-ui/models/headless.

TypeScript
function useModels(): ComposerModels | undefined
ComposerModels | undefined

ui/src/models/ModelsProvider.tsx:31

Interfaces#

ModelCatalogStateInterface#

A model catalog as a picker reads it.

TypeScript
interface ModelCatalogState
ModelCatalogState properties
NameTypeDescription
catalogreadonly ComposerModelEntry[] | null

The rows, null while loading.

errorstring | null

Why it failed to load.

retry(() => void) | undefined

Reads it again.

ui/src/models/use-model-catalog.ts:20

ModelsProviderPropsInterface#

Props for ModelsProvider.

TypeScript
interface ModelsProviderProps
ModelsProviderProps properties
NameTypeDescription
childrenReactNode

The app's components.

models?ComposerModels

The host's model catalogs. Absent: no catalog, and models keep their readable ids.

ui/src/models/ModelsProvider.tsx:14