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

+25 -19
View File
@@ -309,6 +309,30 @@ HttpResponse Server::handle_tokenizer_info(const HttpRequest& req) {
return HttpResponse::json_body(200, json_dump(o));
}
/* ================================================================== capabilities */
json Server::capabilities() const {
json caps;
caps["chat"] = deps_.chat != nullptr;
caps["tools"] = deps_.chat && deps_.chat->supports_tools();
caps["reasoning"] = deps_.chat && deps_.chat->supports_reasoning();
caps["grammar"] = deps_.grammar != nullptr;
caps["embedding"] = deps_.embed != nullptr;
caps["image"] = deps_.mm && deps_.mm->accepts(MediaKind::Image);
caps["video"] = deps_.mm && deps_.mm->accepts(MediaKind::Video);
caps["audio"] = deps_.mm && deps_.mm->accepts(MediaKind::Audio);
caps["logprobs"] = opt_.supports_logprobs;
/* THE EFFORTS A CHAT REQUEST MAY SEND, as probed from the template at startup: null when it
* takes any word. "none" and "minimal" are this server's, and turn thinking off. */
if (lim_.reasoning_efforts.empty()) {
caps["reasoning_efforts"] = nullptr;
} else {
std::vector<std::string> e = { "none", "minimal" };
e.insert(e.end(), lim_.reasoning_efforts.begin(), lim_.reasoning_efforts.end());
caps["reasoning_efforts"] = e;
}
return caps;
}
/* ================================================================== /server_info */
/* vLLM returns the repr() of its config object, which is a Python string a client can only print.
* This returns the same information as JSON, in two halves: what the SERVER decided, which is
@@ -335,25 +359,7 @@ HttpResponse Server::handle_server_info(const HttpRequest&) {
srv["uptime_s"] = unix_now() - started_at_;
srv["in_flight"] = in_flight_.load(std::memory_order_relaxed);
json caps;
caps["chat"] = deps_.chat != nullptr;
caps["tools"] = deps_.chat && deps_.chat->supports_tools();
caps["reasoning"] = deps_.chat && deps_.chat->supports_reasoning();
caps["grammar"] = deps_.grammar != nullptr;
caps["embedding"] = deps_.embed != nullptr;
caps["image"] = deps_.mm && deps_.mm->accepts(MediaKind::Image);
caps["video"] = deps_.mm && deps_.mm->accepts(MediaKind::Video);
caps["audio"] = deps_.mm && deps_.mm->accepts(MediaKind::Audio);
caps["logprobs"] = opt_.supports_logprobs;
/* THE EFFORTS A CHAT REQUEST MAY SEND, as probed from the template at startup: null when it
* takes any word. "none" and "minimal" are this server's, and turn thinking off. */
if (lim_.reasoning_efforts.empty()) {
caps["reasoning_efforts"] = nullptr;
} else {
std::vector<std::string> e = { "none", "minimal" };
e.insert(e.end(), lim_.reasoning_efforts.begin(), lim_.reasoning_efforts.end());
caps["reasoning_efforts"] = e;
}
json caps = capabilities();
/* WHAT A REQUEST THAT LEAVES A FIELD OUT GETS, under the request's own spelling of each
* field, so a client can read off exactly what leaving one out means on this deployment. */
+4
View File
@@ -2213,6 +2213,10 @@ static json model_card(const ModelCard& c) {
m["owned_by"] = "radiance";
if (c.max_model_len > 0) m["max_model_len"] = c.max_model_len;
if (!c.root.empty()) m["root"] = c.root;
if (!c.capabilities.empty()) {
json caps = json::parse(c.capabilities, nullptr, false);
if (!caps.is_discarded() && caps.is_object()) m["capabilities"] = std::move(caps);
}
return m;
}
+5
View File
@@ -331,6 +331,11 @@ struct ModelCard {
int64_t max_model_len = 0;
/* What the server loaded (ServerOptions::model_path), vLLM's `root`. Empty leaves it out. */
std::string root;
/* What the model can be asked for -- tools, reasoning, images -- as /server_info reports it.
* There is no field for it in OpenAI's model object, so a client today learns it by sending a
* request and reading the refusal; the entry it already fetches can say so up front. A JSON
* object as text, spliced in as it is; empty leaves it out. */
std::string capabilities;
};
/* The list, for GET /v1/models. */
std::string models_body(const ModelCard& m);
+1
View File
@@ -1158,6 +1158,7 @@ HttpResponse Server::handle_models(const HttpRequest& req) {
c.created = started_at_;
c.max_model_len = opt_.max_ctx;
c.root = opt_.model_path;
c.capabilities = capabilities().dump();
metrics_.observe_http(200);
return HttpResponse::json_body(200, id.empty() ? models_body(c) : model_body(c));
}
+4
View File
@@ -201,6 +201,10 @@ private:
HttpResponse handle_detokenize(const HttpRequest& req);
HttpResponse handle_tokenizer_info(const HttpRequest& req);
HttpResponse handle_server_info(const HttpRequest& req);
/* What this deployment can do -- chat, tools, reasoning, grammar, media, logprobs, the
* reasoning efforts it takes -- as /server_info's `capabilities` and the model entry both
* report it, built in one place so the two cannot disagree. */
json capabilities() const;
HttpResponse handle_sessions(const HttpRequest& req);
HttpResponse handle_reset_prefix_cache(const HttpRequest& req);