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

115 lines
3.0 KiB
TypeScript
Raw Normal View History

2025-01-28 08:08:52 +08:00
import {
type BusterChat,
type BusterChatMessage_text,
type BusterChatMessage_file,
type BusterChatMessage_thought,
type BusterChatMessageRequest,
type BusterChatMessageResponse,
2025-01-29 03:47:14 +08:00
FileType,
2025-01-29 06:21:07 +08:00
BusterChatMessage_thoughtPill,
BusterChatMessage_fileMetadata
2025-01-28 08:08:52 +08:00
} from '@/api/buster_socket/chats';
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-01-30 04:58:27 +08:00
export 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-01-29 05:07:30 +08:00
export const createMockResponseMessageThought = (): BusterChatMessage_thought => {
2025-01-29 03:47:14 +08:00
const randomPillCount = faker.number.int(7);
const fourRandomPills: BusterChatMessage_thoughtPill[] = Array.from(
{ length: randomPillCount },
() => {
return {
text: faker.lorem.word(),
type: 'term',
id: faker.string.uuid()
};
}
);
return {
id: faker.string.uuid(),
type: 'thought',
thought_title: `Found ${faker.number.int(100)} terms`,
thought_secondary_title: faker.lorem.word(),
thought_pills: fourRandomPills,
2025-01-30 04:08:33 +08:00
hidden: undefined,
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-01-30 04:58:27 +08:00
export 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-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
export const MOCK_CHAT: BusterChat = {
id: '0',
title: 'Mock Chat',
is_favorited: false,
messages: [
{
id: faker.string.uuid(),
created_at: '2025-01-01',
request_message: createMockUserMessage(),
response_messages: [
createMockResponseMessageText(),
2025-01-29 05:20:39 +08:00
createMockResponseMessageThought(),
2025-01-30 06:10:41 +08:00
createMockResponseMessageThought(),
createMockResponseMessageThought(),
createMockResponseMessageThought(),
2025-01-29 06:21:07 +08:00
createMockResponseMessageFile()
2025-01-30 04:58:27 +08:00
// createMockResponseMessageFile(),
// createMockResponseMessageText(),
// createMockResponseMessageText(),
// createMockResponseMessageThought(),
// createMockResponseMessageThought(),
// createMockResponseMessageFile()
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: ''
};