mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-19 05:12:19 +02:00
fix(ui): stop stripping the word assistant from rendered text (#5974)
* fix: stop stripping the word 'assistant' from rendered text The QWEN_BARE_MARKER_RE regex in both the Python backend (tool_parsing.py) and JS frontend (chatRenderer.js) was matching any standalone occurrence of the word 'assistant' separated by any whitespace, then replacing it with a space. This caused normal English uses like 'Home assistant' to render as 'Home '. Fixed by narrowing the word-boundary check from [\t\r\n ] (any whitespace) to [\r\n] (line boundaries only), so only Qwen-format role-token leaks (where 'assistant' appears alone on a line) are stripped. * fix(tests): update bare-marker test expectations for #5971 Move 'x assistant y' from STRIPPED to KEPT (mid-sentence must survive). Add 'Before\nassistant\nAfter' to STRIPPED (bare-marker on own line). * fix(ui): strip whitespace-padded assistant role markers --------- Co-authored-by: samy <samy@users.noreply.github.com> Co-authored-by: Alexandre Teixeira <alexandremagteixeira@gmail.com>
This commit is contained in:
co-authored by
samy
Alexandre Teixeira
parent
bea48c749c
commit
d87a913729
@@ -481,7 +481,7 @@ const QWEN_ROLE_MARKER_RE = /<\/?\|(?:assistant|assistan|user|system|tool)\|>?|<
|
||||
// Keep in sync with _QWEN_BARE_MARKER_RE in src/tool_parsing.py. At least one
|
||||
// pipe is required around `end`: with both optional (`\|?end\|?`) this also ate
|
||||
// a bare `end` on its own line, breaking Ruby/Lua/shell snippets (#5547).
|
||||
const QWEN_BARE_MARKER_RE = /(?:^|[\t\r\n ])(?:\/?\|end\||\|end|end\|)(?=[\t\r\n ]|$)|(?:^|[\t\r\n ])assistan(?:t)?(?=[\t\r\n ]|$)/gi;
|
||||
const QWEN_BARE_MARKER_RE = /(?:^|[\t\r\n ])(?:\/?\|end\||\|end|end\|)(?=[\t\r\n ]|$)|(?:^|[\r\n])[ \t]*assistan(?:t)?[ \t]*(?=[\r\n]|$)/gi;
|
||||
// Self-narration about tool results (model echoing stdout/exit_code)
|
||||
const TOOL_NARRATION_RE = /(?:The (?:result|output) shows?:?\s*)?-?\s*(?:stdout|stderr|exit_code):\s*.+/gi;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user