From 2b315f19abc7bd5d1d865dc4be52c18b10b6f6ce Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Sat, 27 Dec 2025 17:29:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(tool-calling):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=B7=A5=E5=85=B7=E6=94=AF=E6=8C=81=E5=B9=B6?= =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=B7=A5=E5=85=B7=E6=98=BE=E7=A4=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 TaskTool 组件用于显示任务分配工具结果 - 为 BaseToolCall 添加通用 header slot 支持自定义标题 - 改进 TodoListTool 和 WebSearchTool 的显示样式 - 调整浮动侧边栏的 z-index 防止遮挡 - 优化 AgentChatComponent 的 header-right slot 支持响应式隐藏文本 --- web/src/components/AgentChatComponent.vue | 4 +- .../ToolCallingResult/BaseToolCall.vue | 71 ++++++++---- .../ToolCallingResult/ToolCallRenderer.vue | 21 +++- .../ToolCallingResult/tools/TaskTool.vue | 107 ++++++++++++++++++ .../ToolCallingResult/tools/TodoListTool.vue | 10 +- .../ToolCallingResult/tools/WebSearchTool.vue | 32 ++++-- web/src/views/AgentView.vue | 8 +- 7 files changed, 207 insertions(+), 46 deletions(-) create mode 100644 web/src/components/ToolCallingResult/tools/TaskTool.vue diff --git a/web/src/components/AgentChatComponent.vue b/web/src/components/AgentChatComponent.vue index 4235d46a..9c07c1f6 100644 --- a/web/src/components/AgentChatComponent.vue +++ b/web/src/components/AgentChatComponent.vue @@ -68,7 +68,7 @@ 状态 - + @@ -1043,7 +1043,7 @@ watch(conversations, () => { .floating-sidebar { position: absolute !important; - z-index: 101; + z-index: 1001; height: 100%; left: 0; top: 0; diff --git a/web/src/components/ToolCallingResult/BaseToolCall.vue b/web/src/components/ToolCallingResult/BaseToolCall.vue index cdef9827..0a911f08 100644 --- a/web/src/components/ToolCallingResult/BaseToolCall.vue +++ b/web/src/components/ToolCallingResult/BaseToolCall.vue @@ -21,32 +21,40 @@
- - 工具  {{ toolName }}   执行完成 - + + - - 工具  {{ toolName }}   执行失败 - ({{ toolCall.error_message }}) - + +
@@ -264,6 +272,21 @@ const formatResultData = (data) => { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; + + :deep(.keywords) { + color: var(--main-700); + font-weight: 600; + font-size: 14px; + } + + :deep(.tag) { + font-size: 12px; + color: var(--gray-600); + background-color: var(--gray-100); + padding: 0px 4px; + border-radius: 4px; + margin-left: 8px; + } } } diff --git a/web/src/components/ToolCallingResult/ToolCallRenderer.vue b/web/src/components/ToolCallingResult/ToolCallRenderer.vue index d0cb1fd1..f1a99c7d 100644 --- a/web/src/components/ToolCallingResult/ToolCallRenderer.vue +++ b/web/src/components/ToolCallingResult/ToolCallRenderer.vue @@ -21,6 +21,9 @@ + + + @@ -36,6 +39,7 @@ import KnowledgeGraphTool from './tools/KnowledgeGraphTool.vue'; import CalculatorTool from './tools/CalculatorTool.vue'; import TodoListTool from './tools/TodoListTool.vue'; import ImageTool from './tools/ImageTool.vue'; +import TaskTool from './tools/TaskTool.vue'; const props = defineProps({ toolCall: { @@ -63,10 +67,19 @@ const parseData = (content) => { // 识别逻辑 const isWebSearchResult = computed(() => { const name = toolName.value.toLowerCase(); - const isWebSearchTool = name.includes('search') || name.includes('tavily') || name.includes('web'); - if (!isWebSearchTool) return false; - const data = parseData(props.toolCall.tool_call_result?.content); - return data && typeof data === 'object' && 'results' in data && Array.isArray(data.results); + return name.includes('search') || name.includes('tavily') || name.includes('web'); +}); + +const isTaskResult = computed(() => { + let args = props.toolCall.args || props.toolCall.function?.arguments; + if (typeof args === 'string') { + try { + args = JSON.parse(args); + } catch { + return false; + } + } + return args && typeof args === 'object' && 'subagent_type' in args; }); const isKnowledgeBaseResult = computed(() => { diff --git a/web/src/components/ToolCallingResult/tools/TaskTool.vue b/web/src/components/ToolCallingResult/tools/TaskTool.vue new file mode 100644 index 00000000..88cc409d --- /dev/null +++ b/web/src/components/ToolCallingResult/tools/TaskTool.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/web/src/components/ToolCallingResult/tools/TodoListTool.vue b/web/src/components/ToolCallingResult/tools/TodoListTool.vue index ceb7942e..b7ab412e 100644 --- a/web/src/components/ToolCallingResult/tools/TodoListTool.vue +++ b/web/src/components/ToolCallingResult/tools/TodoListTool.vue @@ -1,9 +1,7 @@