Skip to content

Commit 42937a5

Browse files
authored
refactored changes to follow string tern op
1 parent c6c4f7c commit 42937a5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

common/chat.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,19 +1640,13 @@ static common_chat_params common_chat_params_init_hermes_2_pro(const common_chat
16401640
tool_call_alts.push_back(
16411641
"( \"```\\n\" | \"```json\\n\" | \"```xml\\n\" ) space " + wrappable_tool_call + " space \"```\" space ");
16421642
auto tool_call = builder.add_rule("tool_call", string_join(tool_call_alts, " | "));
1643-
if (supports_thinking)
1644-
{
1643+
if (supports_thinking) {
16451644
builder.add_rule("thinking", "\"<think>\" [^\\x00]* \"</think>\" space");
1646-
builder.add_rule("root",
1647-
"(thinking)? space " +
1648-
(inputs.parallel_tool_calls ? "(" + tool_call + ")+" : tool_call));
16491645
}
1650-
else
1651-
{
1652-
builder.add_rule("root",
1653-
std::string(data.thinking_forced_open ? "( \"</think>\" space )? " : "") +
1646+
builder.add_rule("root",
1647+
std::string(supports_thinking ? "(thinking)? space " :
1648+
data.thinking_forced_open ? "( \"</think>\" space )? " : "") +
16541649
(inputs.parallel_tool_calls ? "(" + tool_call + ")+" : tool_call));
1655-
}
16561650
// Trigger on some common known "good bad" outputs (only from the start and with a json that's about a specific argument name to avoid false positives)
16571651
data.grammar_triggers.push_back({
16581652
COMMON_GRAMMAR_TRIGGER_TYPE_PATTERN_FULL,

0 commit comments

Comments
 (0)