buster/web/src/api/asset_interfaces/chat/chatMessageInterfaces.ts

110 lines
2.9 KiB
TypeScript
Raw Normal View History

2025-03-19 23:59:14 +08:00
import { BusterShare } from '../share';
2025-02-08 13:24:18 +08:00
import type { FileType, ThoughtFileType } from './config';
2025-01-28 04:21:42 +08:00
export type BusterChatMessage = {
id: string;
2025-03-30 11:13:40 +08:00
request_message: BusterChatMessageRequest | null;
2025-03-05 08:49:53 +08:00
response_message_ids: string[];
response_messages: Record<string, BusterChatMessageResponse>;
reasoning_message_ids: string[];
reasoning_messages: Record<string, BusterChatMessageReasoning>;
2025-01-28 04:21:42 +08:00
created_at: string;
2025-03-01 02:30:39 +08:00
final_reasoning_message: string | null;
2025-04-17 05:45:22 +08:00
feedback: 'negative' | null;
2025-03-19 23:59:14 +08:00
} & BusterShare;
2025-01-28 04:21:42 +08:00
export type BusterChatMessageRequest = null | {
2025-01-28 04:21:42 +08:00
request: string;
sender_id: string;
sender_name: string;
sender_avatar: string | null;
};
2025-03-05 08:49:53 +08:00
export type BusterChatMessageResponse =
| BusterChatResponseMessage_text
| BusterChatResponseMessage_file;
2025-01-28 04:21:42 +08:00
2025-03-05 08:49:53 +08:00
export type BusterChatResponseMessage_text = {
2025-01-28 04:21:42 +08:00
id: string;
type: 'text';
message: string;
message_chunk?: string;
2025-03-19 23:43:53 +08:00
is_final_message: boolean;
2025-01-28 04:21:42 +08:00
};
2025-03-05 00:32:47 +08:00
export type BusterChatMessageReasoning_status = 'loading' | 'completed' | 'failed';
2025-03-05 08:49:53 +08:00
export type BusterChatResponseMessage_fileMetadata = {
2025-03-05 00:32:47 +08:00
status: BusterChatMessageReasoning_status;
2025-01-28 04:21:42 +08:00
message: string;
2025-01-29 06:38:43 +08:00
timestamp?: number;
2025-01-28 04:21:42 +08:00
};
2025-03-05 08:49:53 +08:00
export type BusterChatResponseMessage_file = {
2025-01-28 04:21:42 +08:00
id: string;
type: 'file';
file_type: FileType;
2025-01-29 06:21:07 +08:00
file_name: string;
2025-01-28 04:21:42 +08:00
version_number: number;
2025-02-13 02:01:54 +08:00
filter_version_id: string | null;
2025-03-05 08:49:53 +08:00
metadata?: BusterChatResponseMessage_fileMetadata[];
2025-01-28 04:21:42 +08:00
};
2025-02-08 13:24:18 +08:00
export type BusterChatMessageReasoning =
2025-03-05 08:49:53 +08:00
| BusterChatMessageReasoning_pills
2025-02-11 01:42:02 +08:00
| BusterChatMessageReasoning_text
2025-03-05 00:32:47 +08:00
| BusterChatMessageReasoning_files;
2025-02-08 13:24:18 +08:00
2025-03-05 08:49:53 +08:00
export type BusterChatMessageReasoning_pill = {
2025-02-08 13:24:18 +08:00
text: string;
2025-03-01 02:30:39 +08:00
type: ThoughtFileType | null; //if null then the pill will not link anywhere
2025-02-08 13:24:18 +08:00
id: string;
};
2025-03-05 08:49:53 +08:00
export type BusterChatMessageReasoning_pillContainer = {
2025-02-11 00:59:54 +08:00
title: string;
2025-03-05 08:49:53 +08:00
pills: BusterChatMessageReasoning_pill[];
2025-02-11 00:59:54 +08:00
};
2025-03-05 08:49:53 +08:00
export type BusterChatMessageReasoning_pills = {
2025-02-08 13:24:18 +08:00
id: string;
2025-03-01 02:30:39 +08:00
type: 'pills';
title: string;
2025-03-05 08:49:53 +08:00
secondary_title: string | undefined;
pill_containers: BusterChatMessageReasoning_pillContainer[];
status: BusterChatMessageReasoning_status; //if left undefined, will automatically be set to 'loading' if the chat stream is in progress AND there is no message after it
2025-02-08 13:24:18 +08:00
};
export type BusterChatMessageReasoning_text = {
id: string;
type: 'text';
2025-03-01 02:30:39 +08:00
title: string;
2025-03-05 08:49:53 +08:00
secondary_title: string | undefined;
2025-03-01 02:30:39 +08:00
message?: string;
2025-02-08 13:24:18 +08:00
message_chunk?: string;
2025-03-05 00:32:47 +08:00
status: BusterChatMessageReasoning_status;
2025-02-08 13:24:18 +08:00
};
2025-02-11 01:42:02 +08:00
export type BusterChatMessageReasoning_file = {
id: string;
2025-02-11 02:41:59 +08:00
file_type: FileType;
2025-02-11 01:42:02 +08:00
file_name: string;
version_number: number;
2025-03-05 08:49:53 +08:00
status: BusterChatMessageReasoning_status;
file: {
text: string | undefined;
text_chunk?: string | undefined;
modified?: [number, number][];
};
2025-02-11 01:42:02 +08:00
};
2025-03-05 00:32:47 +08:00
export type BusterChatMessageReasoning_files = {
id: string;
type: 'files';
title: string;
status: BusterChatMessageReasoning_status;
2025-03-05 08:49:53 +08:00
secondary_title: string | undefined;
file_ids: string[];
files: Record<string, BusterChatMessageReasoning_file>;
2025-03-05 00:32:47 +08:00
};