Repository navigation
docs: note that a match can be split across chunks in the filter stre… - #1798
Open
ninadphalak wants to merge 1 commit into
Open
ninadphalak wants to merge 1 commit into
ninadphalak wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Filter page lists "real-time content filtering" and "live word replacement" as uses for the
streamhook, and its example removes a marker withdelta["content"].replace(...).stream()is called once per event, so when the model emits the marker across two chunks, neither call sees it and the text reaches the reader unchanged. This adds a short note under that example that says so, and points to the two options the page already describes: keep per-reply state and hold back a possible match start, or useoutlet(), which sees the whole message but runs after the chunks were delivered.It saves filter authors from finding this out in production, where it shows up as a rule that works most of the time.
Related issue or discussion
None.
Checklist
Notes for reviewers
Checked against open-webui at
926f826(0.13.5):backend/open_webui/utils/middleware.pylines 5014-5026: each SSEdata:line is parsed and passed toprocess_filter_functions(filter_type='stream', form_data=data)on its own. Lines 6709-6716 and 6739-6748 do the same on the direct API path.backend/open_webui/utils/filter.pyline 136: the handler receives that single event asevent.Running the page's own example over the text
Hi [redacted] therecut in two at every position leaves the marker in the output for 10 of the 18 cuts (every cut that falls inside the marker). A version that holds back a possible match start in per-reply state gives the same result as a whole-text replace for all 18 cuts and for one character per chunk.npm run buildpasses with the change (the note links to the existing "Correlating one stream" heading), as donpm run prettier:check,npm run lintandnpm run test:docs-search.