Skip to content

Commit 1931479

Browse files
committed
Merge branch 'bestsanmao-bug_fix'
2 parents 2f9cb5a + 8680182 commit 1931479

File tree

4 files changed

+40
-22
lines changed

4 files changed

+40
-22
lines changed

.env.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
2+
13
# Your openai api key. (required)
24
OPENAI_API_KEY=sk-xxxx
35

6+
# DeepSeek Api Key. (Optional)
7+
DEEPSEEK_API_KEY=
8+
49
# Access password, separated by comma. (optional)
510
CODE=your-password
611

@@ -70,5 +75,6 @@ ANTHROPIC_API_VERSION=
7075
### anthropic claude Api url (optional)
7176
ANTHROPIC_URL=
7277

78+
7379
### (optional)
7480
WHITE_WEBDAV_ENDPOINTS=

app/config/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,6 @@ export const getServerSideConfig = () => {
255255
defaultModel,
256256
visionModels,
257257
allowedWebDavEndpoints,
258-
enableMcp: !!process.env.ENABLE_MCP,
258+
enableMcp: process.env.ENABLE_MCP === "true",
259259
};
260260
};

app/constant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ You are an AI assistant with access to system tools. Your role is to help users
393393

394394
export const SUMMARIZE_MODEL = "gpt-4o-mini";
395395
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
396+
export const DEEPSEEK_SUMMARIZE_MODEL = "deepseek-chat";
396397

397398
export const KnowledgeCutOffDate: Record<string, string> = {
398399
default: "2021-09",
@@ -561,7 +562,7 @@ const iflytekModels = [
561562
"4.0Ultra",
562563
];
563564

564-
const deepseekModels = ["deepseek-chat", "deepseek-coder"];
565+
const deepseekModels = ["deepseek-chat", "deepseek-coder", "deepseek-reasoner"];
565566

566567
const xAIModes = ["grok-beta"];
567568

app/store/chat.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
3536
import { useAccessStore } from "./access";
3637
import { collectModelsWithDefaultModel } from "../utils/model";
3738
import { createEmptyMask, Mask } from "./mask";
38-
import { executeMcpAction, getAllTools } from "../mcp/actions";
39+
import { executeMcpAction, getAllTools, isMcpEnabled } from "../mcp/actions";
3940
import { extractMcpJson, isMcpJson } from "../mcp/utils";
4041

4142
const 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

Comments
 (0)