Scaffold web frontend: mock-backed chat + PDF split-view, Tailwind/shadcn
This commit is contained in:
@@ -1 +1 @@
|
||||
export {};
|
||||
export * from "./sendChatMessage";
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { SendMessageResponse } from "@duoc-thu/shared-types";
|
||||
|
||||
let nextId = 1;
|
||||
|
||||
export function buildMockResponse(userContent: string): SendMessageResponse {
|
||||
const id = String(nextId++);
|
||||
return {
|
||||
message: {
|
||||
id,
|
||||
role: "assistant",
|
||||
content:
|
||||
`(Mock) Paracetamol được chỉ định để giảm đau, hạ sốt. Liều thường dùng ở người ` +
|
||||
`lớn là 500-1000mg mỗi 4-6 giờ, tối đa 4g/ngày. Đây là dữ liệu giả lập cho câu hỏi: "${userContent}".`,
|
||||
citations: [
|
||||
{
|
||||
drugName: "PARACETAMOL",
|
||||
sectionType: "lieu_dung",
|
||||
sourcePageRange: [412, 413],
|
||||
},
|
||||
],
|
||||
disclaimer:
|
||||
"Câu trả lời chỉ mang tính tham khảo, không thay thế chỉ định của bác sĩ hoặc dược sĩ.",
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { SendMessageResponse } from "@duoc-thu/shared-types";
|
||||
import { buildMockResponse } from "./mockFixtures";
|
||||
|
||||
const MOCK_LATENCY_MS = 400;
|
||||
|
||||
export async function sendChatMessage(content: string): Promise<SendMessageResponse> {
|
||||
await new Promise((resolve) => setTimeout(resolve, MOCK_LATENCY_MS));
|
||||
return buildMockResponse(content);
|
||||
}
|
||||
Reference in New Issue
Block a user