buster/web/src/context/Chats/ChatProvider/MOCK_CHAT.ts

170 lines
4.6 KiB
TypeScript
Raw Normal View History

2025-03-04 03:59:18 +08:00
import type {
BusterChat,
BusterChatMessage_text,
BusterChatMessage_file,
BusterChatMessageRequest,
2025-02-08 13:24:18 +08:00
BusterChatMessage_fileMetadata,
2025-03-05 00:32:47 +08:00
BusterChatMessageReasoning_Pills,
2025-03-04 01:40:32 +08:00
BusterChatMessageReasoning_Pill,
2025-03-05 00:32:47 +08:00
BusterChatMessageReasoning_files,
BusterChatMessageReasoning_text,
BusterChatMessageReasoning_file
2025-02-01 02:04:49 +08:00
} from '@/api/asset_interfaces';
2025-01-28 08:08:52 +08:00
import { faker } from '@faker-js/faker';
const createMockUserMessage = (
message: string = faker.lorem.sentence(12)
): BusterChatMessageRequest => ({
request: message,
sender_id: faker.string.uuid(),
sender_name: faker.person.fullName(),
sender_avatar: faker.image.avatar()
});
2025-03-04 03:59:18 +08:00
const createMockResponseMessageText = (): BusterChatMessage_text => ({
2025-01-28 08:08:52 +08:00
id: faker.string.uuid(),
type: 'text',
2025-01-29 01:04:54 +08:00
message: '',
2025-01-30 04:58:27 +08:00
message_chunk: faker.lorem.sentence({
min: 5,
max: 35
})
2025-01-28 08:08:52 +08:00
});
2025-03-05 00:32:47 +08:00
const createMockResponseMessagePills = (): BusterChatMessageReasoning_Pills => {
2025-02-09 05:37:46 +08:00
const randomPillCount = faker.number.int({ min: 0, max: 10 });
2025-03-04 01:40:32 +08:00
const fourRandomPills: BusterChatMessageReasoning_Pill[] = Array.from(
2025-01-29 03:47:14 +08:00
{ length: randomPillCount },
() => {
return {
text: faker.lorem.word(),
type: 'term',
id: faker.string.uuid()
};
}
);
return {
id: faker.string.uuid(),
2025-03-01 02:30:39 +08:00
type: 'pills',
title: `Found ${faker.number.int(100)} terms`,
secondary_title: faker.lorem.word(),
pill_containers: [
2025-02-11 02:55:18 +08:00
{
title: `Found ${faker.number.int(100)} terms`,
2025-03-04 01:40:32 +08:00
pills: fourRandomPills
2025-02-11 02:55:18 +08:00
},
{
title: `Found ${faker.number.int(100)} terms 2`,
2025-03-04 01:40:32 +08:00
pills: fourRandomPills
2025-02-11 02:55:18 +08:00
}
],
2025-01-29 06:21:07 +08:00
status: undefined
2025-01-29 03:47:14 +08:00
};
};
2025-01-28 08:08:52 +08:00
2025-03-04 03:59:18 +08:00
const createMockResponseMessageFile = (): BusterChatMessage_file => {
2025-01-29 06:38:43 +08:00
const randomMetadataCount = faker.number.int({
min: 1,
max: 3
});
2025-01-29 06:21:07 +08:00
const randomMetadata: BusterChatMessage_fileMetadata[] = Array.from(
{ length: randomMetadataCount },
() => {
return {
status: 'completed',
message: faker.lorem.sentence(),
2025-01-29 06:38:43 +08:00
timestamp: faker.number.int(100)
2025-01-29 06:21:07 +08:00
};
}
);
2025-01-29 03:47:14 +08:00
return {
id: faker.string.uuid(),
type: 'file',
file_type: 'metric',
version_number: 1,
2025-02-13 02:01:54 +08:00
filter_version_id: null,
2025-01-29 06:21:07 +08:00
version_id: faker.string.uuid(),
file_name: faker.company.name(),
metadata: randomMetadata
2025-01-29 03:47:14 +08:00
};
};
2025-01-28 08:08:52 +08:00
2025-03-05 00:32:47 +08:00
const createMockReasoningMessageFile = (): BusterChatMessageReasoning_files => {
const randomFileCount = faker.number.int({ min: 1, max: 3 });
const files: BusterChatMessageReasoning_file[] = Array.from({ length: randomFileCount }, () => {
const randomLineCount = faker.number.int({ min: 0, max: 5 });
const fileLines =
randomLineCount > 0
? Array.from({ length: randomLineCount }, (_, index) => ({
text: faker.lorem.sentence(),
line_number: index + 1,
modified: faker.datatype.boolean()
}))
: undefined;
return {
id: faker.string.uuid(),
file_type: faker.helpers.arrayElement(['metric', 'dashboard', 'reasoning']),
file_name: faker.system.fileName(),
version_number: faker.number.int({ min: 1, max: 10 }),
version_id: faker.string.uuid(),
status: faker.helpers.arrayElement(['loading', 'completed', 'failed']),
file: fileLines
};
});
2025-02-11 03:24:35 +08:00
return {
2025-03-05 00:32:47 +08:00
id: faker.string.uuid(),
type: 'files',
title: faker.lorem.words(3),
secondary_title: faker.datatype.boolean() ? faker.lorem.sentence() : undefined,
status: faker.helpers.arrayElement(['loading', 'completed', 'failed']),
files
2025-02-11 03:24:35 +08:00
};
};
2025-03-04 07:30:38 +08:00
const createMockReasoningMessageText = (): BusterChatMessageReasoning_text => {
return {
id: faker.string.uuid(),
type: 'text',
message: faker.lorem.sentence(),
title: faker.lorem.words(4),
secondary_title: faker.lorem.sentence(),
status: 'loading'
};
};
2025-01-28 08:08:52 +08:00
export const MOCK_CHAT: BusterChat = {
id: '0',
title: 'Mock Chat',
is_favorited: false,
messages: [
{
2025-02-08 13:24:18 +08:00
id: '123',
2025-01-28 08:08:52 +08:00
created_at: '2025-01-01',
request_message: createMockUserMessage(),
2025-03-01 02:30:39 +08:00
final_reasoning_message: null,
2025-02-11 03:24:35 +08:00
reasoning: [
2025-03-04 07:30:38 +08:00
createMockReasoningMessageText(),
createMockReasoningMessageText(),
...Array.from({ length: 1 }, () => createMockResponseMessagePills()),
2025-02-11 03:24:35 +08:00
createMockReasoningMessageFile()
],
2025-02-08 13:24:18 +08:00
response_messages: [
createMockResponseMessageText(),
2025-02-09 05:37:46 +08:00
createMockResponseMessageFile(),
2025-02-09 06:40:41 +08:00
createMockResponseMessageFile(),
2025-02-09 05:37:46 +08:00
createMockResponseMessageText(),
createMockResponseMessageText()
2025-01-28 08:08:52 +08:00
]
}
],
created_at: '2025-01-01',
updated_at: '2025-01-01',
created_by: 'Mock User',
created_by_id: '1',
created_by_name: 'Mock User',
created_by_avatar: ''
};