Inkling longhaul support

This commit is contained in:
Owen Qwen
2026-08-03 20:50:22 -05:00
parent e3b2925150
commit ac9907e841
28 changed files with 1375 additions and 34 deletions
+75 -1
View File
@@ -91,6 +91,7 @@ static void test_normalize_quotes_with_embedded_quotes(testing & t);
static void test_tagged_args_with_embedded_quotes(testing & t);
static void test_role_markers_all_templates(testing & t);
static void test_inkling_tml_parser(testing & t);
int main(int argc, char * argv[]) {
testing t(std::cout);
@@ -117,6 +118,7 @@ int main(int argc, char * argv[]) {
t.test("standard_json_tools", test_standard_json_tools_formats);
t.test("normalize_quotes_to_json", test_normalize_quotes_to_json);
t.test("tagged_args_embedded_quotes", test_tagged_args_with_embedded_quotes);
t.test("inkling_tml", test_inkling_tml_parser);
t.test("role_markers_all_templates", test_role_markers_all_templates);
return t.summary();
@@ -2075,6 +2077,79 @@ static void test_role_markers_all_templates(testing & t) {
}
}
static void test_inkling_tml_parser(testing & t) {
const std::string tmpl_src =
"{# <|content_thinking|><|content_text|> #}"
"{%- for message in messages -%}"
"<|message_user|><|content_text|>{{ message.content }}<|end_message|>"
"{%- endfor -%}"
"{%- if add_generation_prompt -%}<|message_model|>{%- endif -%}";
common_chat_templates_ptr tmpls =
common_chat_templates_init(nullptr, tmpl_src);
common_chat_templates_inputs inputs;
common_chat_msg user_message;
user_message.role = "user";
user_message.content = "Hello";
inputs.messages = { user_message };
inputs.add_generation_prompt = true;
inputs.reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK;
inputs.tools = common_chat_tools_parse_oaicompat(build_test_tools());
inputs.parallel_tool_calls = true;
inputs.use_jinja = true;
const common_chat_params params =
common_chat_templates_apply(tmpls.get(), inputs);
t.assert_equal(
"Inkling uses the native PEG parser",
COMMON_CHAT_FORMAT_PEG_NATIVE,
params.format);
t.assert_true("Inkling exposes thinking blocks", params.supports_thinking);
t.assert_equal(
"Inkling generation marker",
"<|message_model|>",
params.generation_prompt);
common_peg_arena arena;
arena.load(params.parser);
common_chat_parser_params parser_params(params);
parser_params.reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK;
const common_chat_msg parsed = common_chat_peg_parse(
arena,
"<|content_thinking|>plan<|end_message|>"
"<|message_model|><|content_text|>answer<|end_message|>"
"<|content_model_end_sampling|>",
false,
parser_params);
t.assert_equal("reasoning block", "plan", parsed.reasoning_content);
t.assert_equal("text block", "answer", parsed.content);
const common_chat_msg tool_parsed = common_chat_peg_parse(
arena,
"<|content_thinking|>I should check.<|end_message|>"
"<|message_model|><|content_invoke_tool_json|>"
R"({"name":"get_current_weather","args":{"location":"Chicago","unit":"celsius"}})"
"<|end_message|>"
"<|message_model|><|content_invoke_tool_json|>"
R"({"name":"get_current_weather","args":{"location":"Austin","unit":"fahrenheit"}})"
"<|end_message|><|content_model_end_sampling|>",
false,
parser_params);
t.assert_equal("tool reasoning block", "I should check.", tool_parsed.reasoning_content);
t.assert_equal("parallel tool-call count", 2u, tool_parsed.tool_calls.size());
if (tool_parsed.tool_calls.size() == 2) {
t.assert_equal("first tool name", "get_current_weather", tool_parsed.tool_calls[0].name);
t.assert_equal("second tool name", "get_current_weather", tool_parsed.tool_calls[1].name);
t.assert_true(
"first tool arguments",
tool_parsed.tool_calls[0].arguments.find("Chicago") != std::string::npos);
t.assert_true(
"second tool arguments",
tool_parsed.tool_calls[1].arguments.find("Austin") != std::string::npos);
}
}
// Test that reproduces the Seed-OSS template issue with embedded quotes
static void test_tagged_args_with_embedded_quotes(testing & t) {
json tools = build_edit_tool();
@@ -2192,4 +2267,3 @@ static void test_tagged_args_with_embedded_quotes(testing & t) {
}
}
}