Chat
import { Chat } from '@hanzo/ui/chat'
No examples yet.
Types
export interface Turn {id: stringrole: Role/*** What was said — a string, or the wire's parts.** This was `string` alone, which is the same mistake `Role` made one field* over: a completion's content is `string | ContentPart[]` (text beside an* image), so a turn holding an attachment could not be handed to this at all.* Narrowing the wire in a component fed BY the wire just relocates the* mismatch to every caller. `words` flattens it to prose; `Parts` draws it.*/content?: Said}
export interface ChatProps extends Omit<ThreadProps, 'children' | 'ref'> {/** The conversation, oldest first. */messages: Turn[]/** A turn is arriving: the last one carries the caret and the composer stops. */streaming?: boolean/*** Send the draft. The composer clears itself once this is called.** Named `send`, not `onSend`, and the distinction is the reason this component* is usable at all. A leaf control announces an event that happened TO it, so* `Composer` takes `onSend`. This is a container handed a whole conversation,* and the thing it is handed is a hook result whose actions are verbs —* `useChat` answers `{ messages, streaming, send, stop }`. Spelling these* `onSend`/`onStop` meant `<Chat {...useChat(…)} />` did not typecheck, which* is the ONE call this exists to make work.*/send: (text: string) => void/** End the turn in flight. Absent, the composer offers no stop. */stop?: () => void/*** Render a turn's body. Defaults to `Parts` for a list and the words for a* string.** A surface with a markdown pipeline passes it here — the plugin set is* per-surface (nine plugins, one plugin, or a regex under a bundle ceiling* that cannot afford a parser), so this package ships none and renders the* words plainly until someone says otherwise. The usual form hands the* pipeline to `Parts` rather than replacing it:* `body={(t) => <Parts parts={t.content as MessagePart[]} prose={md} />}`.*/body?: (turn: Turn) => ReactNode/** Shown instead of the thread while nothing has been said. */empty?: ReactNode/** The composer's own props — placeholder, hint, the send control, the field. */composer?: Partial<ComposerProps>}
Exports
Chattype ChatPropstype Turn