serve: the model entry carries the capabilities /server_info reports

OpenAI's model object has no field for what a model can be asked for, so a client learned it
by sending a request and reading the refusal. The entry it already fetches now carries the same
capabilities object /server_info does (tools, reasoning, grammar, media, logprobs, the reasoning
efforts the template takes), built by one Server::capabilities() so the two cannot disagree.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-08 15:57:51 +02:00
1 parent d5b584a4c1
commit 7c0bd03841
8 files changed
+63 -20

No files matched your search

+14
View File
@@ -2542,6 +2542,20 @@ TEST(the_model_entry_carries_the_context_length_the_server_was_started_with) {
CHECK(!json::parse(unknown.get("/v1/models").body)["data"][0].contains("max_model_len"));
}
TEST(the_model_entry_and_server_info_report_the_same_capabilities) {
Fixture f;
const json info = json::parse(f.get("/server_info").body)["capabilities"];
const json list = json::parse(f.get("/v1/models").body)["data"][0]["capabilities"];
const json one = json::parse(f.get("/v1/models/test-model").body)["capabilities"];
CHECK(info.is_object());
CHECK(list == info);
CHECK(one == info);
/* Read per request, not frozen at startup: a template that takes no tools says so. */
CHECK(info.value("tools", false));
f.tmpl.tools_ok = false;
CHECK(!json::parse(f.get("/v1/models").body)["data"][0]["capabilities"].value("tools", true));
}
TEST(embeddings_without_an_embedder_is_501_not_an_empty_200) {
Fixture f;
HttpResponse r = f.post("/v1/embeddings", R"({"input":"hi"})");
+9
View File
@@ -426,6 +426,15 @@ TEST(the_model_list_is_a_list_of_one_with_the_fields_clients_read) {
* trusting a made-up one. */
CHECK(!o["data"][0].contains("max_model_len"));
CHECK(!o["data"][0].contains("root"));
CHECK(!o["data"][0].contains("capabilities"));
}
TEST(the_model_entry_carries_the_capabilities_it_was_given) {
ModelCard c = card("q38-flashnext", 1700000000);
c.capabilities = R"({"tools":true,"image":false})";
const json m = parsed(model_body(c));
CHECK(m["capabilities"].value("tools", false));
CHECK(!m["capabilities"].value("image", true));
}
TEST(the_model_entry_names_the_file_behind_the_served_name) {