feat: extracting context window from llama.cpp metadata

This commit is contained in:
Alok Saboo
2026-08-25 09:47:25 -04:00
parent 3e82f13042
commit 3b0b66cbd1
2 changed files with 23 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ _CONTEXT_WINDOW_KEYS = (
"max_prompt_tokens",
"max_model_len",
"max_sequence_length",
"n_ctx",
)
_KNOWN_CONTEXT_WINDOWS: tuple[tuple[str, int], ...] = (

View File

@@ -99,6 +99,28 @@ def test_extract_context_window_reads_novita_context_size_key() -> None:
)
def test_extract_context_window_reads_llamacpp_n_ctx_meta() -> None:
"""llama.cpp exposes the effective window as ``meta.n_ctx`` for loaded models."""
payload = {
"data": [
{
"id": "Qwen3.8-27B:Q6_K_XL",
"status": {
"value": "loaded",
"args": ["--alias", "Qwen3.8-27B:Q6_K_XL", "--ctx-size", "400000"],
},
"preset": "ctx-size = 400000\n",
"meta": {"n_ctx": 200_192, "n_ctx_train": 262_144},
},
]
}
assert (
detection_module._extract_context_window_from_payload(payload, "Qwen3.8-27B:Q6_K_XL")
== 200_192
)
def test_models_endpoint_probe_honors_disable_ssl_verify(monkeypatch) -> None:
captured: dict[str, object] = {}