Sending same embedding file (rag) multiple times increases token usage #2150

Closed
opened 2025-11-11 15:01:13 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @bgeneto on GitHub (Sep 21, 2024).

Bug Report

Installation Method

Docker

Environment

  • Open WebUI Version: v0.3.23

  • Ollama (if applicable): n/a

  • Operating System: Debian 12 6.1

  • Browser (if applicable): Edge v129

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior

The system should only send or stream each file or collection (RAG embedding) once in a chat. To achieve this, a function should be implemented to analyze and preprocess the files and retain only one instance of each unique collection_name. This is crucial as sending duplicate collection_name entries significantly increases the input token count, resulting in substantial cost implications.

Actual Behavior

The current system sends the same file or collection (RAG embedding) multiple times, effectively doubling (or even tripling) the actual number of input tokens.

Description

Bug Summary

A bug has been identified where selecting a document or collection using the '#' character in a chat, followed by one or more consecutive questions about the context, results in the same document or collection being listed or sent multiple times in the input body. This is demonstrated in the example below, where the same filename appears twice.

{'stream': True, 'model': 'gpt-4o-mini', 'stream_options': {'include_usage': True}, 'messages': [{'role': 'user', 'content': 'what is pipelines according to context only?'}], 'temperature': 0.15, 'files': [{'type': 'file', 'collection_name': 'c0aabf58356294a210c649fbb22c599f50530928a02955fbd082fb000f6ccff', 'name': 'pipelinestutorial', 'title': 'open-webui-pipelines-tutorial', 'filename': 'open-webui-pipelines-tutorial.txt', 'content': {'tags': [{'name': 'open-webui'}]}, 'user_id': '01503731-0a49-4033-bdc0-8c1bc3b75fd6', 'timestamp': 1726908132, 'status': 'processed'}, {'type': 'file', 'collection_name': 'c0aabf58356294a210c649fbb22c599f50530928a02955fbd082fb000f6ccff', 'name': 'pipelinestutorial', 'title': 'open-webui-pipelines-tutorial', 'filename': 'open-webui-pipelines-tutorial.txt', 'content': {'tags': [{'name': 'open-webui'}]}, 'user_id': '01503731-0a49-4033-bdc0-8c1bc3b75fd6', 'timestamp': 1726908132, 'status': 'processed'}], 'session_id': 'uLGPka0fPoIniChP000b', 'chat_id': '4f93c8bc-e088-480e-bf3d-77ef929e9b3a', 'id': 'cae24965-ea47-4c96-bcd0-72b34984b733'}

Reproduction Details

Steps to Reproduce:

Just select a document/collection using the '#' char in a chat and then ask one or more consecutive questions about the context. Inspect the inlet/body contents to confirm duplication.

Logs and Screenshots

Browser Console Logs:
None

Docker Container Logs:
None

Screenshots/Screen Recordings (if applicable):
None

Additional Information

None

Note

If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!

Originally created by @bgeneto on GitHub (Sep 21, 2024). # Bug Report ## Installation Method Docker ## Environment - **Open WebUI Version:** v0.3.23 - **Ollama (if applicable):** n/a - **Operating System:** Debian 12 6.1 - **Browser (if applicable):** Edge v129 **Confirmation:** - [x] I have read and followed all the instructions provided in the README.md. - [x] I am on the latest version of both Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior The system should only send or stream each file or collection (RAG embedding) once in a chat. To achieve this, a function should be implemented to analyze and preprocess the `files` and retain only one instance of each unique `collection_name`. This is crucial as sending duplicate `collection_name` entries significantly increases the input token count, resulting in substantial cost implications. ## Actual Behavior The current system sends the same file or collection (RAG embedding) multiple times, effectively doubling (or even tripling) the actual number of input tokens. ## Description **Bug Summary** A bug has been identified where selecting a document or collection using the '#' character in a chat, followed by one or more consecutive questions about the context, results in the same document or collection being listed or sent multiple times in the input body. This is demonstrated in the example below, where the same filename appears twice. ``` {'stream': True, 'model': 'gpt-4o-mini', 'stream_options': {'include_usage': True}, 'messages': [{'role': 'user', 'content': 'what is pipelines according to context only?'}], 'temperature': 0.15, 'files': [{'type': 'file', 'collection_name': 'c0aabf58356294a210c649fbb22c599f50530928a02955fbd082fb000f6ccff', 'name': 'pipelinestutorial', 'title': 'open-webui-pipelines-tutorial', 'filename': 'open-webui-pipelines-tutorial.txt', 'content': {'tags': [{'name': 'open-webui'}]}, 'user_id': '01503731-0a49-4033-bdc0-8c1bc3b75fd6', 'timestamp': 1726908132, 'status': 'processed'}, {'type': 'file', 'collection_name': 'c0aabf58356294a210c649fbb22c599f50530928a02955fbd082fb000f6ccff', 'name': 'pipelinestutorial', 'title': 'open-webui-pipelines-tutorial', 'filename': 'open-webui-pipelines-tutorial.txt', 'content': {'tags': [{'name': 'open-webui'}]}, 'user_id': '01503731-0a49-4033-bdc0-8c1bc3b75fd6', 'timestamp': 1726908132, 'status': 'processed'}], 'session_id': 'uLGPka0fPoIniChP000b', 'chat_id': '4f93c8bc-e088-480e-bf3d-77ef929e9b3a', 'id': 'cae24965-ea47-4c96-bcd0-72b34984b733'} ``` ## Reproduction Details **Steps to Reproduce:** Just select a document/collection using the '#' char in a chat and then ask one or more consecutive questions about the context. Inspect the inlet/body contents to confirm duplication. ## Logs and Screenshots **Browser Console Logs:** None **Docker Container Logs:** None **Screenshots/Screen Recordings (if applicable):** None ## Additional Information None ## Note If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#2150