feat:添加描述字段
This commit is contained in:
@ -41,6 +41,7 @@ export interface MessageSegment {
|
||||
toolName?: string;
|
||||
toolStatus?: "running" | "success" | "error";
|
||||
toolResult?: string;
|
||||
toolDescription?: string;
|
||||
askId?: string;
|
||||
question?: string;
|
||||
options?: string[];
|
||||
@ -180,7 +181,8 @@ export class DialogSession {
|
||||
private updateToolSegment(
|
||||
toolName: string,
|
||||
status: "success" | "error",
|
||||
result?: string
|
||||
result?: string,
|
||||
description?: string
|
||||
): void {
|
||||
// 找到最后一个匹配的工具段落
|
||||
for (let i = this.segments.length - 1; i >= 0; i--) {
|
||||
@ -192,6 +194,9 @@ export class DialogSession {
|
||||
) {
|
||||
seg.toolStatus = status;
|
||||
seg.toolResult = result;
|
||||
if (description !== undefined) {
|
||||
seg.toolDescription = description;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -590,7 +595,7 @@ export class DialogSession {
|
||||
},
|
||||
|
||||
onToolComplete: (data) => {
|
||||
this.updateToolSegment(data.tool_name, "success", data.result);
|
||||
this.updateToolSegment(data.tool_name, "success", data.result, data.description);
|
||||
callbacks.onToolComplete?.(data.tool_name, data.result);
|
||||
// 实时发送段落更新
|
||||
callbacks.onSegmentUpdate?.(this.segments);
|
||||
|
||||
Reference in New Issue
Block a user