chat : honor json_schema in Ling 3.0 parser (#29813)
* chat : honor json_schema in Ling 3.0 parser Ling 3.0 only built a grammar for tool calls and did not handle inputs.json_schema, so response_format requests were left unconstrained. Add an eager response-format grammar path with precedence over tools, following the existing parser patterns. Require </think> before JSON when thinking is enabled and do not allow trailing prose after the JSON response. Fixes #29652. Assisted-by: Claude Opus 5.5 * chat : require Ling 3.0 think block for response formats
This commit is contained in:
1 parent
a55e952b85
commit
9bf55f4a36
2 files changed
+28
-4
No files matched your search
@@ -4835,6 +4835,22 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
|
||||
.expect_tool_calls({ { "set_union", R"({"value": "plain text", "amount": "1abc"})", "" } })
|
||||
.run();
|
||||
|
||||
// A response format is enforced with thinking on and off.
|
||||
tst.test("I need to output the invoice details in JSON\n</think>\n"
|
||||
R"({"amount": 123.45, "date": "2025-12-03"})")
|
||||
.reasoning_format(COMMON_REASONING_FORMAT_DEEPSEEK)
|
||||
.json_schema(invoice_schema)
|
||||
.expect_reasoning("I need to output the invoice details in JSON\n")
|
||||
.expect_content(R"({"amount": 123.45, "date": "2025-12-03"})")
|
||||
.run();
|
||||
|
||||
tst.test(R"({"amount": 123.45, "date": "2025-12-03"})")
|
||||
.reasoning_format(COMMON_REASONING_FORMAT_DEEPSEEK)
|
||||
.enable_thinking(false)
|
||||
.json_schema(invoice_schema)
|
||||
.expect_content(R"({"amount": 123.45, "date": "2025-12-03"})")
|
||||
.run();
|
||||
|
||||
// Continuation: the partial assistant turn is spliced back into the prompt.
|
||||
common_chat_msg prefill = simple_assist_msg("", "I'm thinking");
|
||||
|
||||
|
||||
Reference in new issue
Block a user