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
d5ed1196
"examples/vscode:/vscode.git/clone" did not exist on "f4f87f468de59fc4ddadb2dd2eaae69a0338eaf5"
Commit
d5ed1196
authored
Jan 18, 2024
by
Timothy J. Baek
Browse files
feat: convo tagging api added
parent
077f1fa3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
4 deletions
+156
-4
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+21
-4
src/lib/apis/chats/index.ts
src/lib/apis/chats/index.ts
+135
-0
No files found.
backend/apps/web/routers/chats.py
View file @
d5ed1196
...
@@ -165,15 +165,32 @@ async def add_chat_tag_by_id(
...
@@ -165,15 +165,32 @@ async def add_chat_tag_by_id(
@
router
.
delete
(
"/{id}/tags"
,
response_model
=
Optional
[
bool
])
@
router
.
delete
(
"/{id}/tags"
,
response_model
=
Optional
[
bool
])
async
def
add
_chat_tag_by_id
(
async
def
delete
_chat_tag_by_id
(
id
:
str
,
form_data
:
ChatIdTagForm
,
user
=
Depends
(
get_current_user
)
id
:
str
,
form_data
:
ChatIdTagForm
,
user
=
Depends
(
get_current_user
)
):
):
tag
=
Tags
.
delete_tag_by_tag_name_and_chat_id_and_user_id
(
result
=
Tags
.
delete_tag_by_tag_name_and_chat_id_and_user_id
(
form_data
.
tag_name
,
id
,
user
.
id
form_data
.
tag_name
,
id
,
user
.
id
)
)
if
tag
:
if
result
:
return
tag
return
result
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
NOT_FOUND
)
############################
# DeleteAllChatTagsById
############################
@
router
.
delete
(
"/{id}/tags/all"
,
response_model
=
Optional
[
bool
])
async
def
delete_all_chat_tags_by_id
(
id
:
str
,
user
=
Depends
(
get_current_user
)):
result
=
Tags
.
delete_tags_by_chat_id_and_user_id
(
id
,
user
.
id
)
if
result
:
return
result
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
NOT_FOUND
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
NOT_FOUND
...
...
src/lib/apis/chats/index.ts
View file @
d5ed1196
...
@@ -192,6 +192,141 @@ export const deleteChatById = async (token: string, id: string) => {
...
@@ -192,6 +192,141 @@ export const deleteChatById = async (token: string, id: string) => {
return
res
;
return
res
;
};
};
export
const
getTagsById
=
async
(
token
:
string
,
id
:
string
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/chats/
${
id
}
/tags`
,
{
method
:
'
GET
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
}
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
then
((
json
)
=>
{
return
json
;
})
.
catch
((
err
)
=>
{
error
=
err
;
console
.
log
(
err
);
return
null
;
});
if
(
error
)
{
throw
error
;
}
return
res
;
};
export
const
addTagById
=
async
(
token
:
string
,
id
:
string
,
tagName
:
string
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/chats/
${
id
}
/tags`
,
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
},
body
:
JSON
.
stringify
({
tag_name
:
tagName
,
chat_id
:
id
})
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
then
((
json
)
=>
{
return
json
;
})
.
catch
((
err
)
=>
{
error
=
err
;
console
.
log
(
err
);
return
null
;
});
if
(
error
)
{
throw
error
;
}
return
res
;
};
export
const
deleteTagById
=
async
(
token
:
string
,
id
:
string
,
tagName
:
string
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/chats/
${
id
}
/tags`
,
{
method
:
'
DELETE
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
},
body
:
JSON
.
stringify
({
tag_name
:
tagName
,
chat_id
:
id
})
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
then
((
json
)
=>
{
return
json
;
})
.
catch
((
err
)
=>
{
error
=
err
;
console
.
log
(
err
);
return
null
;
});
if
(
error
)
{
throw
error
;
}
return
res
;
};
export
const
deleteTagsById
=
async
(
token
:
string
,
id
:
string
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/chats/
${
id
}
/tags/all`
,
{
method
:
'
DELETE
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
}
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
then
((
json
)
=>
{
return
json
;
})
.
catch
((
err
)
=>
{
error
=
err
;
console
.
log
(
err
);
return
null
;
});
if
(
error
)
{
throw
error
;
}
return
res
;
};
export
const
deleteAllChats
=
async
(
token
:
string
)
=>
{
export
const
deleteAllChats
=
async
(
token
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
...
...
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