fix: unify chat process and reply presentation
This commit is contained in:
@@ -29,6 +29,7 @@ export function upsertProgress(progress: AgentChatProgress[] | undefined, data:
|
||||
status,
|
||||
title: readString(payload.title) ?? "正在处理",
|
||||
detail: readString(payload.detail),
|
||||
tool: readProgressTool(payload.tool) ?? existing?.tool,
|
||||
startedAt,
|
||||
endedAt,
|
||||
elapsedMs: status === "running" ? elapsedMs : undefined,
|
||||
@@ -373,3 +374,15 @@ function readNumber(value: unknown) {
|
||||
function readStringArray(value: unknown) {
|
||||
return Array.isArray(value) ? value.map((item) => String(item).trim()).filter(Boolean) : [];
|
||||
}
|
||||
|
||||
export function readProgressTool(value: unknown): AgentChatProgress["tool"] {
|
||||
const tool = asRecord(value);
|
||||
const name = readString(tool.name);
|
||||
if (!name) return undefined;
|
||||
return {
|
||||
name,
|
||||
callId: readString(tool.call_id) ?? readString(tool.callId),
|
||||
input: tool.input && typeof tool.input === "object" && !Array.isArray(tool.input)
|
||||
? tool.input as Record<string, unknown> : undefined
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user