Skip to content

Commit abeccc4

Browse files
committed
fix: fixed the conflict BUG between model thinking mode and line break parsing.
Co-authored-by: MrrDrr l.tingting@pku.edu.cn Co-authored-by: NakanoMiku39 jinleho@hotmail.com
1 parent 995bef7 commit abeccc4

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

app/utils/chat.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -624,19 +624,13 @@ export function streamWithThink(
624624
if (!isInThinkingMode || isThinkingChanged) {
625625
// If this is a new thinking block or mode changed, add prefix
626626
isInThinkingMode = true;
627-
if (remainText.length > 0) {
627+
if (remainText.length > 0 && !remainText.endsWith("\n")) {
628628
remainText += "\n";
629629
}
630-
remainText += "> " + chunk.content;
631-
} else {
632-
// Handle newlines in thinking content
633-
if (chunk.content.includes("\n\n")) {
634-
const lines = chunk.content.split("\n\n");
635-
remainText += lines.join("\n\n> ");
636-
} else {
637-
remainText += chunk.content;
638-
}
630+
remainText += "> ";
639631
}
632+
// Append content, ensuring newlines are quoted
633+
remainText += chunk.content.replace(/\n/g, "\n> ");
640634
} else {
641635
// If in normal mode
642636
if (isInThinkingMode || isThinkingChanged) {

0 commit comments

Comments
 (0)