Merge branch 'feat/backend' into feat/front-end
This commit is contained in:
@ -41,6 +41,7 @@ export interface MessageSegment {
|
|||||||
toolName?: string;
|
toolName?: string;
|
||||||
toolStatus?: "running" | "success" | "error";
|
toolStatus?: "running" | "success" | "error";
|
||||||
toolResult?: string;
|
toolResult?: string;
|
||||||
|
toolDescription?: string;
|
||||||
askId?: string;
|
askId?: string;
|
||||||
question?: string;
|
question?: string;
|
||||||
options?: string[];
|
options?: string[];
|
||||||
@ -180,7 +181,8 @@ export class DialogSession {
|
|||||||
private updateToolSegment(
|
private updateToolSegment(
|
||||||
toolName: string,
|
toolName: string,
|
||||||
status: "success" | "error",
|
status: "success" | "error",
|
||||||
result?: string
|
result?: string,
|
||||||
|
description?: string
|
||||||
): void {
|
): void {
|
||||||
// 找到最后一个匹配的工具段落
|
// 找到最后一个匹配的工具段落
|
||||||
for (let i = this.segments.length - 1; i >= 0; i--) {
|
for (let i = this.segments.length - 1; i >= 0; i--) {
|
||||||
@ -192,6 +194,9 @@ export class DialogSession {
|
|||||||
) {
|
) {
|
||||||
seg.toolStatus = status;
|
seg.toolStatus = status;
|
||||||
seg.toolResult = result;
|
seg.toolResult = result;
|
||||||
|
if (description !== undefined) {
|
||||||
|
seg.toolDescription = description;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,7 +595,7 @@ export class DialogSession {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onToolComplete: (data) => {
|
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.onToolComplete?.(data.tool_name, data.result);
|
||||||
// 实时发送段落更新
|
// 实时发送段落更新
|
||||||
callbacks.onSegmentUpdate?.(this.segments);
|
callbacks.onSegmentUpdate?.(this.segments);
|
||||||
|
|||||||
@ -96,6 +96,7 @@ export interface ToolStartEvent {
|
|||||||
export interface ToolCompleteEvent {
|
export interface ToolCompleteEvent {
|
||||||
tool_name: string;
|
tool_name: string;
|
||||||
result: string;
|
result: string;
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** tool_error 事件数据 */
|
/** tool_error 事件数据 */
|
||||||
|
|||||||
@ -543,6 +543,12 @@ export function getMessageAreaStyles(): string {
|
|||||||
.tool-segment-content.collapsed {
|
.tool-segment-content.collapsed {
|
||||||
max-height: 0;
|
max-height: 0;
|
||||||
}
|
}
|
||||||
|
.tool-segment-description {
|
||||||
|
margin: 2px 0 0 0px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #fff;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
/* 低调显示的工具调用样式 */
|
/* 低调显示的工具调用样式 */
|
||||||
.segment-tool.low-profile .tool-segment-header {
|
.segment-tool.low-profile .tool-segment-header {
|
||||||
opacity: 0.65;
|
opacity: 0.65;
|
||||||
@ -1067,6 +1073,7 @@ export function getMessageAreaScript(): string {
|
|||||||
const toolResult = segment.toolResult || '';
|
const toolResult = segment.toolResult || '';
|
||||||
const toolCount = segment.toolCount || 1;
|
const toolCount = segment.toolCount || 1;
|
||||||
const countSuffix = toolCount > 1 ? \` x\${toolCount}\` : '';
|
const countSuffix = toolCount > 1 ? \` x\${toolCount}\` : '';
|
||||||
|
const toolDescription = segment.toolDescription || '';
|
||||||
|
|
||||||
// 检查工具结果是否过长(超过一行显示不下)
|
// 检查工具结果是否过长(超过一行显示不下)
|
||||||
const shouldCollapse = toolResult && toolResult.length > 60;
|
const shouldCollapse = toolResult && toolResult.length > 60;
|
||||||
@ -1084,6 +1091,7 @@ export function getMessageAreaScript(): string {
|
|||||||
\${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''}
|
\${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''}
|
||||||
</div>
|
</div>
|
||||||
\${shouldCollapse ? \`<div class="tool-segment-content\${isCollapsed ? ' collapsed' : ''}" style="max-height:\${isCollapsed ? '0' : 'none'}"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''}
|
\${shouldCollapse ? \`<div class="tool-segment-content\${isCollapsed ? ' collapsed' : ''}" style="max-height:\${isCollapsed ? '0' : 'none'}"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''}
|
||||||
|
\${toolDescription ? \`<p class="tool-segment-description">\${toolDescription}</p>\` : ''}
|
||||||
\`;
|
\`;
|
||||||
|
|
||||||
// 如果是仿真工具且成功完成,尝试添加波形预览
|
// 如果是仿真工具且成功完成,尝试添加波形预览
|
||||||
@ -1331,6 +1339,7 @@ export function getMessageAreaScript(): string {
|
|||||||
const toolResult = segment.toolResult || '';
|
const toolResult = segment.toolResult || '';
|
||||||
const toolCount = segment.toolCount || 1;
|
const toolCount = segment.toolCount || 1;
|
||||||
const countSuffix = toolCount > 1 ? \` x\${toolCount}\` : '';
|
const countSuffix = toolCount > 1 ? \` x\${toolCount}\` : '';
|
||||||
|
const toolDescription = segment.toolDescription || '';
|
||||||
|
|
||||||
// 检查工具结果是否过长(超过一行显示不下)
|
// 检查工具结果是否过长(超过一行显示不下)
|
||||||
const shouldCollapse = toolResult && toolResult.length > 60;
|
const shouldCollapse = toolResult && toolResult.length > 60;
|
||||||
@ -1342,6 +1351,7 @@ export function getMessageAreaScript(): string {
|
|||||||
\${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''}
|
\${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''}
|
||||||
</div>
|
</div>
|
||||||
\${shouldCollapse ? \`<div class="tool-segment-content collapsed"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''}
|
\${shouldCollapse ? \`<div class="tool-segment-content collapsed"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''}
|
||||||
|
\${toolDescription ? \`<p class="tool-segment-description">\${toolDescription}</p>\` : ''}
|
||||||
\`;
|
\`;
|
||||||
|
|
||||||
// 如果是仿真工具且成功完成,尝试添加波形预览
|
// 如果是仿真工具且成功完成,尝试添加波形预览
|
||||||
|
|||||||
Reference in New Issue
Block a user