Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
1eec1763
Commit
1eec1763
authored
Jan 18, 2024
by
Timothy J. Baek
Browse files
feat: save tags to chat data
parent
987685db
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
3 deletions
+17
-3
backend/apps/web/models/tags.py
backend/apps/web/models/tags.py
+0
-2
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+0
-1
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+9
-0
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+8
-0
No files found.
backend/apps/web/models/tags.py
View file @
1eec1763
...
...
@@ -101,7 +101,6 @@ class TagTable:
if
tag
==
None
:
tag
=
self
.
insert_new_tag
(
form_data
.
tag_name
,
user_id
)
print
(
tag
)
id
=
str
(
uuid
.
uuid4
())
chatIdTag
=
ChatIdTagModel
(
**
{
...
...
@@ -131,7 +130,6 @@ class TagTable:
.
order_by
(
ChatIdTag
.
timestamp
.
desc
())
]
print
(
tag_names
)
return
[
TagModel
(
**
model_to_dict
(
tag
))
for
tag
in
Tag
.
select
().
where
(
Tag
.
name
.
in_
(
tag_names
))
...
...
backend/apps/web/routers/chats.py
View file @
1eec1763
...
...
@@ -134,7 +134,6 @@ async def get_chat_tags_by_id(id: str, user=Depends(get_current_user)):
tags
=
Tags
.
get_tags_by_chat_id_and_user_id
(
id
,
user
.
id
)
if
tags
!=
None
:
print
(
tags
)
return
tags
else
:
raise
HTTPException
(
...
...
src/routes/(app)/+page.svelte
View file @
1eec1763
...
...
@@ -189,6 +189,7 @@
},
messages: messages,
history: history,
tags: [],
timestamp: Date.now()
});
await chats.set(await getChatList(localStorage.token));
...
...
@@ -690,11 +691,19 @@
const addTag = async (tagName) => {
const res = await addTagById(localStorage.token, $chatId, tagName);
tags = await getTags();
chat = await updateChatById(localStorage.token, $chatId, {
tags: tags
});
};
const deleteTag = async (tagName) => {
const res = await deleteTagById(localStorage.token, $chatId, tagName);
tags = await getTags();
chat = await updateChatById(localStorage.token, $chatId, {
tags: tags
});
};
const setChatTitle = async (_chatId, _title) => {
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
1eec1763
...
...
@@ -707,11 +707,19 @@
const addTag = async (tagName) => {
const res = await addTagById(localStorage.token, $chatId, tagName);
tags = await getTags();
chat = await updateChatById(localStorage.token, $chatId, {
tags: tags.map((tag) => tag.name)
});
};
const deleteTag = async (tagName) => {
const res = await deleteTagById(localStorage.token, $chatId, tagName);
tags = await getTags();
chat = await updateChatById(localStorage.token, $chatId, {
tags: tags.map((tag) => tag.name)
});
};
onMount(async () => {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment