mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat(sqlalchemy): format backend
This commit is contained in:
@@ -44,9 +44,7 @@ async def get_documents(user=Depends(get_current_user)):
|
||||
|
||||
|
||||
@router.post("/create", response_model=Optional[DocumentResponse])
|
||||
async def create_new_doc(
|
||||
form_data: DocumentForm, user=Depends(get_admin_user)
|
||||
):
|
||||
async def create_new_doc(form_data: DocumentForm, user=Depends(get_admin_user)):
|
||||
doc = Documents.get_doc_by_name(form_data.name)
|
||||
if doc == None:
|
||||
doc = Documents.insert_new_doc(user.id, form_data)
|
||||
@@ -76,9 +74,7 @@ async def create_new_doc(
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
if doc:
|
||||
@@ -110,12 +106,8 @@ class TagDocumentForm(BaseModel):
|
||||
|
||||
|
||||
@router.post("/doc/tags", response_model=Optional[DocumentResponse])
|
||||
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}
|
||||
)
|
||||
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})
|
||||
|
||||
if doc:
|
||||
return DocumentResponse(
|
||||
@@ -163,8 +155,6 @@ async def update_doc_by_name(
|
||||
|
||||
|
||||
@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)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user