server: add "verbose" field to schema

This commit is contained in:
Xuan Son Nguyen 2026-06-21 11:16:06 +02:00
parent 8a118ee86c
commit f1ef61fb1b
2 changed files with 23 additions and 0 deletions

View File

@ -14,6 +14,9 @@ std::vector<std::unique_ptr<field>> make_llama_cmpl_schema(const common_params &
fields.emplace_back(f); fields.emplace_back(f);
}; };
add((new field_bool("verbose", params.verbose))
->set_desc("Include __verbose field in the response with additional debug information"));
add((new field_bool("timings_per_token", params.timings_per_token)) add((new field_bool("timings_per_token", params.timings_per_token))
->set_desc("Include prompt processing and text generation speed information in each response")); ->set_desc("Include prompt processing and text generation speed information in each response"));

View File

@ -603,3 +603,23 @@ def test_chat_completions_token_count():
}) })
assert res.status_code == 200 assert res.status_code == 200
assert res.body["input_tokens"] > 5 assert res.body["input_tokens"] > 5
def test_verbose_debug():
global server
server.start()
for verbose in [True, False]:
res = server.make_request("POST", "/chat/completions", data={
"max_tokens": 2,
"messages": [
{"role": "system", "content": "Book"},
{"role": "user", "content": "What is the best book"},
],
"verbose": verbose,
})
assert res.status_code == 200
if verbose:
assert "__verbose" in res.body
assert "Book" in res.body["__verbose"]["prompt"]
else:
assert "__verbose" not in res.body