Skip to contentVibraUI
Dashboards

AI vocabulary

The AI dashboard's words, shared by both assistant pages: the models a member can send to and how they are named, and the rule that greets the member by the time of day.

One module both assistants print their models and their greeting from, so the two pages never offer different models or greet the same hour two ways. Plain constants and pure functions: the model type is read off the AiThread entity and erased, so a client island and a server file can both import it without the store coming along.

Install

npx shadcn@latest add @vibra/vocabulary-ai

Needs the @vibra registry in your components.json — set it up once.

Props

PropTypeDefaultDescription
ASSISTANT_MODELS{ value: AssistantModel; label: string }[]—Northwind 2, Northwind Large 2 and Northwind Fast 2 — the in-house family, fictional like every AI name in the kit — in the order the composer offers them.
MODEL_IDS / isModelreadonly AssistantModel[] / (value: string) => value is AssistantModel—The ids a server action accepts, and the check it runs.
modelLabel(value: AssistantModel) => string—A model's name as the composer prints it.
greetingFor(at: Date) => string—Good morning, afternoon or evening by the hour of at, read in UTC.

Dependencies

Source

lib/dashboards/ai/vocabulary.ts
import type { AiThread } from "@/lib/sample-data"

/**
 * The AI dashboard's words, shared by both assistant pages: the models a
 * reader can send to, as the store names them and as the composer prints
 * them, and the rule that greets the member by the time of day. One file, so
 * the two pages never offer different models or greet the same hour two ways.
 */

export type AssistantModel = AiThread["model"]

/** Northwind's in-house family: the default, then the large and the fast. */
export const ASSISTANT_MODELS: { value: AssistantModel; label: string }[] = [
  { value: "nw-2", label: "Northwind 2" },
  { value: "nw-large-2", label: "Northwind Large 2" },
  { value: "nw-fast-2", label: "Northwind Fast 2" },
]

export const MODEL_IDS: readonly AssistantModel[] = ASSISTANT_MODELS.map((model) => model.value)

export function isModel(value: string): value is AssistantModel {
  return (MODEL_IDS as readonly string[]).includes(value)
}

/** The model's name as the composer prints it. */
export function modelLabel(value: AssistantModel): string {
  return ASSISTANT_MODELS.find((model) => model.value === value)?.label ?? value
}

/** "Good morning", "Good afternoon" or "Good evening" by the hour of `at`, read in UTC. */
export function greetingFor(at: Date): string {
  const hour = at.getUTCHours()
  if (hour >= 5 && hour < 12) return "Good morning"
  if (hour >= 12 && hour < 18) return "Good afternoon"
  return "Good evening"
}