serve: /v1/models reports max_model_len, the context the server runs with

The model list carried only the id, so a client had no way to read the context the server
was started with and guessed it from the model's name. Carry the field vLLM's model card does:
the server's max_ctx (--max-model-len, else the container's trained length), on both
/v1/models and /v1/models/:id, and leave it out when the length is unknown.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-08 15:57:51 +02:00
1 parent 7fd2cd7fa6
commit 86128c2e75
6 files changed
+33 -5

No files matched your search

+2 -1
View File
@@ -2205,12 +2205,13 @@ std::string embeddings_body(const OaiRequest& r, const std::vector<std::vector<f
return o.dump();
}
std::string models_body(const std::string& model_id, int64_t created) {
std::string models_body(const std::string& model_id, int64_t created, int64_t max_model_len) {
json m;
m["id"] = model_id;
m["object"] = "model";
m["created"] = created;
m["owned_by"] = "radiance";
if (max_model_len > 0) m["max_model_len"] = max_model_len;
json o;
o["object"] = "list";
o["data"] = json::array({m});