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

155 lines
3.9 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-01 02:30:39 +08:00
BusterChatMessageReasoning_pills,
2025-03-04 01:40:32 +08:00
BusterChatMessageReasoning_Pill,
2025-02-11 03:24:35 +08:00
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-04 03:59:18 +08:00
const createMockResponseMessageThought = (): 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-04 03:59:18 +08:00
const createMockReasoningMessageFile = (): BusterChatMessageReasoning_file => {
2025-02-11 03:24:35 +08:00
return {
2025-02-11 06:21:59 +08:00
id: 'swag' + faker.string.uuid(),
2025-02-11 03:24:35 +08:00
type: 'file',
file_type: 'metric',
status: 'completed',
file_name: faker.company.name(),
version_number: 1,
version_id: faker.string.uuid(),
file: [
{
text: 'name: my-service\nversion: 1.0.0\ndescription: A sample service',
line_number: 1,
modified: false
},
{
text: 'dependencies:\n - name: redis\n version: 6.2.0\n - name: postgres\n version: 13.4',
line_number: 2
},
{
text: 'ports:\n - 8080\n - 9000\n - 6379',
line_number: 3
},
{
text: 'environment:\n NODE_ENV: production\n LOG_LEVEL: info\n DB_HOST: localhost',
line_number: 4
}
]
};
};
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: [
...Array.from({ length: 1 }, () => createMockResponseMessageThought()),
createMockReasoningMessageFile()
2025-02-11 06:21:59 +08:00
// createMockReasoningMessageFile(),
// createMockResponseMessageThought(),
// createMockResponseMessageThought()
2025-02-11 03:24:35 +08:00
],
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: ''
};