From 1db93e8b569f066b243b1fe8671399ab27bf9c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=A2=E5=A5=8B=E7=8C=AB?= Date: Thu, 26 Jun 2025 13:19:36 +0800 Subject: [PATCH] Fix anthropic request cannot handle webSearch and knowbase references (#7559) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 Anthropic 模型请求忽略了知识库和网络搜索引用内容的问题 --- .../src/aiCore/clients/anthropic/AnthropicAPIClient.ts | 4 ++-- src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx | 2 +- .../__tests__/__snapshots__/ThinkingBlock.test.tsx.snap | 2 +- src/renderer/src/pages/home/Messages/CitationsList.tsx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts b/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts index 465cdff5ac..e07b7508db 100644 --- a/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts +++ b/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts @@ -66,7 +66,7 @@ import { mcpToolCallResponseToAnthropicMessage, mcpToolsToAnthropicTools } from '@renderer/utils/mcp-tools' -import { findFileBlocks, findImageBlocks, getMainTextContent } from '@renderer/utils/messageUtils/find' +import { findFileBlocks, findImageBlocks } from '@renderer/utils/messageUtils/find' import { buildSystemPrompt } from '@renderer/utils/prompt' import { BaseApiClient } from '../BaseApiClient' @@ -192,7 +192,7 @@ export class AnthropicAPIClient extends BaseApiClient< const parts: MessageParam['content'] = [ { type: 'text', - text: getMainTextContent(message) + text: await this.getMessageContent(message) } ] diff --git a/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx b/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx index e1420ba6cb..fa422ea524 100644 --- a/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx +++ b/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx @@ -150,7 +150,7 @@ const ThinkingTimeSeconds = memo( ) const CollapseContainer = styled(Collapse)` - margin-bottom: 15px; + margin: 15px 0; ` const MessageTitleLabel = styled.div` diff --git a/src/renderer/src/pages/home/Messages/Blocks/__tests__/__snapshots__/ThinkingBlock.test.tsx.snap b/src/renderer/src/pages/home/Messages/Blocks/__tests__/__snapshots__/ThinkingBlock.test.tsx.snap index 7f1f866b8b..805e7d2a90 100644 --- a/src/renderer/src/pages/home/Messages/Blocks/__tests__/__snapshots__/ThinkingBlock.test.tsx.snap +++ b/src/renderer/src/pages/home/Messages/Blocks/__tests__/__snapshots__/ThinkingBlock.test.tsx.snap @@ -2,7 +2,7 @@ exports[`ThinkingBlock > basic rendering > should match snapshot 1`] = ` .c0 { - margin-bottom: 15px; + margin: 15px 0; } .c1 { diff --git a/src/renderer/src/pages/home/Messages/CitationsList.tsx b/src/renderer/src/pages/home/Messages/CitationsList.tsx index 8929ffd89c..f147619adc 100644 --- a/src/renderer/src/pages/home/Messages/CitationsList.tsx +++ b/src/renderer/src/pages/home/Messages/CitationsList.tsx @@ -326,7 +326,7 @@ const PopoverContent = styled.div` ` const KnowledgePopoverContent = styled(PopoverContent)` - max-width: 800px; + max-width: 600px; ` const PopoverContentItem = styled.div`