@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
67 lines (66 loc) • 2.57 kB
TypeScript
import { MessageModel, ChatMessageOwner, Message } from './MessageModel';
import { ThreadMessages } from './ThreadMessages';
import { ObservableReactValue } from '../utils/observers/ObservableReactValue';
import { MessageSentParams } from './MessageSentParams';
import { IdType } from '../types';
export type NewMessageResponse = {
user: Message;
assistant: Message;
};
export declare enum StreamResponseState {
START = "start",
TYPING_MESSAGE = "typingMessage",
THINKING = "thinking",
FINISH_MESSAGE = "finishMessage"
}
export type Thread<DM extends Message = any> = {
id: IdType;
title: string;
date?: string;
messages?: DM[];
} & {
isNew?: boolean;
};
export declare class ThreadModel<DM extends Message = any, DD extends Thread<DM> = any> {
readonly streamMessage: (params: MessageSentParams) => void | Promise<void>;
readonly viewerUniqueKey: string;
readonly messages: ThreadMessages<DM>;
readonly observableTitle: ObservableReactValue<string>;
readonly isTyping: ObservableReactValue<boolean>;
readonly isLoadingAttachments: ObservableReactValue<IdType[]>;
readonly isEmpty: ObservableReactValue<boolean>;
readonly streamStatus: ObservableReactValue<string | undefined>;
readonly tool: ObservableReactValue<string | undefined>;
readonly helloMessage: MessageModel<{
id: string;
content: string;
role: ChatMessageOwner.ASSISTANT;
time: number;
}>;
/**
* We can pass threads with empty history to improve performance
* When opening such a thread, we need to call the getFullThread method to load the history
*/
readonly isLoadingFullData: ObservableReactValue<boolean>;
scrollY: number;
readonly timestamp: ObservableReactValue<number>;
private _data;
constructor(data: DD, streamMessage: (params: MessageSentParams) => void | Promise<void>);
get id(): IdType;
set id(value: IdType);
get time(): number;
get title(): string;
set title(value: string);
get date(): string | undefined;
get isNew(): boolean | undefined;
get messagesArray(): MessageModel<DM>[];
get data(): Thread<DM>;
setFullData: (threadData: Thread & {
messages: DM[];
}) => void;
static createEmptyData: <DD_1>() => DD_1;
protected _createPair: (content: Message['content'], parentMessage: MessageModel<DM> | undefined) => {
userMessage: MessageModel<DM>;
assistantMessage: MessageModel<DM>;
};
}