sync from b7516

This commit is contained in:
2026-01-16 11:16:14 +08:00
parent f4ae4cc7da
commit 6ee41dd9e3
380 changed files with 18435 additions and 38806 deletions

View File

@@ -650,7 +650,7 @@ static void test_msgs_oaicompat_json_conversion() {
"[\n"
" {\n"
" \"role\": \"assistant\",\n"
" \"content\": \"\",\n"
" \"content\": null,\n"
" \"tool_calls\": [\n"
" {\n"
" \"type\": \"function\",\n"
@@ -724,30 +724,6 @@ static void test_tools_oaicompat_json_conversion() {
"]"
),
common_chat_tools_to_json_oaicompat<json>({special_function_tool}).dump(2));
{
auto tools_no_params = common_chat_tools_parse_oaicompat(json::parse(
R"([{"type": "function", "function": {"name": "test_func", "description": "A test"}}])"));
assert_equals((size_t) 1, tools_no_params.size());
assert_equals(std::string("test_func"), tools_no_params[0].name);
assert_equals(std::string("A test"), tools_no_params[0].description);
assert_equals(std::string("{}"), tools_no_params[0].parameters);
}
{
auto tools_no_desc = common_chat_tools_parse_oaicompat(json::parse(
R"([{"type": "function", "function": {"name": "test_func", "parameters": {"type": "object"}}}])"));
assert_equals((size_t) 1, tools_no_desc.size());
assert_equals(std::string("test_func"), tools_no_desc[0].name);
assert_equals(std::string(""), tools_no_desc[0].description);
}
{
auto tools_minimal = common_chat_tools_parse_oaicompat(json::parse(
R"([{"type": "function", "function": {"name": "test_func"}}])"));
assert_equals((size_t) 1, tools_minimal.size());
assert_equals(std::string("test_func"), tools_minimal[0].name);
assert_equals(std::string(""), tools_minimal[0].description);
assert_equals(std::string("{}"), tools_minimal[0].parameters);
}
}
static void test_template_output_parsers() {
@@ -930,8 +906,7 @@ static void test_template_output_parsers() {
" },\n"
" \"id\": \"123456789\"\n"
" }\n"
" ],\n"
" \"content\": \"\"\n"
" ]\n"
"}");
}
{
@@ -1738,8 +1713,7 @@ static void test_template_output_parsers() {
" },\n"
" \"id\": \"123456789\"\n"
" }\n"
" ],\n"
" \"content\": \"\"\n"
" ]\n"
"}",
/* expect_grammar_triggered= */ false
);