[PR #3464] [CLOSED] feat: reduce document selection overhead #8044

Closed
opened 2025-11-11 17:43:35 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/3464
Author: @jonathan-rohde
Created: 6/27/2024
Status: Closed

Base: devHead: feat/reduce-document-selection-overhead


📝 Commits (3)

  • 954622b feat(chat): Reduce request size to attach file to chat
  • 3925e78 feat(chat): formatting
  • 4d681ec feat(chat): rebase changes

📊 Changes

6 files changed (+82 additions, -21 deletions)

View changed files

📝 backend/apps/rag/utils.py (+17 -5)
📝 backend/apps/webui/models/documents.py (+9 -0)
📝 src/lib/components/chat/Chat.svelte (+12 -4)
📝 src/lib/components/chat/MessageInput.svelte (+1 -1)
📝 src/lib/components/chat/MessageInput/Documents.svelte (+13 -10)
📝 src/lib/components/chat/Messages/UserMessage.svelte (+30 -1)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • Each document that is part of the chat is stored within the chat data and is part of each chat completion request
  • With this change this overhead is reduced
  • For queries with all documents, the collection names are extracted in the backend
  • For queries with tags, the collection names are extracted in the backend
  • No change for single file selection
  • Benefit: Much faster request/response handling. Please see the screenshots of before and after.

Changed

  • Reduce the request size and chat history storage size by removing the file checksums from the request

Additional Information

  • Example with 10,000 documents
  • Browser used: Google Chrome
  • Environment: Localhost on MacOS
  • Headers before the change. Request size is 88785. Also the UI was a bit lagging around with computing the payload
    headers-before

  • Headers after the change. Request size is just 237. UI is very usable
    headers-after

  • Payload before the change. Quite a long list of checksum in payload
    payload-before

  • Payload after the change. Just the collection type is required
    payload-after

  • Timing before the change. Processing the request took 35s
    timing-before

  • Timing after the change. Processing the request took 8s. Side note: I did also a prove of concept by using just one single collection in ChromaDB and got the request down to under a second (after filling some caches, which is not possible storing it in different collections)
    timing-after

Script used to create the files

for i in {1..100000}
do
echo "Test file $i" > files/"test-$i.txt"
done


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/3464 **Author:** [@jonathan-rohde](https://github.com/jonathan-rohde) **Created:** 6/27/2024 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat/reduce-document-selection-overhead` --- ### 📝 Commits (3) - [`954622b`](https://github.com/open-webui/open-webui/commit/954622b3c7aabf82923a7d9440b6ace3cf5b0b07) feat(chat): Reduce request size to attach file to chat - [`3925e78`](https://github.com/open-webui/open-webui/commit/3925e78024d91b050885c450823b0ccba5a7fff1) feat(chat): formatting - [`4d681ec`](https://github.com/open-webui/open-webui/commit/4d681ece5dbbc192d01b7123d20fa45072e3a1ba) feat(chat): rebase changes ### 📊 Changes **6 files changed** (+82 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `backend/apps/rag/utils.py` (+17 -5) 📝 `backend/apps/webui/models/documents.py` (+9 -0) 📝 `src/lib/components/chat/Chat.svelte` (+12 -4) 📝 `src/lib/components/chat/MessageInput.svelte` (+1 -1) 📝 `src/lib/components/chat/MessageInput/Documents.svelte` (+13 -10) 📝 `src/lib/components/chat/Messages/UserMessage.svelte` (+30 -1) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [ ] **Testing:** Have you written and run sufficient tests for validating the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - Each document that is part of the chat is stored within the chat data and is part of each chat completion request - With this change this overhead is reduced - For queries with all documents, the collection names are extracted in the backend - For queries with tags, the collection names are extracted in the backend - No change for single file selection - Benefit: Much faster request/response handling. Please see the screenshots of before and after. ### Changed - Reduce the request size and chat history storage size by removing the file checksums from the request --- ### Additional Information - *Example with 10,000 documents* - Browser used: Google Chrome - Environment: Localhost on MacOS * Headers before the change. Request size is 88785. Also the UI was a bit lagging around with computing the payload ![headers-before](https://github.com/open-webui/open-webui/assets/165899591/22b669f8-218b-403f-a196-9bc2007b007b) * Headers after the change. Request size is just 237. UI is very usable ![headers-after](https://github.com/open-webui/open-webui/assets/165899591/cbecc097-4afa-488b-8b3b-1dfdaf025404) * Payload before the change. Quite a long list of checksum in payload ![payload-before](https://github.com/open-webui/open-webui/assets/165899591/e22a20fb-6b69-4ac5-80eb-f2422dd3150b) * Payload after the change. Just the collection type is required ![payload-after](https://github.com/open-webui/open-webui/assets/165899591/863c9831-048e-446b-98c2-d90e2833aa92) * Timing before the change. Processing the request took 35s ![timing-before](https://github.com/open-webui/open-webui/assets/165899591/78af2eec-afed-445c-afdd-047fe47de51f) * Timing after the change. Processing the request took 8s. Side note: I did also a prove of concept by using just one single collection in ChromaDB and got the request down to under a second (after filling some caches, which is not possible storing it in different collections) ![timing-after](https://github.com/open-webui/open-webui/assets/165899591/1a11deff-1c67-47c2-9c51-0fc466c06460) ### Script used to create the files ``` for i in {1..100000} do echo "Test file $i" > files/"test-$i.txt" done ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 17:43:35 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#8044