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
facb6edf
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "683650ec00f6f619de4fb31ba687da783de499ec"
Commit
facb6edf
authored
May 03, 2024
by
Timothy J. Baek
Browse files
refac: chat tags
parent
e8085f80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+13
-4
src/lib/apis/chats/index.ts
src/lib/apis/chats/index.ts
+6
-3
No files found.
backend/apps/web/routers/chats.py
View file @
facb6edf
...
@@ -321,19 +321,28 @@ async def get_all_tags(user=Depends(get_current_user)):
...
@@ -321,19 +321,28 @@ async def get_all_tags(user=Depends(get_current_user)):
############################
############################
@
router
.
get
(
"/tags/tag/{tag_name}"
,
response_model
=
List
[
ChatTitleIdResponse
])
class
TagNameForm
(
BaseModel
):
name
:
str
@
router
.
post
(
"/tags"
,
response_model
=
List
[
ChatTitleIdResponse
])
async
def
get_user_chat_list_by_tag_name
(
async
def
get_user_chat_list_by_tag_name
(
tag_name
:
str
,
user
=
Depends
(
get_current_user
),
skip
:
int
=
0
,
limit
:
int
=
50
form_data
:
TagNameForm
,
user
=
Depends
(
get_current_user
),
skip
:
int
=
0
,
limit
:
int
=
50
,
):
):
chat_ids
=
[
chat_ids
=
[
chat_id_tag
.
chat_id
chat_id_tag
.
chat_id
for
chat_id_tag
in
Tags
.
get_chat_ids_by_tag_name_and_user_id
(
tag_name
,
user
.
id
)
for
chat_id_tag
in
Tags
.
get_chat_ids_by_tag_name_and_user_id
(
form_data
.
name
,
user
.
id
)
]
]
chats
=
Chats
.
get_chat_list_by_chat_ids
(
chat_ids
,
skip
,
limit
)
chats
=
Chats
.
get_chat_list_by_chat_ids
(
chat_ids
,
skip
,
limit
)
if
len
(
chats
)
==
0
:
if
len
(
chats
)
==
0
:
Tags
.
delete_tag_by_tag_name_and_user_id
(
tag_
name
,
user
.
id
)
Tags
.
delete_tag_by_tag_name_and_user_id
(
form_data
.
name
,
user
.
id
)
return
chats
return
chats
...
...
src/lib/apis/chats/index.ts
View file @
facb6edf
...
@@ -220,13 +220,16 @@ export const getAllChatTags = async (token: string) => {
...
@@ -220,13 +220,16 @@ export const getAllChatTags = async (token: string) => {
export
const
getChatListByTagName
=
async
(
token
:
string
=
''
,
tagName
:
string
)
=>
{
export
const
getChatListByTagName
=
async
(
token
:
string
=
''
,
tagName
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/chats/tags
/tag/
${
tagName
}
`
,
{
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/chats/tags`
,
{
method
:
'
GE
T
'
,
method
:
'
POS
T
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
}
},
body
:
JSON
.
stringify
({
name
:
tagName
})
})
})
.
then
(
async
(
res
)
=>
{
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
if
(
!
res
.
ok
)
throw
await
res
.
json
();
...
...
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