refac: tagging behaviour

This commit is contained in:
Timothy J. Baek
2024-10-21 01:30:22 -07:00
parent 8d71323009
commit fc6dc43a19
2 changed files with 13 additions and 6 deletions

View File

@@ -49,6 +49,8 @@
import {
addTagById,
createNewChat,
deleteTagById,
deleteTagsById,
getAllTags,
getChatById,
getChatList,
@@ -1912,6 +1914,14 @@
const setChatTags = async (messages) => {
if (!$temporaryChatEnabled) {
const currentTags = await getTagsById(localStorage.token, $chatId);
if (currentTags.length > 0) {
const res = await deleteTagsById(localStorage.token, $chatId);
if (res) {
allTags.set(await getAllTags(localStorage.token));
}
}
let generatedTags = await generateTags(
localStorage.token,
selectedModels[0],
@@ -1922,7 +1932,6 @@
return [];
});
const currentTags = await getTagsById(localStorage.token, $chatId);
generatedTags = generatedTags.filter(
(tag) => !currentTags.find((t) => t.id === tag.replaceAll(' ', '_').toLowerCase())
);