feat: support compress chat history

This commit is contained in:
Yifei Zhang
2023-03-19 15:13:10 +00:00
parent 9398b34b5c
commit c133cae04b
6 changed files with 125 additions and 24 deletions

View File

@@ -208,7 +208,10 @@ export function Chat(props: { showSideBar?: () => void }) {
<IconButton
icon={<BrainIcon />}
bordered
title="查看压缩后的历史 Prompt(开发中)"
title="查看压缩后的历史 Prompt"
onClick={() => {
showMemoryPrompt(session.memoryPrompt)
}}
/>
</div>
<div className={styles["window-action-button"]}>
@@ -320,6 +323,16 @@ function exportMessages(messages: Message[], topic: string) {
})
}
function showMemoryPrompt(prompt: string) {
showModal({
title: "上下文记忆 Prompt", children: <div className="markdown-body">
<pre className={styles['export-content']}>{prompt}</pre>
</div>, actions: [
<IconButton key="copy" icon={<CopyIcon />} bordered text="全部复制" onClick={() => copyToClipboard(prompt)} />,
]
})
}
export function Home() {
const [createNewSession] = useChatStore((state) => [state.newSession]);
const loading = !useChatStore?.persist?.hasHydrated();