Store trimmed text in Content and Thinking nodes
Was checking trim but storing untrimmed. Now stores the trimmed version — no leading/trailing whitespace in the AST. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
01bbc39a31
commit
119dc8c146
1 changed files with 4 additions and 3 deletions
|
|
@ -527,8 +527,8 @@ impl ResponseParser {
|
||||||
self.think_buf.push_str(&self.buf[..end]);
|
self.think_buf.push_str(&self.buf[..end]);
|
||||||
self.buf = self.buf[end + 8..].to_string();
|
self.buf = self.buf[end + 8..].to_string();
|
||||||
self.in_think = false;
|
self.in_think = false;
|
||||||
let text = std::mem::take(&mut self.think_buf);
|
let text = std::mem::take(&mut self.think_buf).trim().to_string();
|
||||||
if !text.trim().is_empty() {
|
if !text.is_empty() {
|
||||||
self.push_child(ctx, AstNode::thinking(text));
|
self.push_child(ctx, AstNode::thinking(text));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -623,7 +623,8 @@ impl ResponseParser {
|
||||||
fn flush_content(&mut self, ctx: &mut ContextState) {
|
fn flush_content(&mut self, ctx: &mut ContextState) {
|
||||||
if !self.content_parts.is_empty() {
|
if !self.content_parts.is_empty() {
|
||||||
let text: String = self.content_parts.drain(..).collect();
|
let text: String = self.content_parts.drain(..).collect();
|
||||||
if !text.trim().is_empty() {
|
let text = text.trim().to_string();
|
||||||
|
if !text.is_empty() {
|
||||||
self.push_child(ctx, AstNode::content(text));
|
self.push_child(ctx, AstNode::content(text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue