From 0e2abccf116f3dd159fb2b874cfc1d0c3f28fb82 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Sun, 22 Jun 2025 23:56:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=8A=A9=E6=89=8B?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=BB=84=E4=BB=B6=E5=92=8C=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=99=A8=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 AgentMessageComponent.vue 中更新消息解析逻辑,使用 parsedMessage 处理内容和推理信息。 - 改进样式,增强用户体验,包括工具调用结果的展示和交互效果。 - 移除 CalculatorResult.vue 中不必要的元素,简化结果展示。 --- web/src/components/AgentMessageComponent.vue | 118 +++++++++++++++--- .../ToolCallingResult/CalculatorResult.vue | 20 --- 2 files changed, 103 insertions(+), 35 deletions(-) diff --git a/web/src/components/AgentMessageComponent.vue b/web/src/components/AgentMessageComponent.vue index 1d580f86..1cc634cf 100644 --- a/web/src/components/AgentMessageComponent.vue +++ b/web/src/components/AgentMessageComponent.vue @@ -5,28 +5,28 @@
-
+
-

{{ message.reasoning_content.trim() }}

+

{{ parsedMessage.reasoning_content.trim() }}

- -
+
@@ -38,13 +38,13 @@ {{ toolCall.name || toolCall.function.name }} - 工具 {{ toolCall.name || toolCall.function.name }} 执行完成 +   工具 {{ toolCall.name || toolCall.function.name }} 执行完成
-
 参数: {{ toolCall.args || toolCall.function.arguments }}
+ 参数: {{ toolCall.args || toolCall.function.arguments }}
@@ -137,6 +137,26 @@ const isEmptyAndLoading = computed(() => { return isEmpty && isLoading; }); +const parsedMessage = computed(() => { + const message = props.message; + if (message.content) { + // 匹配完整的 ... 标签 + const thinkContent = message.content.match(/(.*?)<\/think>/s); + if (thinkContent) { + message.reasoning_content = thinkContent[1]; + message.content = message.content.replace(/(.*?)<\/think>/s, ''); + } else { + // 匹配未闭合的 标签,处理加载中的情况 + const incompleteThinkContent = message.content.match(/(.*?)$/s); + if (incompleteThinkContent) { + message.reasoning_content = incompleteThinkContent[1]; + message.content = message.content.replace(/(.*?)$/s, ''); + } + } + } + return message; +}); + const toggleToolCall = (toolCallId) => { if (expandedToolCalls.value.has(toolCallId)) { expandedToolCalls.value.delete(toolCallId); @@ -207,14 +227,61 @@ const toggleToolCall = (toolCallId) => { .reasoning-box { margin-top: 10px; margin-bottom: 15px; - border-radius: 8px; - border: 1px solid var(--main-light-3); + border-radius: 12px; + border: 1px solid var(--gray-200); + background-color: var(--gray-50); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02); + overflow: hidden; + transition: all 0.2s ease; + + &:hover { + border-color: var(--main-300); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08); + } + + :deep(.ant-collapse) { + background-color: transparent; + border: none; + + .ant-collapse-item { + border: none; + + .ant-collapse-header { + padding: 12px 16px; + background-color: var(--gray-100); + font-size: 14px; + font-weight: 500; + color: var(--gray-800); + border-bottom: 1px solid var(--gray-200); + transition: all 0.2s ease; + + &:hover { + background-color: var(--gray-150); + } + + .ant-collapse-expand-icon { + color: var(--main-600); + } + } + + .ant-collapse-content { + border: none; + background-color: transparent; + + .ant-collapse-content-box { + padding: 16px; + background-color: var(--gray-50); + } + } + } + } .reasoning-content { font-size: 13px; color: var(--gray-800); white-space: pre-wrap; margin: 0; + line-height: 1.6; } } @@ -251,11 +318,18 @@ const toggleToolCall = (toolCallId) => { :deep(.tool-call-display) { background-color: var(--gray-50); border: 1px solid var(--gray-200); - border-radius: 8px; + border-radius: 12px; overflow: hidden; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02); + transition: all 0.2s ease; + + &:hover { + border-color: var(--main-300); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08); + } .tool-header { - padding: 10px 12px; + padding: 12px 16px; background-color: var(--gray-100); font-size: 14px; font-weight: 500; @@ -267,9 +341,20 @@ const toggleToolCall = (toolCallId) => { cursor: pointer; user-select: none; position: relative; + transition: all 0.2s ease; + + &:hover { + background-color: var(--gray-150); + } .anticon { color: var(--main-600); + font-size: 16px; + } + + .tool-name { + font-weight: 600; + color: var(--main-700); } .step-badge { @@ -285,27 +370,30 @@ const toggleToolCall = (toolCallId) => { .tool-content { transition: all 0.3s ease; + .tool-params { - padding: 10px 12px; + padding: 16px; background-color: var(--gray-50); .tool-params-header { background-color: var(--gray-100); font-size: 13px; color: var(--gray-800); + margin-bottom: 8px; + font-weight: 500; } .tool-params-content { margin: 0; font-size: 13px; background-color: var(--gray-100); - border-radius: 4px; - padding: 8px; overflow-x: auto; color: var(--gray-800); + line-height: 1.5; pre { margin: 0; + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; } } } @@ -315,7 +403,7 @@ const toggleToolCall = (toolCallId) => { background-color: transparent; .tool-result-header { - padding: 10px 12px; + padding: 12px 16px; background-color: var(--gray-100); font-size: 12px; color: var(--gray-700); diff --git a/web/src/components/ToolCallingResult/CalculatorResult.vue b/web/src/components/ToolCallingResult/CalculatorResult.vue index 81a346ce..a87e3fda 100644 --- a/web/src/components/ToolCallingResult/CalculatorResult.vue +++ b/web/src/components/ToolCallingResult/CalculatorResult.vue @@ -6,28 +6,8 @@
-
结果:
{{ formatNumber(data) }}
- -
- - 复制结果 - -
-
- - -
- 科学记数法: - {{ data.toExponential(6) }} -
- - -
- {{ getNumberType() }} - 整数 - {{ getDecimalPlaces() }} 位小数