Update test-tool-call.cpp

This commit is contained in:
ochafik 2024-10-22 10:54:48 +01:00
parent 9f5ab97756
commit b53362a148

View file

@ -134,18 +134,29 @@ static void test_parsing() {
{"tools", tools} {"tools", tools}
}; };
const auto fooBarCall = json {
{"type", "function"},
{"function", {
{"name", "foo"},
{"arguments", dump({
{"bar", 1}
})}
}}
};
test_parse_tool_call(llama_tool_call_style::Generic, tools,
"{\"tool_call\": {\"name\": \"foo\", \"arguments\": {\"bar\": 1}}}",
"",
json::array({fooBarCall}));
test_parse_tool_call(llama_tool_call_style::Generic, tools,
"{\"tool_calls\": [{\"name\": \"foo\", \"arguments\": {\"bar\": 1}}]}",
"",
json::array({fooBarCall}));
test_parse_tool_call(llama_tool_call_style::Hermes2Pro, tools, test_parse_tool_call(llama_tool_call_style::Hermes2Pro, tools,
"<tool_call>{\"name\": \"foo\", \"arguments\": {\"bar\": 1}}</tool_call>", "<tool_call>{\"name\": \"foo\", \"arguments\": {\"bar\": 1}}</tool_call>",
"", "",
json {{ json::array({fooBarCall}));
{"type", "function"},
{"function", {
{"name", "foo"},
{"arguments", dump({
{"bar", 1}
})}
}}
}});
test_parse_tool_call(llama_tool_call_style::FunctionaryV3Llama3, tools, test_parse_tool_call(llama_tool_call_style::FunctionaryV3Llama3, tools,
">>>ipython\n{\"code\": \"print('Hello, world!')\"}", ">>>ipython\n{\"code\": \"print('Hello, world!')\"}",