@@ -20,6 +20,7 @@ import {
2020 DEFAULT_MODELS ,
2121 DEFAULT_SYSTEM_TEMPLATE ,
2222 GEMINI_SUMMARIZE_MODEL ,
23+ DEEPSEEK_SUMMARIZE_MODEL ,
2324 KnowledgeCutOffDate ,
2425 MCP_SYSTEM_TEMPLATE ,
2526 MCP_TOOLS_TEMPLATE ,
@@ -35,7 +36,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config";
3536import { useAccessStore } from "./access" ;
3637import { collectModelsWithDefaultModel } from "../utils/model" ;
3738import { createEmptyMask , Mask } from "./mask" ;
38- import { executeMcpAction , getAllTools } from "../mcp/actions" ;
39+ import { executeMcpAction , getAllTools , isMcpEnabled } from "../mcp/actions" ;
3940import { extractMcpJson , isMcpJson } from "../mcp/utils" ;
4041
4142const localStorage = safeLocalStorage ( ) ;
@@ -143,7 +144,10 @@ function getSummarizeModel(
143144 }
144145 if ( currentModel . startsWith ( "gemini" ) ) {
145146 return [ GEMINI_SUMMARIZE_MODEL , ServiceProvider . Google ] ;
147+ } else if ( currentModel . startsWith ( "deepseek-" ) ) {
148+ return [ DEEPSEEK_SUMMARIZE_MODEL , ServiceProvider . DeepSeek ] ;
146149 }
150+
147151 return [ currentModel , providerName ] ;
148152}
149153
@@ -245,7 +249,7 @@ export const useChatStore = createPersistStore(
245249
246250 newSession . topic = currentSession . topic ;
247251 // 深拷贝消息
248- newSession . messages = currentSession . messages . map ( msg => ( {
252+ newSession . messages = currentSession . messages . map ( ( msg ) => ( {
249253 ...msg ,
250254 id : nanoid ( ) , // 生成新的消息 ID
251255 } ) ) ;
@@ -551,27 +555,32 @@ export const useChatStore = createPersistStore(
551555 ( session . mask . modelConfig . model . startsWith ( "gpt-" ) ||
552556 session . mask . modelConfig . model . startsWith ( "chatgpt-" ) ) ;
553557
554- const mcpSystemPrompt = await getMcpSystemPrompt ( ) ;
558+ const mcpEnabled = await isMcpEnabled ( ) ;
559+ const mcpSystemPrompt = mcpEnabled ? await getMcpSystemPrompt ( ) : "" ;
555560
556561 var systemPrompts : ChatMessage [ ] = [ ] ;
557- systemPrompts = shouldInjectSystemPrompts
558- ? [
559- createMessage ( {
560- role : "system" ,
561- content :
562- fillTemplateWith ( "" , {
563- ...modelConfig ,
564- template : DEFAULT_SYSTEM_TEMPLATE ,
565- } ) + mcpSystemPrompt ,
566- } ) ,
567- ]
568- : [
569- createMessage ( {
570- role : "system" ,
571- content : mcpSystemPrompt ,
572- } ) ,
573- ] ;
562+
574563 if ( shouldInjectSystemPrompts ) {
564+ systemPrompts = [
565+ createMessage ( {
566+ role : "system" ,
567+ content :
568+ fillTemplateWith ( "" , {
569+ ...modelConfig ,
570+ template : DEFAULT_SYSTEM_TEMPLATE ,
571+ } ) + mcpSystemPrompt ,
572+ } ) ,
573+ ] ;
574+ } else if ( mcpEnabled ) {
575+ systemPrompts = [
576+ createMessage ( {
577+ role : "system" ,
578+ content : mcpSystemPrompt ,
579+ } ) ,
580+ ] ;
581+ }
582+
583+ if ( shouldInjectSystemPrompts || mcpEnabled ) {
575584 console . log (
576585 "[Global System Prompt] " ,
577586 systemPrompts . at ( 0 ) ?. content ?? "empty" ,
@@ -816,6 +825,8 @@ export const useChatStore = createPersistStore(
816825
817826 /** check if the message contains MCP JSON and execute the MCP action */
818827 checkMcpJson ( message : ChatMessage ) {
828+ const mcpEnabled = isMcpEnabled ( ) ;
829+ if ( ! mcpEnabled ) return ;
819830 const content = getMessageTextContent ( message ) ;
820831 if ( isMcpJson ( content ) ) {
821832 try {
0 commit comments