@assistant-ui/react
Version:
React components for AI chat.
86 lines • 3.67 kB
TypeScript
import { SpeechState, SubmittedFeedback } from "../runtimes/core/ThreadRuntimeCore";
import { ThreadMessage, ThreadAssistantContentPart, ThreadUserContentPart, Unsubscribe } from "../types";
import { ToolCallContentPartStatus } from "../types/AssistantTypes";
import { AttachmentRuntime, MessageAttachmentRuntimeImpl } from "./AttachmentRuntime";
import { EditComposerRuntime, EditComposerRuntimeImpl } from "./ComposerRuntime";
import { ContentPartRuntime, ContentPartRuntimeImpl } from "./ContentPartRuntime";
import { MessageRuntimePath } from "./RuntimePathTypes";
import { ThreadRuntimeCoreBinding } from "./ThreadRuntime";
import { SubscribableWithState } from "./subscribable/Subscribable";
export declare const toContentPartStatus: (message: ThreadMessage, partIndex: number, part: ThreadUserContentPart | ThreadAssistantContentPart) => ToolCallContentPartStatus;
export declare const EMPTY_CONTENT: Readonly<{
type: "text";
text: "";
}>;
export type MessageState = ThreadMessage & {
/**
* @deprecated You can directly access message fields in the state. Replace `.message.content` with `.content` etc. This will be removed in 0.6.0.
*/
message: ThreadMessage;
parentId: string | null;
isLast: boolean;
/**
* @deprecated Use `branchNumber` and `branchCount` instead. This will be removed in 0.6.0.
*/
branches: readonly string[];
branchNumber: number;
branchCount: number;
/**
* @deprecated This API is still under active development and might change without notice.
*/
speech: SpeechState | undefined;
submittedFeedback: SubmittedFeedback | undefined;
};
export type MessageStateBinding = SubscribableWithState<MessageState, MessageRuntimePath>;
export type MessageRuntime = {
readonly path: MessageRuntimePath;
readonly composer: EditComposerRuntime;
getState(): MessageState;
reload(): void;
/**
* @deprecated This API is still under active development and might change without notice.
*/
speak(): void;
/**
* @deprecated This API is still under active development and might change without notice.
*/
stopSpeaking(): void;
submitFeedback({ type }: {
type: "positive" | "negative";
}): void;
switchToBranch({ position, branchId, }: {
position?: "previous" | "next" | undefined;
branchId?: string | undefined;
}): void;
unstable_getCopyText(): string;
subscribe(callback: () => void): Unsubscribe;
getContentPartByIndex(idx: number): ContentPartRuntime;
getContentPartByToolCallId(toolCallId: string): ContentPartRuntime;
getAttachmentByIndex(idx: number): AttachmentRuntime & {
source: "message";
};
};
export declare class MessageRuntimeImpl implements MessageRuntime {
private _core;
private _threadBinding;
get path(): MessageRuntimePath;
constructor(_core: MessageStateBinding, _threadBinding: ThreadRuntimeCoreBinding);
composer: EditComposerRuntimeImpl;
getState(): MessageState;
reload(): void;
speak(): void;
stopSpeaking(): void;
submitFeedback({ type }: {
type: "positive" | "negative";
}): void;
switchToBranch({ position, branchId, }: {
position?: "previous" | "next" | undefined;
branchId?: string | undefined;
}): void;
unstable_getCopyText(): string;
subscribe(callback: () => void): Unsubscribe;
getContentPartByIndex(idx: number): ContentPartRuntimeImpl;
getContentPartByToolCallId(toolCallId: string): ContentPartRuntimeImpl;
getAttachmentByIndex(idx: number): MessageAttachmentRuntimeImpl;
}
//# sourceMappingURL=MessageRuntime.d.ts.map