diff --git a/.env.template b/.env.template index c0cd80c65df..fd2f68df01f 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,11 @@ + + # Your openai api key. (required) OPENAI_API_KEY=sk-xxxx +# DeepSeek Api Key. (Optional) +DEEPSEEK_API_KEY= + # Access password, separated by comma. (optional) CODE=your-password @@ -70,5 +75,6 @@ ANTHROPIC_API_VERSION= ### anthropic claude Api url (optional) ANTHROPIC_URL= + ### (optional) WHITE_WEBDAV_ENDPOINTS= \ No newline at end of file diff --git a/app/config/server.ts b/app/config/server.ts index 6792a8330a2..1166805b57c 100644 --- a/app/config/server.ts +++ b/app/config/server.ts @@ -255,6 +255,6 @@ export const getServerSideConfig = () => { defaultModel, visionModels, allowedWebDavEndpoints, - enableMcp: !!process.env.ENABLE_MCP, + enableMcp: process.env.ENABLE_MCP === "true", }; }; diff --git a/app/constant.ts b/app/constant.ts index ce00d063ebd..14c8c78e5f3 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -393,6 +393,7 @@ You are an AI assistant with access to system tools. Your role is to help users export const SUMMARIZE_MODEL = "gpt-4o-mini"; export const GEMINI_SUMMARIZE_MODEL = "gemini-pro"; +export const DEEPSEEK_SUMMARIZE_MODEL = "deepseek-chat"; export const KnowledgeCutOffDate: Record = { default: "2021-09", @@ -561,7 +562,7 @@ const iflytekModels = [ "4.0Ultra", ]; -const deepseekModels = ["deepseek-chat", "deepseek-coder"]; +const deepseekModels = ["deepseek-chat", "deepseek-coder", "deepseek-reasoner"]; const xAIModes = ["grok-beta"]; diff --git a/app/store/chat.ts b/app/store/chat.ts index 5c95ac02c7d..87c1a8beba0 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -20,6 +20,7 @@ import { DEFAULT_MODELS, DEFAULT_SYSTEM_TEMPLATE, GEMINI_SUMMARIZE_MODEL, + DEEPSEEK_SUMMARIZE_MODEL, KnowledgeCutOffDate, MCP_SYSTEM_TEMPLATE, MCP_TOOLS_TEMPLATE, @@ -35,7 +36,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config"; import { useAccessStore } from "./access"; import { collectModelsWithDefaultModel } from "../utils/model"; import { createEmptyMask, Mask } from "./mask"; -import { executeMcpAction, getAllTools } from "../mcp/actions"; +import { executeMcpAction, getAllTools, isMcpEnabled } from "../mcp/actions"; import { extractMcpJson, isMcpJson } from "../mcp/utils"; const localStorage = safeLocalStorage(); @@ -143,7 +144,10 @@ function getSummarizeModel( } if (currentModel.startsWith("gemini")) { return [GEMINI_SUMMARIZE_MODEL, ServiceProvider.Google]; + } else if (currentModel.startsWith("deepseek-")) { + return [DEEPSEEK_SUMMARIZE_MODEL, ServiceProvider.DeepSeek]; } + return [currentModel, providerName]; } @@ -245,7 +249,7 @@ export const useChatStore = createPersistStore( newSession.topic = currentSession.topic; // 深拷贝消息 - newSession.messages = currentSession.messages.map(msg => ({ + newSession.messages = currentSession.messages.map((msg) => ({ ...msg, id: nanoid(), // 生成新的消息 ID })); @@ -551,27 +555,32 @@ export const useChatStore = createPersistStore( (session.mask.modelConfig.model.startsWith("gpt-") || session.mask.modelConfig.model.startsWith("chatgpt-")); - const mcpSystemPrompt = await getMcpSystemPrompt(); + const mcpEnabled = await isMcpEnabled(); + const mcpSystemPrompt = mcpEnabled ? await getMcpSystemPrompt() : ""; var systemPrompts: ChatMessage[] = []; - systemPrompts = shouldInjectSystemPrompts - ? [ - createMessage({ - role: "system", - content: - fillTemplateWith("", { - ...modelConfig, - template: DEFAULT_SYSTEM_TEMPLATE, - }) + mcpSystemPrompt, - }), - ] - : [ - createMessage({ - role: "system", - content: mcpSystemPrompt, - }), - ]; + if (shouldInjectSystemPrompts) { + systemPrompts = [ + createMessage({ + role: "system", + content: + fillTemplateWith("", { + ...modelConfig, + template: DEFAULT_SYSTEM_TEMPLATE, + }) + mcpSystemPrompt, + }), + ]; + } else if (mcpEnabled) { + systemPrompts = [ + createMessage({ + role: "system", + content: mcpSystemPrompt, + }), + ]; + } + + if (shouldInjectSystemPrompts || mcpEnabled) { console.log( "[Global System Prompt] ", systemPrompts.at(0)?.content ?? "empty", @@ -816,6 +825,8 @@ export const useChatStore = createPersistStore( /** check if the message contains MCP JSON and execute the MCP action */ checkMcpJson(message: ChatMessage) { + const mcpEnabled = isMcpEnabled(); + if (!mcpEnabled) return; const content = getMessageTextContent(message); if (isMcpJson(content)) { try {