@assistant-ui/react
Version:
Typescript/React library for AI Chat
79 lines • 3.11 kB
TypeScript
import { ModelContext } from "../../model-context";
import { AppendMessage, ThreadMessage } from "../../types";
import { RunConfig } from "../../types/AssistantTypes";
import type { Unsubscribe } from "../../types/Unsubscribe";
import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
import { ChatModelRunOptions, ChatModelRunResult } from "../local";
import { ExportedMessageRepository } from "../utils/MessageRepository";
import { ComposerRuntimeCore, ThreadComposerRuntimeCore } from "./ComposerRuntimeCore";
export type RuntimeCapabilities = {
readonly switchToBranch: boolean;
readonly edit: boolean;
readonly reload: boolean;
readonly cancel: boolean;
readonly unstable_copy: boolean;
readonly speech: boolean;
readonly attachments: boolean;
readonly feedback: boolean;
};
export type AddToolResultOptions = {
messageId: string;
toolName: string;
toolCallId: string;
result: any;
};
export type SubmitFeedbackOptions = {
messageId: string;
type: "negative" | "positive";
};
export type ThreadSuggestion = {
prompt: string;
};
export type SpeechState = {
readonly messageId: string;
readonly status: SpeechSynthesisAdapter.Status;
};
export type SubmittedFeedback = {
readonly type: "negative" | "positive";
};
export type ThreadRuntimeEventType = "run-start" | "run-end" | "initialize" | "model-context-update";
export type StartRunConfig = {
parentId: string | null;
sourceId: string | null;
runConfig: RunConfig;
};
export type ResumeRunConfig = StartRunConfig & {
stream: (options: ChatModelRunOptions) => AsyncGenerator<ChatModelRunResult, void, unknown>;
};
export type ThreadRuntimeCore = Readonly<{
getMessageById: (messageId: string) => {
parentId: string | null;
message: ThreadMessage;
} | undefined;
getBranches: (messageId: string) => readonly string[];
switchToBranch: (branchId: string) => void;
append: (message: AppendMessage) => void;
startRun: (config: StartRunConfig) => void;
resumeRun: (config: ResumeRunConfig) => void;
cancelRun: () => void;
addToolResult: (options: AddToolResultOptions) => void;
speak: (messageId: string) => void;
stopSpeaking: () => void;
getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
submitFeedback: (feedback: SubmitFeedbackOptions) => void;
getModelContext: () => ModelContext;
composer: ThreadComposerRuntimeCore;
getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
beginEdit: (messageId: string) => void;
speech: SpeechState | undefined;
capabilities: Readonly<RuntimeCapabilities>;
isDisabled: boolean;
messages: readonly ThreadMessage[];
suggestions: readonly ThreadSuggestion[];
extras: unknown;
subscribe: (callback: () => void) => Unsubscribe;
import(repository: ExportedMessageRepository): void;
export(): ExportedMessageRepository;
unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
}>;
//# sourceMappingURL=ThreadRuntimeCore.d.ts.map