fix: clean last message when user clean thread message (#1793)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-01-25 23:14:24 +07:00 committed by GitHub
parent b2ff76ce80
commit 663bf0c902
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,6 +49,14 @@ export default function useDeleteThread() {
threadId,
messages.filter((msg) => msg.role === ChatCompletionRole.System)
)
thread.metadata = {
...thread.metadata,
lastMessage: undefined,
}
await extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.saveThread(thread)
updateThreadLastMessage(threadId, undefined)
}
}