mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-06 23:41:34 +08:00
fix: chat history with memory
This commit is contained in:
@@ -26,7 +26,7 @@ import CloseIcon from "../icons/close.svg";
|
||||
import CopyIcon from "../icons/copy.svg";
|
||||
import DownloadIcon from "../icons/download.svg";
|
||||
|
||||
import { Message, SubmitKey, useChatStore, Theme } from "../store";
|
||||
import { Message, SubmitKey, useChatStore, ChatSession } from "../store";
|
||||
import { Settings } from "./settings";
|
||||
import { showModal } from "./ui-lib";
|
||||
import { copyToClipboard, downloadAs, isIOS } from "../utils";
|
||||
@@ -189,8 +189,8 @@ export function Chat(props: { showSideBar?: () => void }) {
|
||||
return (
|
||||
<div className={styles.chat} key={session.id}>
|
||||
<div className={styles["window-header"]}>
|
||||
<div>
|
||||
<div className={styles["window-header-title"]}>{session.topic}</div>
|
||||
<div className={styles["window-header-title"]}>
|
||||
<div className={styles["window-header-main-title"]}>{session.topic}</div>
|
||||
<div className={styles["window-header-sub-title"]}>
|
||||
与 ChatGPT 的 {session.messages.length} 条对话
|
||||
</div>
|
||||
@@ -210,7 +210,7 @@ export function Chat(props: { showSideBar?: () => void }) {
|
||||
bordered
|
||||
title="查看压缩后的历史 Prompt"
|
||||
onClick={() => {
|
||||
showMemoryPrompt(session.memoryPrompt)
|
||||
showMemoryPrompt(session)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@@ -323,12 +323,12 @@ function exportMessages(messages: Message[], topic: string) {
|
||||
})
|
||||
}
|
||||
|
||||
function showMemoryPrompt(prompt: string) {
|
||||
function showMemoryPrompt(session: ChatSession) {
|
||||
showModal({
|
||||
title: "上下文记忆 Prompt", children: <div className="markdown-body">
|
||||
<pre className={styles['export-content']}>{prompt}</pre>
|
||||
title: `上下文记忆 Prompt (${session.lastSummarizeIndex} of ${session.messages.length})`, children: <div className="markdown-body">
|
||||
<pre className={styles['export-content']}>{session.memoryPrompt || '无'}</pre>
|
||||
</div>, actions: [
|
||||
<IconButton key="copy" icon={<CopyIcon />} bordered text="全部复制" onClick={() => copyToClipboard(prompt)} />,
|
||||
<IconButton key="copy" icon={<CopyIcon />} bordered text="全部复制" onClick={() => copyToClipboard(session.memoryPrompt)} />,
|
||||
]
|
||||
})
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@ export function Settings(props: { closeSettings: () => void }) {
|
||||
return (
|
||||
<>
|
||||
<div className={styles["window-header"]}>
|
||||
<div>
|
||||
<div className={styles["window-header-title"]}>设置</div>
|
||||
<div className={styles["window-header-title"]}>
|
||||
<div className={styles["window-header-main-title"]}>设置</div>
|
||||
<div className={styles["window-header-sub-title"]}>设置选项</div>
|
||||
</div>
|
||||
<div className={styles["window-actions"]}>
|
||||
@@ -140,14 +140,14 @@ export function Settings(props: { closeSettings: () => void }) {
|
||||
</List>
|
||||
<List>
|
||||
<ListItem>
|
||||
<div className={styles["settings-title"]}>最大上下文消息数</div>
|
||||
<div className={styles["settings-title"]}>附带历史消息数</div>
|
||||
<input
|
||||
type="range"
|
||||
title={config.historyMessageCount.toString()}
|
||||
value={config.historyMessageCount}
|
||||
min="5"
|
||||
max="20"
|
||||
step="5"
|
||||
min="2"
|
||||
max="25"
|
||||
step="2"
|
||||
onChange={(e) =>
|
||||
updateConfig(
|
||||
(config) =>
|
||||
@@ -157,7 +157,6 @@ export function Settings(props: { closeSettings: () => void }) {
|
||||
></input>
|
||||
</ListItem>
|
||||
|
||||
|
||||
<ListItem>
|
||||
<div className={styles["settings-title"]}>
|
||||
历史消息压缩长度阈值
|
||||
|
@@ -8,18 +8,22 @@
|
||||
}
|
||||
|
||||
.window-header-title {
|
||||
font-size: 20px;
|
||||
font-weight: bolder;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: block;
|
||||
max-width: 50vw;
|
||||
}
|
||||
max-width: calc(100% - 100px);
|
||||
|
||||
.window-header-sub-title {
|
||||
font-size: 14px;
|
||||
margin-top: 5px;
|
||||
.window-header-main-title {
|
||||
font-size: 20px;
|
||||
font-weight: bolder;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: block;
|
||||
max-width: 50vw;
|
||||
}
|
||||
|
||||
.window-header-sub-title {
|
||||
font-size: 14px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.window-actions {
|
||||
@@ -28,4 +32,4 @@
|
||||
|
||||
.window-action-button {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user