forked from open-webui/open-webui
feat: export all chats from db
admin only
This commit is contained in:
parent
c4ca46637e
commit
7c2f297c84
4 changed files with 103 additions and 9 deletions
|
@ -54,6 +54,25 @@ async def get_all_user_chats(user=Depends(get_current_user)):
|
|||
]
|
||||
|
||||
|
||||
############################
|
||||
# GetAllChatsInDB
|
||||
############################
|
||||
|
||||
|
||||
@router.get("/all/db", response_model=List[ChatResponse])
|
||||
async def get_all_user_chats_in_db(user=Depends(get_current_user)):
|
||||
if user.role == "admin":
|
||||
return [
|
||||
ChatResponse(**{**chat.model_dump(), "chat": json.loads(chat.chat)})
|
||||
for chat in Chats.get_all_chats()
|
||||
]
|
||||
else:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
|
||||
|
||||
############################
|
||||
# CreateNewChat
|
||||
############################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue