Skip to content

Commit

Permalink
feat: added topic auto-renaming to messages page
Browse files Browse the repository at this point in the history
  • Loading branch information
kangfenmao committed Dec 3, 2024
1 parent 12d8f57 commit 6596497
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/renderer/src/pages/home/Messages/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ const Messages: FC<Props> = ({ assistant, topic, setActiveTopic }) => {
)

const autoRenameTopic = useCallback(async () => {
const _topic = getTopic(assistant, topic.id)

// If the topic auto naming is not enabled, use the first message content as the topic name
if (!enableTopicNaming) {
const topicName = messages[0].content.substring(0, 50)
const data = { ..._topic, name: topicName } as Topic
setActiveTopic(data)
updateTopic(data)
return
}

const _topic = getTopic(assistant, topic.id)

// Auto rename the topic
if (_topic && _topic.name === t('chat.default.topic.name') && messages.length >= 2) {
const summaryText = await fetchMessagesSummary({ messages, assistant })
if (summaryText) {
Expand Down

0 comments on commit 6596497

Please sign in to comment.