progress
This commit is contained in:
@@ -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,53 @@ 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.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);
|
||||
}
|
||||
|
||||
// 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 +2241,3 @@ static void test_tagged_args_with_embedded_quotes(testing & t) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user