Skip to content

Commit a1587bb

Browse files
committed
loosen up the regex and grammar around tool calls
1 parent bfbce41 commit a1587bb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

common/chat.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static common_chat_params common_chat_params_init_gpt_oss(const common_chat_temp
13261326
builder.resolve_refs(parameters);
13271327

13281328
tool_rules.push_back(builder.add_rule(name + "-call",
1329-
"\"" + name + "\"" + " space? \"<|constrain|>json<|message|>\" " + builder.add_schema(name + "-args", parameters)
1329+
"\"" + name + "\"" + " space* \"<|constrain|>\"? \"json<|message|>\" " + builder.add_schema(name + "-args", parameters)
13301330
));
13311331
});
13321332

@@ -1343,6 +1343,7 @@ static common_chat_params common_chat_params_init_gpt_oss(const common_chat_temp
13431343
"<|constrain|>",
13441344
"<|message|>",
13451345
"<|start|>",
1346+
"<|end|>",
13461347
};
13471348
});
13481349
}
@@ -1358,7 +1359,7 @@ static void common_chat_parse_gpt_oss(common_chat_msg_parser & builder) {
13581359
static const common_regex to_regex(" to=");
13591360
static const common_regex channel_type_regexp("(final|analysis|commentary)");
13601361
static const common_regex user_tool_call_regex(
1361-
"functions\\.([a-zA-Z_][a-zA-Z0-9_]*)\\s?(?:<\\|constrain\\|>([a-zA-Z]+))?<\\|message\\|>"
1362+
"functions\\.([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?:(?:<\\|constrain\\|>)?([a-zA-Z]+))?\\s*<\\|message\\|>"
13621363
);
13631364
static const common_regex builtin_tool_call_regex("(?:browser|python)[\\s\\S]*<\\|message\\|>");
13641365

0 commit comments

Comments
 (0)