From b7b4f3bc8e23a1792fe29f1e98329eb5be62e596 Mon Sep 17 00:00:00 2001 From: skymkmk Date: Fri, 13 Sep 2024 21:09:03 +0800 Subject: [PATCH] feat: manual refresh for title --- app/components/chat.tsx | 12 ++++++++++++ app/store/chat.ts | 26 ++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index dafb98464219..bd411826f0dc 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -43,6 +43,7 @@ import QualityIcon from "../icons/hd.svg"; import StyleIcon from "../icons/palette.svg"; import PluginIcon from "../icons/plugin.svg"; import ShortcutkeyIcon from "../icons/shortcutkey.svg"; +import ReloadIcon from "../icons/reload.svg"; import { ChatMessage, @@ -1541,6 +1542,17 @@ function _Chat() {
+
+ } + bordered + title={Locale.Chat.Actions.RefreshTitle} + onClick={() => { + showToast(Locale.Chat.Actions.RefreshToast); + chatStore.summarizeSession(true); + }} + /> +
{!isMobileScreen && (
= SUMMARIZE_MIN_LEN + (config.enableAutoGenerateTitle && + session.topic === DEFAULT_TOPIC && + countMessages(messages) >= SUMMARIZE_MIN_LEN) || + refreshTitle ) { - const topicMessages = messages.concat( - createMessage({ - role: "user", - content: Locale.Store.Prompt.Topic, - }), - ); + const topicMessages = messages + .slice( + messages.length - modelConfig.historyMessageCount, + messages.length, + ) + .concat( + createMessage({ + role: "user", + content: Locale.Store.Prompt.Topic, + }), + ); api.llm.chat({ messages: topicMessages, config: {