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
a382e82d
Unverified
Commit
a382e82d
authored
Jun 12, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jun 12, 2024
Browse files
Merge pull request #3105 from open-webui/dev
fix/refac: docs
parents
c0a06f7d
bdd2ac00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
backend/apps/webui/routers/documents.py
backend/apps/webui/routers/documents.py
+4
-4
src/lib/apis/documents/index.ts
src/lib/apis/documents/index.ts
+16
-4
No files found.
backend/apps/webui/routers/documents.py
View file @
a382e82d
...
@@ -73,7 +73,7 @@ async def create_new_doc(form_data: DocumentForm, user=Depends(get_admin_user)):
...
@@ -73,7 +73,7 @@ async def create_new_doc(form_data: DocumentForm, user=Depends(get_admin_user)):
############################
############################
@
router
.
get
(
"/
name/{name}
"
,
response_model
=
Optional
[
DocumentResponse
])
@
router
.
get
(
"/
doc
"
,
response_model
=
Optional
[
DocumentResponse
])
async
def
get_doc_by_name
(
name
:
str
,
user
=
Depends
(
get_current_user
)):
async
def
get_doc_by_name
(
name
:
str
,
user
=
Depends
(
get_current_user
)):
doc
=
Documents
.
get_doc_by_name
(
name
)
doc
=
Documents
.
get_doc_by_name
(
name
)
...
@@ -105,7 +105,7 @@ class TagDocumentForm(BaseModel):
...
@@ -105,7 +105,7 @@ class TagDocumentForm(BaseModel):
tags
:
List
[
dict
]
tags
:
List
[
dict
]
@
router
.
post
(
"/
name/{name}
/tags"
,
response_model
=
Optional
[
DocumentResponse
])
@
router
.
post
(
"/
doc
/tags"
,
response_model
=
Optional
[
DocumentResponse
])
async
def
tag_doc_by_name
(
form_data
:
TagDocumentForm
,
user
=
Depends
(
get_current_user
)):
async
def
tag_doc_by_name
(
form_data
:
TagDocumentForm
,
user
=
Depends
(
get_current_user
)):
doc
=
Documents
.
update_doc_content_by_name
(
form_data
.
name
,
{
"tags"
:
form_data
.
tags
})
doc
=
Documents
.
update_doc_content_by_name
(
form_data
.
name
,
{
"tags"
:
form_data
.
tags
})
...
@@ -128,7 +128,7 @@ async def tag_doc_by_name(form_data: TagDocumentForm, user=Depends(get_current_u
...
@@ -128,7 +128,7 @@ async def tag_doc_by_name(form_data: TagDocumentForm, user=Depends(get_current_u
############################
############################
@
router
.
post
(
"/
name/{name}
/update"
,
response_model
=
Optional
[
DocumentResponse
])
@
router
.
post
(
"/
doc
/update"
,
response_model
=
Optional
[
DocumentResponse
])
async
def
update_doc_by_name
(
async
def
update_doc_by_name
(
name
:
str
,
form_data
:
DocumentUpdateForm
,
user
=
Depends
(
get_admin_user
)
name
:
str
,
form_data
:
DocumentUpdateForm
,
user
=
Depends
(
get_admin_user
)
):
):
...
@@ -152,7 +152,7 @@ async def update_doc_by_name(
...
@@ -152,7 +152,7 @@ async def update_doc_by_name(
############################
############################
@
router
.
delete
(
"/
name/{name}
/delete"
,
response_model
=
bool
)
@
router
.
delete
(
"/
doc
/delete"
,
response_model
=
bool
)
async
def
delete_doc_by_name
(
name
:
str
,
user
=
Depends
(
get_admin_user
)):
async
def
delete_doc_by_name
(
name
:
str
,
user
=
Depends
(
get_admin_user
)):
result
=
Documents
.
delete_doc_by_name
(
name
)
result
=
Documents
.
delete_doc_by_name
(
name
)
return
result
return
result
src/lib/apis/documents/index.ts
View file @
a382e82d
...
@@ -76,7 +76,10 @@ export const getDocs = async (token: string = '') => {
...
@@ -76,7 +76,10 @@ export const getDocs = async (token: string = '') => {
export
const
getDocByName
=
async
(
token
:
string
,
name
:
string
)
=>
{
export
const
getDocByName
=
async
(
token
:
string
,
name
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/name/
${
name
}
`
,
{
const
searchParams
=
new
URLSearchParams
();
searchParams
.
append
(
'
name
'
,
name
);
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/docs?
${
searchParams
.
toString
()}
`
,
{
method
:
'
GET
'
,
method
:
'
GET
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
...
@@ -113,7 +116,10 @@ type DocUpdateForm = {
...
@@ -113,7 +116,10 @@ type DocUpdateForm = {
export
const
updateDocByName
=
async
(
token
:
string
,
name
:
string
,
form
:
DocUpdateForm
)
=>
{
export
const
updateDocByName
=
async
(
token
:
string
,
name
:
string
,
form
:
DocUpdateForm
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/name/
${
name
}
/update`
,
{
const
searchParams
=
new
URLSearchParams
();
searchParams
.
append
(
'
name
'
,
name
);
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/doc/update?
${
searchParams
.
toString
()}
`
,
{
method
:
'
POST
'
,
method
:
'
POST
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
...
@@ -154,7 +160,10 @@ type TagDocForm = {
...
@@ -154,7 +160,10 @@ type TagDocForm = {
export
const
tagDocByName
=
async
(
token
:
string
,
name
:
string
,
form
:
TagDocForm
)
=>
{
export
const
tagDocByName
=
async
(
token
:
string
,
name
:
string
,
form
:
TagDocForm
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/name/
${
name
}
/tags`
,
{
const
searchParams
=
new
URLSearchParams
();
searchParams
.
append
(
'
name
'
,
name
);
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/doc/tags?
${
searchParams
.
toString
()}
`
,
{
method
:
'
POST
'
,
method
:
'
POST
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/json
'
,
...
@@ -190,7 +199,10 @@ export const tagDocByName = async (token: string, name: string, form: TagDocForm
...
@@ -190,7 +199,10 @@ export const tagDocByName = async (token: string, name: string, form: TagDocForm
export
const
deleteDocByName
=
async
(
token
:
string
,
name
:
string
)
=>
{
export
const
deleteDocByName
=
async
(
token
:
string
,
name
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/name/
${
name
}
/delete`
,
{
const
searchParams
=
new
URLSearchParams
();
searchParams
.
append
(
'
name
'
,
name
);
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/documents/doc/delete?
${
searchParams
.
toString
()}
`
,
{
method
:
'
DELETE
'
,
method
:
'
DELETE
'
,
headers
:
{
headers
:
{
Accept
:
'
application/json
'
,
Accept
:
'
application/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