Merge branch 'main' of https://github.com/Yidadaa/ChatGPT-Next-Web
This commit is contained in:
commit
735afc64f6
@ -40,7 +40,7 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel.
|
|||||||
- [ ] Share as image, share to ShareGPT
|
- [ ] Share as image, share to ShareGPT
|
||||||
- [ ] Desktop App with tauri
|
- [ ] Desktop App with tauri
|
||||||
- [ ] Self-host Model: support llama, alpaca, ChatGLM, BELLE etc.
|
- [ ] 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
|
### Not in Plan
|
||||||
|
|
||||||
|
@ -708,6 +708,7 @@ export function Chat(props: {
|
|||||||
className={styles["chat-body"]}
|
className={styles["chat-body"]}
|
||||||
ref={scrollRef}
|
ref={scrollRef}
|
||||||
onScroll={(e) => onChatBodyScroll(e.currentTarget)}
|
onScroll={(e) => onChatBodyScroll(e.currentTarget)}
|
||||||
|
onMouseDown={() => inputRef.current?.blur()}
|
||||||
onWheel={(e) => setAutoScroll(hitBottom && e.deltaY > 0)}
|
onWheel={(e) => setAutoScroll(hitBottom && e.deltaY > 0)}
|
||||||
onTouchStart={() => {
|
onTouchStart={() => {
|
||||||
inputRef.current?.blur();
|
inputRef.current?.blur();
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="38"
|
|
||||||
height="38" viewBox="0 0 38 38" fill="none">
|
|
||||||
<defs>
|
|
||||||
<filter id="filter_0" x="-4" y="-4" width="38" height="38" filterUnits="userSpaceOnUse"
|
|
||||||
color-interpolation-filters="sRGB">
|
|
||||||
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
||||||
<feColorMatrix in="SourceAlpha" type="matrix"
|
|
||||||
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
|
||||||
<feOffset dx="0" dy="2" />
|
|
||||||
<feGaussianBlur stdDeviation="2" />
|
|
||||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0" />
|
|
||||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_Shadow" />
|
|
||||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_Shadow" result="shape" />
|
|
||||||
</filter>
|
|
||||||
<rect id="path_0" x="0" y="0" width="30" height="30" />
|
|
||||||
</defs>
|
|
||||||
<g opacity="1" transform="translate(4 2) rotate(0 15 15)">
|
|
||||||
<g id="undefined" filter="url(#filter_0)">
|
|
||||||
<rect stroke="#000000" stroke-width="1" stroke-opacity="0.05" />
|
|
||||||
<rect x="0" y="0" width="30" height="30" rx="10" />
|
|
||||||
</g>
|
|
||||||
<mask id="bg-mask-0" fill="white">
|
|
||||||
<use xlink:href="#path_0"></use>
|
|
||||||
</mask>
|
|
||||||
<g mask="url(#bg-mask-0)">
|
|
||||||
<g opacity="1" transform="translate(6 4.5) rotate(0 9 11)">
|
|
||||||
<text>
|
|
||||||
<tspan x="0" y="16.240000000000002" font-size="14" line-height="0" fill="#000000"
|
|
||||||
opacity="1" font-family="SourceHanSansCN-Regular" letter-spacing="0">🤣</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.5 KiB |
@ -38,12 +38,12 @@ const cn = {
|
|||||||
MessageFromChatGPT: "来自 ChatGPT 的消息",
|
MessageFromChatGPT: "来自 ChatGPT 的消息",
|
||||||
},
|
},
|
||||||
Memory: {
|
Memory: {
|
||||||
Title: "历史记忆",
|
Title: "历史摘要",
|
||||||
EmptyContent: "尚未记忆",
|
EmptyContent: "尚未总结",
|
||||||
Send: "发送记忆",
|
Send: "启用总结并发送摘要",
|
||||||
Copy: "复制记忆",
|
Copy: "复制摘要",
|
||||||
Reset: "重置对话",
|
Reset: "重置对话",
|
||||||
ResetConfirm: "重置后将清空当前对话记录以及历史记忆,确认重置?",
|
ResetConfirm: "重置后将清空当前对话记录以及历史摘要,确认重置?",
|
||||||
},
|
},
|
||||||
Home: {
|
Home: {
|
||||||
NewChat: "新的聊天",
|
NewChat: "新的聊天",
|
||||||
@ -108,7 +108,7 @@ const cn = {
|
|||||||
Modal: {
|
Modal: {
|
||||||
Title: "提示词列表",
|
Title: "提示词列表",
|
||||||
Add: "增加一条",
|
Add: "增加一条",
|
||||||
Search: "搜尋提示詞",
|
Search: "搜索提示词",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
HistoryCount: {
|
HistoryCount: {
|
||||||
|
@ -109,9 +109,9 @@ const jp = {
|
|||||||
`組み込み ${builtin} 件、ユーザー定義 ${custom} 件`,
|
`組み込み ${builtin} 件、ユーザー定義 ${custom} 件`,
|
||||||
Edit: "編集",
|
Edit: "編集",
|
||||||
Modal: {
|
Modal: {
|
||||||
Title: "提示词列表",
|
Title: "プロンプトリスト",
|
||||||
Add: "增加一条",
|
Add: "新規追加",
|
||||||
Search: "搜尋提示詞",
|
Search: "プロンプトワード検索",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
HistoryCount: {
|
HistoryCount: {
|
||||||
|
@ -108,7 +108,7 @@ const tw: LocaleType = {
|
|||||||
Modal: {
|
Modal: {
|
||||||
Title: "提示詞列表",
|
Title: "提示詞列表",
|
||||||
Add: "增加一條",
|
Add: "增加一條",
|
||||||
Search: "搜索提示词",
|
Search: "搜尋提示詞",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
HistoryCount: {
|
HistoryCount: {
|
||||||
@ -160,9 +160,9 @@ const tw: LocaleType = {
|
|||||||
History: (content: string) =>
|
History: (content: string) =>
|
||||||
"這是 AI 與用戶的歷史聊天總結,作為前情提要:" + content,
|
"這是 AI 與用戶的歷史聊天總結,作為前情提要:" + content,
|
||||||
Topic:
|
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:
|
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: "確認清除所有對話、設定數據?",
|
ConfirmClearAll: "確認清除所有對話、設定數據?",
|
||||||
},
|
},
|
||||||
|
@ -462,6 +462,7 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
|
|
||||||
const context = session.context.slice();
|
const context = session.context.slice();
|
||||||
|
|
||||||
|
// long term memory
|
||||||
if (
|
if (
|
||||||
session.sendMemory &&
|
session.sendMemory &&
|
||||||
session.memoryPrompt &&
|
session.memoryPrompt &&
|
||||||
@ -471,9 +472,33 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
context.push(memoryPrompt);
|
context.push(memoryPrompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentMessages = context.concat(
|
// get short term and unmemoried long term memory
|
||||||
messages.slice(Math.max(0, n - config.historyMessageCount)),
|
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;
|
return recentMessages;
|
||||||
},
|
},
|
||||||
@ -542,7 +567,10 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
config.compressMessageLengthThreshold,
|
config.compressMessageLengthThreshold,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (historyMsgLength > config.compressMessageLengthThreshold) {
|
if (
|
||||||
|
historyMsgLength > config.compressMessageLengthThreshold &&
|
||||||
|
session.sendMemory
|
||||||
|
) {
|
||||||
requestChatStream(
|
requestChatStream(
|
||||||
toBeSummarizedMsgs.concat({
|
toBeSummarizedMsgs.concat({
|
||||||
role: "system",
|
role: "system",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user