UNPKG

@assistant-ui/react

Version:

TypeScript/React library for AI Chat

106 lines 3.7 kB
import { FC, PropsWithChildren } from "react"; import { ToolUIApi, ToolUIState, ToolUIMeta } from "../../client/types/ToolUI"; import { MessageClientApi, MessageClientState } from "../../client/types/Message"; import { ThreadListItemClientApi, ThreadListItemClientState } from "../../client/types/ThreadListItem"; import { MessagePartClientApi, MessagePartClientState } from "../../client/types/Part"; import { ThreadClientApi, ThreadClientState } from "../../client/types/Thread"; import { ComposerClientApi, ComposerClientState } from "../../client/types/Composer"; import { AttachmentClientApi, AttachmentClientState } from "../../client/types/Attachment"; import { Unsubscribe } from "@assistant-ui/tap"; import { ModelContextProvider } from "../../model-context"; import { AssistantEvent, AssistantEventCallback, AssistantEventSelector } from "../../types/EventTypes"; import { ThreadListClientApi, ThreadListClientState } from "../../client/types/ThreadList"; export type AssistantState = { readonly threads: ThreadListClientState; readonly toolUIs: ToolUIState; readonly threadListItem: ThreadListItemClientState; readonly thread: ThreadClientState; readonly composer: ComposerClientState; readonly message: MessageClientState; readonly part: MessagePartClientState; readonly attachment: AttachmentClientState; }; type AssistantApiField<TApi, TMeta extends { source: string | null; query: any; }> = (() => TApi) & (TMeta | { source: null; query: Record<string, never>; }); type ThreadsMeta = { source: "root"; query: Record<string, never>; }; type ThreadListItemMeta = { source: "threads"; query: { type: "index"; index: number; archived: boolean; } | { type: "main"; } | { type: "id"; id: string; }; }; type ThreadMeta = { source: "threads"; query: { type: "main"; }; }; type ComposerMeta = { source: "message" | "thread"; query: Record<string, never>; }; type MessageMeta = { source: "thread"; query: { type: "index"; index: number; }; }; type PartMeta = { source: "message" | "root"; query: { type: "index"; index: number; } | Record<string, never>; }; type AttachmentMeta = { source: "message" | "composer"; query: { type: "index"; index: number; }; }; export type AssistantApi = { threads: AssistantApiField<ThreadListClientApi, ThreadsMeta>; toolUIs: AssistantApiField<ToolUIApi, ToolUIMeta>; threadListItem: AssistantApiField<ThreadListItemClientApi, ThreadListItemMeta>; thread: AssistantApiField<ThreadClientApi, ThreadMeta>; composer: AssistantApiField<ComposerClientApi, ComposerMeta>; message: AssistantApiField<MessageClientApi, MessageMeta>; part: AssistantApiField<MessagePartClientApi, PartMeta>; attachment: AssistantApiField<AttachmentClientApi, AttachmentMeta>; subscribe(listener: () => void): Unsubscribe; flushSync(): void; on<TEvent extends AssistantEvent>(event: AssistantEventSelector<TEvent>, callback: AssistantEventCallback<TEvent>): Unsubscribe; registerModelContextProvider(provider: ModelContextProvider): void; }; export declare const createAssistantApiField: <TApi, TMeta extends { source: any; query: any; }>(config: { get: () => TApi; } & (TMeta | { source: null; query: Record<string, never>; })) => AssistantApiField<TApi, TMeta>; export declare const useAssistantApi: () => AssistantApi; export declare const AssistantProvider: FC<PropsWithChildren<{ api: Partial<AssistantApi>; }>>; export {}; //# sourceMappingURL=AssistantApiContext.d.ts.map