# gizapp/chatui

Presentation values for chat components. No records, persistence or agent runtime.

```gizlang
import * as Chatui from "gizapp/chatui";
```

## Types

### `ModelOption`

```gizlang
type ModelOption = { id: string; name: string; group: string; note: string; price?: f64; context?: i64; created?: i64; vendor?: string; category?: string; line?: string; about?: string; href?: string; }
```

A model a list shows (ModelList): its id, name, group (a heading: where it runs, or what it makes) and a short note
(whether it is installed, its price); its maker (`vendor`, whose mark leads the row), a line under its name (`line`:
what it takes and makes; its maker when not given), a line about it (`about`, its row's title) and `href` when its row
is a link (else it is a choice); for sorting, its dollars per million input and output tokens or per use (`price`),
its context window in tokens (`context`) and when it was published (`created`, Unix seconds), and for its filter how a
plan pays for it (`category`: "included", "usage"), each left out when not known.

- `id`: `string`
- `name`: `string`
- `group`: `string`
- `note`: `string`
- `price`: `_gizlang_sdk_core.Option<f64>`
- `context`: `_gizlang_sdk_core.Option<i64>`
- `created`: `_gizlang_sdk_core.Option<i64>`
- `vendor`: `_gizlang_sdk_core.Option<string>`
- `category`: `_gizlang_sdk_core.Option<string>`
- `line`: `_gizlang_sdk_core.Option<string>`
- `about`: `_gizlang_sdk_core.Option<string>`
- `href`: `_gizlang_sdk_core.Option<string>`

### `Sortable`

```gizlang
type Sortable = { name: string; vendor: string; price: f64; context: i64; created: i64; }
```

What a row sorts by: its name, its maker ("" not said), its price in dollars (-1 not said), its context window in
tokens and when it was published (0 not said).

- `name`: `string`
- `vendor`: `string`
- `price`: `f64`
- `context`: `i64`
- `created`: `i64`

### `Source`

```gizlang
type Source = { title: string; url: string; }
```

A source a reply cites: its title and URL.

- `title`: `string`
- `url`: `string`

### `Chip`

```gizlang
type Chip = { letter: string; site: string; title: string; url: string; }
```

A cited site as a chip: its initial, site, title and URL.

- `letter`: `string`
- `site`: `string`
- `title`: `string`
- `url`: `string`

### `ContextPart`

```gizlang
type ContextPart = { name: string; tokens: i64; }
```

A part of a model's context: its name and its tokens (gizai/agent's Share).

- `name`: `string`
- `tokens`: `i64`

## Functions

### `sortsOf`

```gizlang
function sortsOf(rows: Vec<Sortable>): Vec<string>
```

The sorts of ROWS: "" (as listed) and each that some row says what it orders by.

Effects: fail, alloc.

### `places`

```gizlang
function places(rows: Vec<Sortable>): Vec<Vec<i64>>
```

Each row's place (from 1) under every sort of SORT_KEYS: `places[k][n]` is row N's under SORT_KEYS[k].

Effects: fail, alloc.

### `placeOf`

```gizlang
function placeOf(places: Vec<Vec<i64>>, n: i64, key: string): i64
```

Row N's place under the sort KEY (a row's `--o-KEY`); 0 for none (N < 0, or no places: the row stays first).

Effects: fail, alloc.

### `sortable`

```gizlang
function sortable(m: ModelOption): Sortable
```

A model option as a row to sort.

### `inCategory`

```gizlang
function inCategory(models: Vec<ModelOption>, category: string): i64
```

How many of MODELS a plan pays for as CATEGORY says ("included", "usage").

Effects: fail, alloc.

### `chips`

```gizlang
function chips(sources: Vec<Source>): Vec<Chip>
```

One chip per distinct site of `sources`, at most six.

Effects: fail, alloc.

### `keyed`

```gizlang
function keyed(text: string, key: string): string
```

The HTML of Markdown `text`, its blocks keyed by `key`.

Effects: fail, read, write, console, io, alloc.

### `groups`

```gizlang
function groups(models: Vec<ModelOption>): Vec<string>
```

The distinct groups of `models`, in order.

Effects: fail, alloc.

### `contextParts`

```gizlang
function contextParts(json: string): Vec<ContextPart>
```

The parts in `json` (a JSON list of ContextPart, as a host keeps them); none when it is empty or not such a list.

Effects: fail, alloc.

## Constants

### `SORT_KEYS`

```gizlang
const SORT_KEYS = ["new", "cheap", "dear", "context", "name", "vendor"]
```

The sorts that reorder, in the order of the menu (after "", as listed).

