mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[GH-ISSUE #6925] Filter "body" should have access to "system message" #85276
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @clang88 on GitHub (Nov 13, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/6925
Feature Request
I am trying to build a "token counter" filter for Open WebUI; it works fine, adding the "Tokens" at the end of each System output but removing them from the messages again before sending the message to the LLM.
The issue is: The token count is incorrect, because the "body" object does not seem to contain the system message:

Is your feature request related to a problem? Please describe.
This is particularly important when using RAG, as the context is added into the system message and is therefore not counted by my "token counter" filter.
Describe the solution you'd like
I believe it would be beneficial to also have acces to the system message with the filter, i.e. add the system message to the chain of messages.
Describe alternatives you've considered
Perhaps we should just add a "Token counter" for openAI models as is already present for Ollama models?
@clang88 commented on GitHub (Nov 13, 2024):
This is the code for the filter, btw. I commented out the trick I used to see the body contents.