mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-22 13:40:16 +09:00
Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web
This commit is contained in:
commit
7f9e4e9cb5
@ -14,6 +14,7 @@ const DANGER_CONFIG = {
|
|||||||
disableFastLink: serverConfig.disableFastLink,
|
disableFastLink: serverConfig.disableFastLink,
|
||||||
customModels: serverConfig.customModels,
|
customModels: serverConfig.customModels,
|
||||||
defaultModel: serverConfig.defaultModel,
|
defaultModel: serverConfig.defaultModel,
|
||||||
|
visionModels: serverConfig.visionModels,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -900,6 +900,12 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
|
|||||||
title: Locale.Chat.ShortcutKey.showShortcutKey,
|
title: Locale.Chat.ShortcutKey.showShortcutKey,
|
||||||
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
|
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: Locale.Chat.ShortcutKey.clearContext,
|
||||||
|
keys: isMac
|
||||||
|
? ["⌘", "Shift", "backspace"]
|
||||||
|
: ["Ctrl", "Shift", "backspace"],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<div className="modal-mask">
|
<div className="modal-mask">
|
||||||
@ -1552,7 +1558,7 @@ function _Chat() {
|
|||||||
const [showShortcutKeyModal, setShowShortcutKeyModal] = useState(false);
|
const [showShortcutKeyModal, setShowShortcutKeyModal] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (event: any) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
// 打开新聊天 command + shift + o
|
// 打开新聊天 command + shift + o
|
||||||
if (
|
if (
|
||||||
(event.metaKey || event.ctrlKey) &&
|
(event.metaKey || event.ctrlKey) &&
|
||||||
@ -1603,14 +1609,30 @@ function _Chat() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setShowShortcutKeyModal(true);
|
setShowShortcutKeyModal(true);
|
||||||
}
|
}
|
||||||
|
// 清除上下文 command + shift + backspace
|
||||||
|
else if (
|
||||||
|
(event.metaKey || event.ctrlKey) &&
|
||||||
|
event.shiftKey &&
|
||||||
|
event.key.toLowerCase() === "backspace"
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
chatStore.updateTargetSession(session, (session) => {
|
||||||
|
if (session.clearContextIndex === session.messages.length) {
|
||||||
|
session.clearContextIndex = undefined;
|
||||||
|
} else {
|
||||||
|
session.clearContextIndex = session.messages.length;
|
||||||
|
session.memoryPrompt = ""; // will clear memory
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("keydown", handleKeyDown);
|
document.addEventListener("keydown", handleKeyDown);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("keydown", handleKeyDown);
|
document.removeEventListener("keydown", handleKeyDown);
|
||||||
};
|
};
|
||||||
}, [messages, chatStore, navigate]);
|
}, [messages, chatStore, navigate, session]);
|
||||||
|
|
||||||
const [showChatSidePanel, setShowChatSidePanel] = useState(false);
|
const [showChatSidePanel, setShowChatSidePanel] = useState(false);
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ export const getBuildConfig = () => {
|
|||||||
buildMode,
|
buildMode,
|
||||||
isApp,
|
isApp,
|
||||||
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
|
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
|
||||||
visionModels: process.env.VISION_MODELS || "",
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ declare global {
|
|||||||
DISABLE_FAST_LINK?: string; // disallow parse settings from url or not
|
DISABLE_FAST_LINK?: string; // disallow parse settings from url or not
|
||||||
CUSTOM_MODELS?: string; // to control custom models
|
CUSTOM_MODELS?: string; // to control custom models
|
||||||
DEFAULT_MODEL?: string; // to control default model in every new chat window
|
DEFAULT_MODEL?: string; // to control default model in every new chat window
|
||||||
|
VISION_MODELS?: string; // to control vision models
|
||||||
|
|
||||||
// stability only
|
// stability only
|
||||||
STABILITY_URL?: string;
|
STABILITY_URL?: string;
|
||||||
@ -128,6 +129,7 @@ export const getServerSideConfig = () => {
|
|||||||
const disableGPT4 = !!process.env.DISABLE_GPT4;
|
const disableGPT4 = !!process.env.DISABLE_GPT4;
|
||||||
let customModels = process.env.CUSTOM_MODELS ?? "";
|
let customModels = process.env.CUSTOM_MODELS ?? "";
|
||||||
let defaultModel = process.env.DEFAULT_MODEL ?? "";
|
let defaultModel = process.env.DEFAULT_MODEL ?? "";
|
||||||
|
let visionModels = process.env.VISION_MODELS ?? "";
|
||||||
|
|
||||||
if (disableGPT4) {
|
if (disableGPT4) {
|
||||||
if (customModels) customModels += ",";
|
if (customModels) customModels += ",";
|
||||||
@ -249,6 +251,7 @@ export const getServerSideConfig = () => {
|
|||||||
disableFastLink: !!process.env.DISABLE_FAST_LINK,
|
disableFastLink: !!process.env.DISABLE_FAST_LINK,
|
||||||
customModels,
|
customModels,
|
||||||
defaultModel,
|
defaultModel,
|
||||||
|
visionModels,
|
||||||
allowedWebDavEndpoints,
|
allowedWebDavEndpoints,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -106,6 +106,7 @@ const cn = {
|
|||||||
copyLastMessage: "复制最后一个回复",
|
copyLastMessage: "复制最后一个回复",
|
||||||
copyLastCode: "复制最后一个代码块",
|
copyLastCode: "复制最后一个代码块",
|
||||||
showShortcutKey: "显示快捷方式",
|
showShortcutKey: "显示快捷方式",
|
||||||
|
clearContext: "清除上下文",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Export: {
|
Export: {
|
||||||
|
@ -107,6 +107,7 @@ const en: LocaleType = {
|
|||||||
copyLastMessage: "Copy Last Reply",
|
copyLastMessage: "Copy Last Reply",
|
||||||
copyLastCode: "Copy Last Code Block",
|
copyLastCode: "Copy Last Code Block",
|
||||||
showShortcutKey: "Show Shortcuts",
|
showShortcutKey: "Show Shortcuts",
|
||||||
|
clearContext: "Clear Context",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Export: {
|
Export: {
|
||||||
|
@ -100,6 +100,7 @@ const tw = {
|
|||||||
copyLastMessage: "複製最後一個回覆",
|
copyLastMessage: "複製最後一個回覆",
|
||||||
copyLastCode: "複製最後一個程式碼區塊",
|
copyLastCode: "複製最後一個程式碼區塊",
|
||||||
showShortcutKey: "顯示快捷方式",
|
showShortcutKey: "顯示快捷方式",
|
||||||
|
clearContext: "清除上下文",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Export: {
|
Export: {
|
||||||
|
@ -131,6 +131,7 @@ const DEFAULT_ACCESS_STATE = {
|
|||||||
disableFastLink: false,
|
disableFastLink: false,
|
||||||
customModels: "",
|
customModels: "",
|
||||||
defaultModel: "",
|
defaultModel: "",
|
||||||
|
visionModels: "",
|
||||||
|
|
||||||
// tts config
|
// tts config
|
||||||
edgeTTSVoiceName: "zh-CN-YunxiNeural",
|
edgeTTSVoiceName: "zh-CN-YunxiNeural",
|
||||||
@ -145,7 +146,10 @@ export const useAccessStore = createPersistStore(
|
|||||||
|
|
||||||
return get().needCode;
|
return get().needCode;
|
||||||
},
|
},
|
||||||
|
getVisionModels() {
|
||||||
|
this.fetch();
|
||||||
|
return get().visionModels;
|
||||||
|
},
|
||||||
edgeVoiceName() {
|
edgeVoiceName() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { ServiceProvider } from "./constant";
|
|||||||
// import { fetch as tauriFetch, ResponseType } from "@tauri-apps/api/http";
|
// import { fetch as tauriFetch, ResponseType } from "@tauri-apps/api/http";
|
||||||
import { fetch as tauriStreamFetch } from "./utils/stream";
|
import { fetch as tauriStreamFetch } from "./utils/stream";
|
||||||
import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
|
import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
|
||||||
import { getClientConfig } from "./config/client";
|
import { useAccessStore } from "./store";
|
||||||
import { ModelSize } from "./typing";
|
import { ModelSize } from "./typing";
|
||||||
|
|
||||||
export function trimTopic(topic: string) {
|
export function trimTopic(topic: string) {
|
||||||
@ -255,8 +255,8 @@ export function getMessageImages(message: RequestMessage): string[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isVisionModel(model: string) {
|
export function isVisionModel(model: string) {
|
||||||
const clientConfig = getClientConfig();
|
const visionModels = useAccessStore.getState().visionModels;
|
||||||
const envVisionModels = clientConfig?.visionModels
|
const envVisionModels = visionModels
|
||||||
?.split(",")
|
?.split(",")
|
||||||
.map((m) => m.trim());
|
.map((m) => m.trim());
|
||||||
if (envVisionModels?.includes(model)) {
|
if (envVisionModels?.includes(model)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user