UNPKG

@assistant-ui/react

Version:

TypeScript/React library for AI Chat

76 lines (66 loc) 1.77 kB
import { ReadonlyJSONObject } from "assistant-stream/utils"; import type { ThreadMessage } from "./AssistantTypes"; export type TextMessagePart = { readonly type: "text"; readonly text: string; readonly parentId?: string; }; export type ReasoningMessagePart = { readonly type: "reasoning"; readonly text: string; readonly parentId?: string; }; export type SourceMessagePart = { readonly type: "source"; readonly sourceType: "url"; readonly id: string; readonly url: string; readonly title?: string; readonly parentId?: string; }; export type ImageMessagePart = { readonly type: "image"; readonly image: string; readonly filename?: string; }; export type FileMessagePart = { readonly type: "file"; readonly filename?: string; readonly data: string; readonly mimeType: string; }; export type Unstable_AudioMessagePart = { readonly type: "audio"; readonly audio: { readonly data: string; readonly format: "mp3" | "wav"; }; }; export type ToolCallMessagePart< TArgs = ReadonlyJSONObject, TResult = unknown, > = { readonly type: "tool-call"; readonly toolCallId: string; readonly toolName: string; readonly args: TArgs; readonly result?: TResult | undefined; readonly isError?: boolean | undefined; readonly argsText: string; readonly artifact?: unknown; readonly interrupt?: { type: "human"; payload: unknown }; readonly parentId?: string; readonly messages?: readonly ThreadMessage[]; }; export type ThreadUserMessagePart = | TextMessagePart | ImageMessagePart | FileMessagePart | Unstable_AudioMessagePart; export type ThreadAssistantMessagePart = | TextMessagePart | ReasoningMessagePart | ToolCallMessagePart | SourceMessagePart | FileMessagePart | ImageMessagePart;