From 6d5cb6b04ee188e644fc71a5e3fcbdc90dcf181a Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:02:24 -0400 Subject: [PATCH 1/4] Add query param to remove content from GET /api/v1/files --- backend/open_webui/routers/files.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index 22e1269e37..b7d64748b1 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -162,11 +162,15 @@ def upload_file( @router.get("/", response_model=list[FileModelResponse]) -async def list_files(user=Depends(get_verified_user)): +async def list_files(user=Depends(get_verified_user), content: bool = Query(True)): if user.role == "admin": files = Files.get_files() else: files = Files.get_files_by_user_id(user.id) + + if not content: + for file in files: + file.data['content'] = "" return files From 138e985d6631a52b19b983c3a8f597549cde9471 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Fri, 4 Apr 2025 08:38:24 -0400 Subject: [PATCH 2/4] Rename field to include_content --- backend/open_webui/routers/files.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index b7d64748b1..d876182f76 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -162,13 +162,13 @@ def upload_file( @router.get("/", response_model=list[FileModelResponse]) -async def list_files(user=Depends(get_verified_user), content: bool = Query(True)): +async def list_files(user=Depends(get_verified_user), include_content: bool = Query(True)): if user.role == "admin": files = Files.get_files() else: files = Files.get_files_by_user_id(user.id) - if not content: + if not include_content: for file in files: file.data['content'] = "" return files From ff1d454bddaf6ea33f8d6e51c47a73cdd7bc553e Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sun, 6 Apr 2025 13:32:51 -0400 Subject: [PATCH 3/4] Fix formatting --- backend/open_webui/routers/files.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index d876182f76..bfdb2be6a5 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -162,7 +162,9 @@ def upload_file( @router.get("/", response_model=list[FileModelResponse]) -async def list_files(user=Depends(get_verified_user), include_content: bool = Query(True)): +async def list_files( + user=Depends(get_verified_user), include_content: bool = Query(True) +): if user.role == "admin": files = Files.get_files() else: @@ -170,7 +172,7 @@ async def list_files(user=Depends(get_verified_user), include_content: bool = Qu if not include_content: for file in files: - file.data['content'] = "" + file.data["content"] = "" return files From 94453839bab0d4d39e807da4283717411715d0f2 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sun, 6 Apr 2025 16:02:16 -0400 Subject: [PATCH 4/4] Update index.ts