mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-20 04:30:17 +09:00
not insert mcpSystemPrompt if not ENABLE_MCP
This commit is contained in:
parent
2f9cb5a68f
commit
0d5e66a9ae
@ -35,7 +35,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config";
|
|||||||
import { useAccessStore } from "./access";
|
import { useAccessStore } from "./access";
|
||||||
import { collectModelsWithDefaultModel } from "../utils/model";
|
import { collectModelsWithDefaultModel } from "../utils/model";
|
||||||
import { createEmptyMask, Mask } from "./mask";
|
import { createEmptyMask, Mask } from "./mask";
|
||||||
import { executeMcpAction, getAllTools } from "../mcp/actions";
|
import { executeMcpAction, getAllTools, isMcpEnabled } from "../mcp/actions";
|
||||||
import { extractMcpJson, isMcpJson } from "../mcp/utils";
|
import { extractMcpJson, isMcpJson } from "../mcp/utils";
|
||||||
|
|
||||||
const localStorage = safeLocalStorage();
|
const localStorage = safeLocalStorage();
|
||||||
@ -245,7 +245,7 @@ export const useChatStore = createPersistStore(
|
|||||||
|
|
||||||
newSession.topic = currentSession.topic;
|
newSession.topic = currentSession.topic;
|
||||||
// 深拷贝消息
|
// 深拷贝消息
|
||||||
newSession.messages = currentSession.messages.map(msg => ({
|
newSession.messages = currentSession.messages.map((msg) => ({
|
||||||
...msg,
|
...msg,
|
||||||
id: nanoid(), // 生成新的消息 ID
|
id: nanoid(), // 生成新的消息 ID
|
||||||
}));
|
}));
|
||||||
@ -551,11 +551,13 @@ export const useChatStore = createPersistStore(
|
|||||||
(session.mask.modelConfig.model.startsWith("gpt-") ||
|
(session.mask.modelConfig.model.startsWith("gpt-") ||
|
||||||
session.mask.modelConfig.model.startsWith("chatgpt-"));
|
session.mask.modelConfig.model.startsWith("chatgpt-"));
|
||||||
|
|
||||||
const mcpSystemPrompt = await getMcpSystemPrompt();
|
const mcpEnabled = await isMcpEnabled();
|
||||||
|
const mcpSystemPrompt = mcpEnabled ? await getMcpSystemPrompt() : "";
|
||||||
|
|
||||||
var systemPrompts: ChatMessage[] = [];
|
var systemPrompts: ChatMessage[] = [];
|
||||||
systemPrompts = shouldInjectSystemPrompts
|
|
||||||
? [
|
if (shouldInjectSystemPrompts) {
|
||||||
|
systemPrompts = [
|
||||||
createMessage({
|
createMessage({
|
||||||
role: "system",
|
role: "system",
|
||||||
content:
|
content:
|
||||||
@ -564,14 +566,17 @@ export const useChatStore = createPersistStore(
|
|||||||
template: DEFAULT_SYSTEM_TEMPLATE,
|
template: DEFAULT_SYSTEM_TEMPLATE,
|
||||||
}) + mcpSystemPrompt,
|
}) + mcpSystemPrompt,
|
||||||
}),
|
}),
|
||||||
]
|
];
|
||||||
: [
|
} else if (mcpEnabled) {
|
||||||
|
systemPrompts = [
|
||||||
createMessage({
|
createMessage({
|
||||||
role: "system",
|
role: "system",
|
||||||
content: mcpSystemPrompt,
|
content: mcpSystemPrompt,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
if (shouldInjectSystemPrompts) {
|
}
|
||||||
|
|
||||||
|
if (shouldInjectSystemPrompts || mcpEnabled) {
|
||||||
console.log(
|
console.log(
|
||||||
"[Global System Prompt] ",
|
"[Global System Prompt] ",
|
||||||
systemPrompts.at(0)?.content ?? "empty",
|
systemPrompts.at(0)?.content ?? "empty",
|
||||||
@ -816,6 +821,8 @@ export const useChatStore = createPersistStore(
|
|||||||
|
|
||||||
/** check if the message contains MCP JSON and execute the MCP action */
|
/** check if the message contains MCP JSON and execute the MCP action */
|
||||||
checkMcpJson(message: ChatMessage) {
|
checkMcpJson(message: ChatMessage) {
|
||||||
|
const mcpEnabled = isMcpEnabled();
|
||||||
|
if (!mcpEnabled) return;
|
||||||
const content = getMessageTextContent(message);
|
const content = getMessageTextContent(message);
|
||||||
if (isMcpJson(content)) {
|
if (isMcpJson(content)) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user