diff --git a/src/renderer/src/windows/mini/home/HomeWindow.tsx b/src/renderer/src/windows/mini/home/HomeWindow.tsx index 3444de7257..a8df8a6387 100644 --- a/src/renderer/src/windows/mini/home/HomeWindow.tsx +++ b/src/renderer/src/windows/mini/home/HomeWindow.tsx @@ -21,7 +21,7 @@ import { getMainTextContent } from '@renderer/utils/messageUtils/find' import { defaultLanguage } from '@shared/config/constant' import { IpcChannel } from '@shared/IpcChannel' import { Divider } from 'antd' -import { isEmpty } from 'lodash' +import { cloneDeep, isEmpty } from 'lodash' import { last } from 'lodash' import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -256,9 +256,19 @@ const HomeWindow: FC<{ draggable?: boolean }> = ({ draggable = true }) => { setIsFirstMessage(false) setUserInputText('') + const newAssistant = cloneDeep(currentAssistant) + if (!newAssistant.settings) { + newAssistant.settings = {} + } + newAssistant.settings.streamOutput = true + // 显式关闭这些功能 + // newAssistant.webSearchProviderId = undefined + newAssistant.mcpServers = undefined + // newAssistant.knowledge_bases = undefined + await fetchChatCompletion({ messages: messagesForContext, - assistant: { ...currentAssistant, settings: { streamOutput: true } }, + assistant: newAssistant, onChunkReceived: (chunk: Chunk) => { switch (chunk.type) { case ChunkType.THINKING_START: diff --git a/src/renderer/src/windows/selection/action/components/ActionGeneral.tsx b/src/renderer/src/windows/selection/action/components/ActionGeneral.tsx index 9f3762b15f..b1d3c18853 100644 --- a/src/renderer/src/windows/selection/action/components/ActionGeneral.tsx +++ b/src/renderer/src/windows/selection/action/components/ActionGeneral.tsx @@ -1,4 +1,5 @@ import { LoadingOutlined } from '@ant-design/icons' +import { loggerService } from '@logger' import CopyButton from '@renderer/components/CopyButton' import { useTopicMessages } from '@renderer/hooks/useMessageOperations' import { useSettings } from '@renderer/hooks/useSettings' @@ -21,6 +22,7 @@ import styled from 'styled-components' import { processMessages } from './ActionUtils' import WindowFooter from './WindowFooter' +const logger = loggerService.withContext('ActionGeneral') interface Props { action: ActionItem scrollToBottom?: () => void @@ -112,6 +114,7 @@ const ActionGeneral: FC = React.memo(({ action, scrollToBottom }) => { } if (!assistantRef.current || !topicRef.current) return + logger.debug('Before peocess message', { assistant: assistantRef.current }) processMessages( assistantRef.current, topicRef.current, diff --git a/src/renderer/src/windows/selection/action/components/ActionUtils.ts b/src/renderer/src/windows/selection/action/components/ActionUtils.ts index 541a4e3bb0..5f41b9b107 100644 --- a/src/renderer/src/windows/selection/action/components/ActionUtils.ts +++ b/src/renderer/src/windows/selection/action/components/ActionUtils.ts @@ -10,6 +10,7 @@ import { Chunk, ChunkType } from '@renderer/types/chunk' import { AssistantMessageStatus, MessageBlockStatus } from '@renderer/types/newMessage' import { formatErrorMessage, isAbortError } from '@renderer/utils/error' import { createErrorBlock, createMainTextBlock, createThinkingBlock } from '@renderer/utils/messageUtils/create' +import { cloneDeep } from 'lodash' const logger = loggerService.withContext('ActionUtils') @@ -53,9 +54,19 @@ export const processMessages = async ( let finished = false + const newAssistant = cloneDeep(assistant) + if (!newAssistant.settings) { + newAssistant.settings = {} + } + newAssistant.settings.streamOutput = true + // 显式关闭这些功能 + newAssistant.webSearchProviderId = undefined + newAssistant.mcpServers = undefined + // newAssistant.knowledge_bases = undefined + await fetchChatCompletion({ messages: [userMessage], - assistant: { ...assistant, settings: { streamOutput: true } }, + assistant: newAssistant, onChunkReceived: (chunk: Chunk) => { if (finished) { return