Archived
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:
1 parent
d5b584a4c1
commit
7c0bd03841
8 files changed
+63
-20
No files matched your search
+25
-19
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -1132,7 +1132,7 @@ for a model that takes no images or video.
|
||||
| `POST /v1/chat/completions` | chat, with tools, reasoning and streaming |
|
||||
| `POST /v1/completions` | raw text completion |
|
||||
| `POST /v1/embeddings` | needs a model with an embedding head, else 501 |
|
||||
| `GET /v1/models`, `/v1/models/:id` | what is loaded, with `max_model_len` (the context it serves) and `root` (the `--model` path), as vLLM reports them; `:id` answers the entry itself, as OpenAI's retrieve does |
|
||||
| `GET /v1/models`, `/v1/models/:id` | what is loaded, with `max_model_len` (the context it serves) and `root` (the `--model` path), as vLLM reports them, and `capabilities` (the same object `/server_info` reports); `:id` answers the entry itself, as OpenAI's retrieve does |
|
||||
| `GET /health`, `/ping`, `POST /ping` | liveness |
|
||||
| `GET /load` | current load |
|
||||
| `GET /version` | server version |
|
||||
|
||||
@@ -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"})");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user