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

+7 -1
View File
@@ -318,7 +318,13 @@ std::string text_completion_body(const OaiRequest& r, const std::vector<ChoiceOu
const UsageOut& u, const TimingsOut& t = TimingsOut());
std::string embeddings_body(const OaiRequest& r, const std::vector<std::vector<float>>& vecs,
const UsageOut& u);
std::string models_body(const std::string& model_id, int64_t created);
/* `max_model_len` is the context the server was started with (--max-model-len, else the
* container's trained length), the field vLLM's model card carries. Clients size their own
* context from it -- an agent that compresses its history at the window's edge, a UI that shows
* how much is left -- and without it they guess from the model's name, which is wrong whenever the
* deployment sets its own length. 0 leaves the field out rather than reporting a length the
* server does not know. */
std::string models_body(const std::string& model_id, int64_t created, int64_t max_model_len = 0);
/* The usage chunk of each endpoint's stream: an SSE event whose choices array is empty and whose
* only payload is `usage`. Emitted when the request asked for stream_options.include_usage, ONCE