diff --git a/.gitignore b/.gitignore
index 2ff556f646e..b1d610c1fcb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,3 +46,5 @@ dev
*.key.pub
masks.json
+
+.codegpt
\ No newline at end of file
diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index f34f7d78e09..9990a359e14 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -900,6 +900,12 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
title: Locale.Chat.ShortcutKey.showShortcutKey,
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
},
+ {
+ title: Locale.Chat.ShortcutKey.clearContext,
+ keys: isMac
+ ? ["⌘", "Shift", "backspace"]
+ : ["Ctrl", "Shift", "backspace"],
+ },
];
return (
@@ -1552,7 +1558,7 @@ function _Chat() {
const [showShortcutKeyModal, setShowShortcutKeyModal] = useState(false);
useEffect(() => {
- const handleKeyDown = (event: any) => {
+ const handleKeyDown = (event: KeyboardEvent) => {
// 打开新聊天 command + shift + o
if (
(event.metaKey || event.ctrlKey) &&
@@ -1603,14 +1609,30 @@ function _Chat() {
event.preventDefault();
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 () => {
- window.removeEventListener("keydown", handleKeyDown);
+ document.removeEventListener("keydown", handleKeyDown);
};
- }, [messages, chatStore, navigate]);
+ }, [messages, chatStore, navigate, session]);
const [showChatSidePanel, setShowChatSidePanel] = useState(false);
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index 182a4ce541c..25f49be7d19 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -106,6 +106,7 @@ const cn = {
copyLastMessage: "复制最后一个回复",
copyLastCode: "复制最后一个代码块",
showShortcutKey: "显示快捷方式",
+ clearContext: "清除上下文",
},
},
Export: {
diff --git a/app/locales/en.ts b/app/locales/en.ts
index 27f44e5d9d7..3eb750d445e 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -107,6 +107,7 @@ const en: LocaleType = {
copyLastMessage: "Copy Last Reply",
copyLastCode: "Copy Last Code Block",
showShortcutKey: "Show Shortcuts",
+ clearContext: "Clear Context",
},
},
Export: {
diff --git a/app/locales/tw.ts b/app/locales/tw.ts
index f10c793ab80..83dd547b8ed 100644
--- a/app/locales/tw.ts
+++ b/app/locales/tw.ts
@@ -100,6 +100,7 @@ const tw = {
copyLastMessage: "複製最後一個回覆",
copyLastCode: "複製最後一個程式碼區塊",
showShortcutKey: "顯示快捷方式",
+ clearContext: "清除上下文",
},
},
Export: {
diff --git a/docker-compose.yml b/docker-compose.yml
index 935b126a394..f6d13607eb9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,38 +1,41 @@
+# Docker Compose 文件版本
version: "3.9"
services:
+ # 主服务 - 不使用代理
chatgpt-next-web:
- profiles: [ "no-proxy" ]
- container_name: chatgpt-next-web
- image: yidadaa/chatgpt-next-web
+ profiles: [ "no-proxy" ] # 不使用代理的profile
+ container_name: chatgpt-next-web # 容器名称
+ image: yidadaa/chatgpt-next-web # 使用的镜像
ports:
- - 3000:3000
+ - 3000:3000 # 端口映射:主机3000端口映射到容器3000端口
environment:
- - OPENAI_API_KEY=$OPENAI_API_KEY
- - GOOGLE_API_KEY=$GOOGLE_API_KEY
- - CODE=$CODE
- - BASE_URL=$BASE_URL
- - OPENAI_ORG_ID=$OPENAI_ORG_ID
- - HIDE_USER_API_KEY=$HIDE_USER_API_KEY
- - DISABLE_GPT4=$DISABLE_GPT4
- - ENABLE_BALANCE_QUERY=$ENABLE_BALANCE_QUERY
- - DISABLE_FAST_LINK=$DISABLE_FAST_LINK
- - OPENAI_SB=$OPENAI_SB
+ - OPENAI_API_KEY=$OPENAI_API_KEY # OpenAI API密钥
+ - GOOGLE_API_KEY=$GOOGLE_API_KEY # Google API密钥
+ - CODE=$CODE # 访问密码
+ - BASE_URL=$BASE_URL # API基础地址
+ - OPENAI_ORG_ID=$OPENAI_ORG_ID # OpenAI组织ID
+ - HIDE_USER_API_KEY=$HIDE_USER_API_KEY # 是否隐藏用户API密钥
+ - DISABLE_GPT4=$DISABLE_GPT4 # 是否禁用GPT-4
+ - ENABLE_BALANCE_QUERY=$ENABLE_BALANCE_QUERY # 是否启用余额查询
+ - DISABLE_FAST_LINK=$DISABLE_FAST_LINK # 是否禁用快速链接
+ - OPENAI_SB=$OPENAI_SB # OpenAI沙盒模式
+ # 代理服务 - 使用代理
chatgpt-next-web-proxy:
- profiles: [ "proxy" ]
- container_name: chatgpt-next-web-proxy
- image: yidadaa/chatgpt-next-web
+ profiles: [ "proxy" ] # 使用代理的profile
+ container_name: chatgpt-next-web-proxy # 容器名称
+ image: yidadaa/chatgpt-next-web # 使用的镜像
ports:
- 3000:3000
environment:
- - OPENAI_API_KEY=$OPENAI_API_KEY
- - GOOGLE_API_KEY=$GOOGLE_API_KEY
- - CODE=$CODE
- - PROXY_URL=$PROXY_URL
- - BASE_URL=$BASE_URL
- - OPENAI_ORG_ID=$OPENAI_ORG_ID
- - HIDE_USER_API_KEY=$HIDE_USER_API_KEY
- - DISABLE_GPT4=$DISABLE_GPT4
- - ENABLE_BALANCE_QUERY=$ENABLE_BALANCE_QUERY
- - DISABLE_FAST_LINK=$DISABLE_FAST_LINK
- - OPENAI_SB=$OPENAI_SB
+ - OPENAI_API_KEY=$OPENAI_API_KEY # OpenAI API密钥
+ - GOOGLE_API_KEY=$GOOGLE_API_KEY # Google API密钥
+ - CODE=$CODE # 访问密码
+ - PROXY_URL=$PROXY_URL # 代理服务器地址
+ - BASE_URL=$BASE_URL # API基础地址
+ - OPENAI_ORG_ID=$OPENAI_ORG_ID # OpenAI组织ID
+ - HIDE_USER_API_KEY=$HIDE_USER_API_KEY # 是否隐藏用户API密钥
+ - DISABLE_GPT4=$DISABLE_GPT4 # 是否禁用GPT-4
+ - ENABLE_BALANCE_QUERY=$ENABLE_BALANCE_QUERY # 是否启用余额查询
+ - DISABLE_FAST_LINK=$DISABLE_FAST_LINK # 是否禁用快速链接
+ - OPENAI_SB=$OPENAI_SB # OpenAI沙盒模式