Skip to content

Commit 449917b

Browse files
author
ochafik
committed
fix test-chat
1 parent af7391e commit 449917b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

common/chat-parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ std::optional<common_chat_msg_parser::find_regex_result> common_chat_msg_parser:
160160
return std::nullopt;
161161
}
162162
if (m.type == COMMON_REGEX_MATCH_TYPE_PARTIAL) {
163-
incomplete(regex.str());
163+
if (is_partial()) {
164+
incomplete(regex.str());
165+
}
166+
return std::nullopt;
164167
}
165168
auto prelude = input_.substr(pos_, m.groups[0].begin - pos_);
166169
pos_ = m.groups[0].end;

common/chat.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,11 @@ static void common_chat_parse_hermes_2_pro(common_chat_msg_parser & builder) {
14941494
);
14951495

14961496
if (auto res = builder.try_find_regex(open_regex)) {
1497+
if (res->groups[0].begin != 0 && res->groups[4].empty() && res->groups[5].empty()) {
1498+
// The only syntax we allow after the very start is <function=...> or <function name=...>
1499+
builder.add_content(builder.consume_rest());
1500+
return;
1501+
}
14971502
GGML_ASSERT(res->prelude.empty()); // matching at_start
14981503

14991504
const auto & block_start = res->groups[1];

0 commit comments

Comments
 (0)