diff --git a/README.md b/README.md
index 3b6308be9..ab902dd39 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel.
- [ ] Share as image, share to ShareGPT
- [ ] Desktop App with tauri
- [ ] Self-host Model: support llama, alpaca, ChatGLM, BELLE etc.
-- [ ] Plugins: support network search, caculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165)
+- [ ] Plugins: support network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165)
### Not in Plan
diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index 3c66627f6..5dce8fd61 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -708,6 +708,7 @@ export function Chat(props: {
className={styles["chat-body"]}
ref={scrollRef}
onScroll={(e) => onChatBodyScroll(e.currentTarget)}
+ onMouseDown={() => inputRef.current?.blur()}
onWheel={(e) => setAutoScroll(hitBottom && e.deltaY > 0)}
onTouchStart={() => {
inputRef.current?.blur();
diff --git a/app/icons/user.svg b/app/icons/user.svg
deleted file mode 100644
index 7f91de4dc..000000000
--- a/app/icons/user.svg
+++ /dev/null
@@ -1,34 +0,0 @@
-
\ No newline at end of file
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index d0ab27ca2..1c198195e 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -38,12 +38,12 @@ const cn = {
MessageFromChatGPT: "来自 ChatGPT 的消息",
},
Memory: {
- Title: "历史记忆",
- EmptyContent: "尚未记忆",
- Send: "发送记忆",
- Copy: "复制记忆",
+ Title: "历史摘要",
+ EmptyContent: "尚未总结",
+ Send: "启用总结并发送摘要",
+ Copy: "复制摘要",
Reset: "重置对话",
- ResetConfirm: "重置后将清空当前对话记录以及历史记忆,确认重置?",
+ ResetConfirm: "重置后将清空当前对话记录以及历史摘要,确认重置?",
},
Home: {
NewChat: "新的聊天",
@@ -108,7 +108,7 @@ const cn = {
Modal: {
Title: "提示词列表",
Add: "增加一条",
- Search: "搜尋提示詞",
+ Search: "搜索提示词",
},
},
HistoryCount: {
diff --git a/app/locales/jp.ts b/app/locales/jp.ts
index a793b5fe0..2818820b5 100644
--- a/app/locales/jp.ts
+++ b/app/locales/jp.ts
@@ -109,9 +109,9 @@ const jp = {
`組み込み ${builtin} 件、ユーザー定義 ${custom} 件`,
Edit: "編集",
Modal: {
- Title: "提示词列表",
- Add: "增加一条",
- Search: "搜尋提示詞",
+ Title: "プロンプトリスト",
+ Add: "新規追加",
+ Search: "プロンプトワード検索",
},
},
HistoryCount: {
diff --git a/app/locales/tw.ts b/app/locales/tw.ts
index 2fbb2e477..44c07898d 100644
--- a/app/locales/tw.ts
+++ b/app/locales/tw.ts
@@ -108,7 +108,7 @@ const tw: LocaleType = {
Modal: {
Title: "提示詞列表",
Add: "增加一條",
- Search: "搜索提示词",
+ Search: "搜尋提示詞",
},
},
HistoryCount: {
@@ -160,9 +160,9 @@ const tw: LocaleType = {
History: (content: string) =>
"這是 AI 與用戶的歷史聊天總結,作為前情提要:" + content,
Topic:
- "Summarise the conversation in a short and concise eye-catching title that instantly conveys the main topic. Use as few words as possible. Use the language used in the enquiry, e.g. use English for English enquiry, use zh-hant for traditional chinese enquiry. Don't use quotation marks at the beginning and the end.",
+ "Use the language used by the user (e.g. en for english conversation, zh-hant for chinese conversation, etc.) to generate a title (at most 6 words) summarizing our conversation without any lead-in, quotation marks, preamble like 'Title:', direct text copies, single-word replies, quotation marks, translations, or brackets. Remove enclosing quotation marks. The title should make third-party grasp the essence of the conversation in first sight.",
Summarize:
- "Summarise the conversation in at most 250 tokens for continuing the conversation in future. Use the language used in the conversation, e.g. use English for English conversation, use zh-hant for traditional chinese conversation.",
+ "Use the language used by the user (e.g. en-us for english conversation, zh-hant for chinese conversation, etc.) to summarise the conversation in at most 200 words. The summary will be used as prompt for you to continue the conversation in the future.",
},
ConfirmClearAll: "確認清除所有對話、設定數據?",
},
diff --git a/app/store/app.ts b/app/store/app.ts
index 39df9ef79..da0e886ff 100644
--- a/app/store/app.ts
+++ b/app/store/app.ts
@@ -462,6 +462,7 @@ export const useChatStore = create()(
const context = session.context.slice();
+ // long term memory
if (
session.sendMemory &&
session.memoryPrompt &&
@@ -471,9 +472,33 @@ export const useChatStore = create()(
context.push(memoryPrompt);
}
- const recentMessages = context.concat(
- messages.slice(Math.max(0, n - config.historyMessageCount)),
+ // get short term and unmemoried long term memory
+ const shortTermMemoryMessageIndex = Math.max(
+ 0,
+ n - config.historyMessageCount,
);
+ const longTermMemoryMessageIndex = session.lastSummarizeIndex;
+ const oldestIndex = Math.min(
+ shortTermMemoryMessageIndex,
+ longTermMemoryMessageIndex,
+ );
+ const threshold = config.compressMessageLengthThreshold;
+
+ // get recent messages as many as possible
+ const reversedRecentMessages = [];
+ for (
+ let i = n - 1, count = 0;
+ i >= oldestIndex && count < threshold;
+ i -= 1
+ ) {
+ const msg = messages[i];
+ if (!msg || msg.isError) continue;
+ count += msg.content.length;
+ reversedRecentMessages.push(msg);
+ }
+
+ // concat
+ const recentMessages = context.concat(reversedRecentMessages.reverse());
return recentMessages;
},
@@ -542,7 +567,10 @@ export const useChatStore = create()(
config.compressMessageLengthThreshold,
);
- if (historyMsgLength > config.compressMessageLengthThreshold) {
+ if (
+ historyMsgLength > config.compressMessageLengthThreshold &&
+ session.sendMemory
+ ) {
requestChatStream(
toBeSummarizedMsgs.concat({
role: "system",