@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
71 lines (70 loc) • 2.41 kB
TypeScript
import { ObservableReactValue } from '../utils/observers/ObservableReactValue';
import { IdType } from '../types';
import { MessageReasoningModel } from './MessageReasoningModel';
import { MessageText } from './MessageText';
import MessageAttachmentsModel from './MessageAttachmentsModel';
import { Attachment } from './AttachmentModel';
export declare enum ChatMessageOwner {
USER = "user",
ASSISTANT = "assistant"
}
export type RatingType = 'like' | 'dislike';
export type MessageFeedbackTagType = {
id: IdType;
label: string;
value: string | number;
};
export type TextContent = {
type: 'text';
text: string;
};
export type InternalMessageType = any;
export type MessageUserContent = string | (Attachment | TextContent)[];
export type MessageAssistantContent = string | (TextContent)[];
export type Message = {
id: IdType;
parentId?: IdType;
time?: number;
rating?: RatingType;
reasoning?: {
title?: string;
text?: string;
timeSec?: number;
};
} & ({
role: ChatMessageOwner.USER;
content: MessageUserContent;
} | {
role: ChatMessageOwner.ASSISTANT;
content: MessageAssistantContent;
});
export declare class MessageModel<DM extends Message = Message> {
private _data;
readonly viewerUniqueKey: string;
/**
* Text of message that supports "observation", should you need to update the component immediately upon variable modification, perfect for React.useSyncExternalStore.
*/
readonly texts: ObservableReactValue<MessageText[]>;
readonly reasoningManager: MessageReasoningModel;
readonly attachments: MessageAttachmentsModel;
/**
* An observable flag indicating the start/finish of message typing.
*/
typing: ObservableReactValue<boolean>;
photoswipeContainerId: string;
constructor(_data: DM);
get id(): IdType;
get data(): DM;
get parentId(): IdType | undefined;
set parentId(val: IdType | undefined);
get rating(): RatingType | undefined;
set rating(value: RatingType | undefined);
get time(): number | undefined;
get role(): ChatMessageOwner;
get isUser(): boolean;
get isAssistant(): boolean;
get content(): string | (Attachment | TextContent)[];
get text(): string;
set text(value: string);
setId: (id: string) => void;
}