添加进度面板,优化消息处理逻辑
This commit is contained in:
@@ -4,6 +4,15 @@ import { config } from "@config/config";
|
||||
export type StreamEvent =
|
||||
| { type: "token"; sessionId: string; content: string }
|
||||
| { type: "done"; sessionId: string }
|
||||
| {
|
||||
type: "progress";
|
||||
sessionId: string;
|
||||
id: string;
|
||||
phase: string;
|
||||
status: "running" | "completed" | "error";
|
||||
title: string;
|
||||
detail?: string;
|
||||
}
|
||||
| {
|
||||
type: "error";
|
||||
sessionId?: string;
|
||||
@@ -121,6 +130,10 @@ export const streamAgentChat = async ({
|
||||
detail?: string;
|
||||
tool?: string;
|
||||
params?: Record<string, unknown>;
|
||||
id?: string;
|
||||
phase?: string;
|
||||
status?: "running" | "completed" | "error";
|
||||
title?: string;
|
||||
};
|
||||
if (event === "token") {
|
||||
onEvent({
|
||||
@@ -128,6 +141,16 @@ export const streamAgentChat = async ({
|
||||
sessionId: parsed.session_id ?? "",
|
||||
content: parsed.content ?? "",
|
||||
});
|
||||
} else if (event === "progress") {
|
||||
onEvent({
|
||||
type: "progress",
|
||||
sessionId: parsed.session_id ?? "",
|
||||
id: parsed.id ?? `${parsed.phase ?? "progress"}-${Date.now()}`,
|
||||
phase: parsed.phase ?? "progress",
|
||||
status: parsed.status ?? "running",
|
||||
title: parsed.title ?? "正在处理",
|
||||
detail: parsed.detail,
|
||||
});
|
||||
} else if (event === "done") {
|
||||
onEvent({
|
||||
type: "done",
|
||||
|
||||
Reference in New Issue
Block a user