mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-18 05:25:59 +08:00
feat: enhance mocking data
This commit is contained in:
parent
0fa890746a
commit
9758180e96
@ -36,18 +36,24 @@ export function chatStream(
|
||||
|
||||
async function* chatStreamMock(
|
||||
userMessage: string,
|
||||
_: {
|
||||
params: {
|
||||
thread_id: string;
|
||||
max_plan_iterations: number;
|
||||
max_step_num: number;
|
||||
interrupt_feedback?: string;
|
||||
} = {
|
||||
thread_id: "__mock__",
|
||||
max_plan_iterations: 3,
|
||||
max_step_num: 1,
|
||||
interrupt_feedback: undefined,
|
||||
},
|
||||
options: { abortSignal?: AbortSignal } = {},
|
||||
): AsyncIterable<ChatEvent> {
|
||||
const res = await fetch("/mock.txt", {
|
||||
const mockFile =
|
||||
params.interrupt_feedback === "accepted"
|
||||
? "/mock-before-interrupt.txt"
|
||||
: "/mock-after-interrupt.txt";
|
||||
const res = await fetch(mockFile, {
|
||||
signal: options.abortSignal,
|
||||
});
|
||||
await sleep(800);
|
||||
@ -58,7 +64,7 @@ async function* chatStreamMock(
|
||||
const [, event] = eventRaw.split("event: ", 2) as [string, string];
|
||||
const [, data] = dataRaw.split("data: ", 2) as [string, string];
|
||||
if (event === "message_chunk") {
|
||||
await sleep(0);
|
||||
await sleep(100);
|
||||
} else if (event === "tool_call_result") {
|
||||
await sleep(1500);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user