mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
perf: skip token parsing when raw content is unchanged (#22183)
This commit is contained in:
parent
47b007ef19
commit
a25ecfa856
1 changed files with 10 additions and 1 deletions
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
let tokens = [];
|
||||
let pendingUpdate = null;
|
||||
let lastContent = '';
|
||||
let lastParsedContent = '';
|
||||
|
||||
const options = {
|
||||
throwOnError: false,
|
||||
|
|
@ -56,7 +58,14 @@
|
|||
});
|
||||
|
||||
const parseTokens = () => {
|
||||
tokens = marked.lexer(replaceTokens(processResponseContent(content), model?.name, $user?.name));
|
||||
if (content === lastContent) return;
|
||||
lastContent = content;
|
||||
|
||||
const processed = replaceTokens(processResponseContent(content), model?.name, $user?.name);
|
||||
if (processed === lastParsedContent) return;
|
||||
lastParsedContent = processed;
|
||||
|
||||
tokens = marked.lexer(processed);
|
||||
};
|
||||
|
||||
const updateHandler = (content) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue