Skip to content

Commit 4dcd653

Browse files
author
ochafik
committed
strip reasoning (now that tags are strings and not regexes)
1 parent fbba5da commit 4dcd653

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

common/chat-parser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,18 @@ void common_chat_msg_parser::consume_literal(const std::string & literal) {
129129

130130
bool common_chat_msg_parser::try_parse_reasoning(const std::string & start_think, const std::string & end_think) {
131131
auto handle_reasoning = [&](const std::string & reasoning, bool closed) {
132-
if (reasoning.empty()) {
132+
auto stripped_reasoning = string_strip(reasoning);
133+
if (stripped_reasoning.empty()) {
133134
return;
134135
}
135136
if (syntax_.reasoning_in_content) {
136137
add_content(syntax_.reasoning_format == COMMON_REASONING_FORMAT_DEEPSEEK ? "<think>" : start_think);
137-
add_content(reasoning);
138+
add_content(stripped_reasoning);
138139
if (closed) {
139140
add_content(syntax_.reasoning_format == COMMON_REASONING_FORMAT_DEEPSEEK ? "</think>" : end_think);
140141
}
141142
} else {
142-
add_reasoning_content(reasoning);
143+
add_reasoning_content(stripped_reasoning);
143144
}
144145
};
145146
if (syntax_.reasoning_format != COMMON_REASONING_FORMAT_NONE) {

0 commit comments

Comments
 (0)