Skip to content

Commit d4fc654

Browse files
committed
condense builtin tool call regex
1 parent 1776dd7 commit d4fc654

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

common/chat.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,7 @@ static void common_chat_parse_gpt_oss(common_chat_msg_parser & builder) {
13621362
static const common_regex user_tool_call_regex(
13631363
"functions\\.([a-zA-Z_][a-zA-Z0-9_]*)\\s?(?:<\\|constrain\\|>([a-zA-Z]+))?<\\|message\\|>"
13641364
);
1365-
static const common_regex browser_tool_call_regex("browser\\.(search|open|find)[\\s\\S]*<\\|message\\|>");
1366-
static const common_regex python_tool_call_regex("python\\s?(?:code)?<\\|message\\|>");
1365+
static const common_regex builtin_tool_call_regex("(?:browser|python)[\\s\\S]*<\\|message\\|>");
13671366

13681367
auto consume_until_start = [&]() {
13691368
if (auto res = builder.try_find_regex(start_regex, std::string::npos, false)) {
@@ -1379,7 +1378,7 @@ static void common_chat_parse_gpt_oss(common_chat_msg_parser & builder) {
13791378
auto name = builder.str(res->groups[1]);
13801379
auto args = builder.consume_rest();
13811380
builder.add_tool_call(name, "", args);
1382-
} else if (builder.try_consume_regex(browser_tool_call_regex) || builder.try_consume_regex(python_tool_call_regex)) {
1381+
} else if (builder.try_consume_regex(builtin_tool_call_regex)) {
13831382
builder.consume_rest();
13841383
LOG_ERR("builtin tool calls not implemented");
13851384
} else {

0 commit comments

Comments
 (0)