fix(web): exclude <think> reasoning blocks from copied answer (#18371)

This commit is contained in:
chanx
2026-08-17 17:00:35 +08:00
committed by GitHub
parent 1ef4ddddec
commit 6f0fff5b77
3 changed files with 19 additions and 4 deletions

View File

@@ -108,6 +108,15 @@ export function replaceThinkToSection(
return result;
}
// Strip <think> reasoning blocks so only the answer text remains.
// The second replace handles a streaming message whose block is still unclosed.
export function removeThinkSection(text: string = '') {
return text
.replace(/<think>[\s\S]*?<\/think>/g, '')
.replace(/<think>[\s\S]*$/, '')
.trim();
}
export function replaceRetrievingToSection(text: string = '') {
const pattern = /<retrieving>([\s\S]*?)<\/retrieving>/g;