feat(llm): extend the built-in context-window table to the rest of the catalog

This commit is contained in:
matevip 2026-08-02 23:59:37 -04:00
parent 5ba92f3b87
commit 12c34c32a8
2 changed files with 63 additions and 0 deletions

View File

@ -60,8 +60,27 @@ final class ModelContextWindowCatalog {
m.put("o4-mini", 200_000);
// ===== Alibaba Qwen =====
// The Max line stays at 256k while Plus / Turbo / Flash and the coder
// flagship run the 1M window; qwen-long is the dedicated 10M model.
m.put("qwen-max", 262_144);
m.put("qwen3-max", 262_144);
m.put("qwen-plus", 1_000_000);
m.put("qwen-turbo", 1_000_000);
m.put("qwen-long", 10_000_000);
m.put("qwen-coder-plus", 1_000_000);
m.put("qwen3-coder-plus", 1_000_000);
m.put("qwen3-coder-next", 262_144);
m.put("qwen3.5-plus", 1_000_000);
m.put("qwen3.5-flash", 1_000_000);
m.put("qwen3.6-plus", 1_000_000);
m.put("qwen3.6-flash", 1_000_000);
m.put("qwen3.6-max", 260_000);
// Open-weight releases: 256k native, larger only with rope scaling the
// hosting provider may or may not have enabled.
m.put("qwen3-vl", 262_144);
m.put("qwen3-235b", 262_144);
m.put("qwen3-30b", 262_144);
m.put("qwen3.5-122b", 262_144);
// ===== Moonshot Kimi =====
m.put("kimi-k2", 262_144);
@ -69,13 +88,31 @@ final class ModelContextWindowCatalog {
// ===== Zhipu GLM =====
m.put("glm-4.7", 204_800);
m.put("glm-4-7", 204_800);
// 200k across the GLM-5 line (5 / 5.1 / turbo variants); 5.2 lifted it to 1M.
m.put("glm-5", 204_800);
m.put("glm-5.2", 1_000_000);
// The 9B open weights ship at 128k (the separate -1m build is its own id).
m.put("glm-4-9b", 131_072);
// ===== Volcengine Doubao / Ark =====
m.put("doubao-seed-1-8", 262_144);
m.put("doubao-seed-code", 262_144);
// Seed 2.0 pro / lite / mini / code all ship 256k; the console uses
// dotted ids and the dated snapshots use dashes.
m.put("doubao-seed-2.0", 262_144);
m.put("doubao-seed-2-0", 262_144);
m.put("ark-code-latest", 262_144);
// ===== MiniMax =====
// M2.x documents 204,800 as the combined input+output budget.
m.put("minimax-m2", 204_800);
m.put("minimax-m3", 1_000_000);
// ===== Xiaomi MiMo =====
m.put("mimo-v2-flash", 262_144);
m.put("mimo-v2-pro", 1_048_576);
m.put("mimo-v2.5", 1_000_000);
// ===== xAI Grok =====
m.put("grok-3", 131_072);
m.put("grok-4", 256_000);

View File

@ -30,6 +30,32 @@ class ModelContextWindowCatalogTest {
assertEquals(1_048_576, ModelContextWindowCatalog.lookup("meta-llama/llama-4-maverick"));
}
@Test
@DisplayName("same-family models with different windows do not bleed into each other")
void familyVariantsStaySeparate() {
// Coder: plus is 1M, next is 256k native.
assertEquals(1_000_000, ModelContextWindowCatalog.lookup("qwen3-coder-plus"));
assertEquals(262_144, ModelContextWindowCatalog.lookup("qwen3-coder-next"));
// GLM-5 line is 200k; only 5.2 lifted it to 1M.
assertEquals(204_800, ModelContextWindowCatalog.lookup("glm-5"));
assertEquals(204_800, ModelContextWindowCatalog.lookup("glm-5.1"));
assertEquals(204_800, ModelContextWindowCatalog.lookup("glm-5-turbo"));
assertEquals(1_000_000, ModelContextWindowCatalog.lookup("glm-5.2"));
// Max line stays at 256k while plus/flash run 1M.
assertEquals(262_144, ModelContextWindowCatalog.lookup("qwen3-max-2026-01-23"));
assertEquals(1_000_000, ModelContextWindowCatalog.lookup("qwen3.6-plus-2026-04-02"));
}
@Test
@DisplayName("dotted and dashed ids of the same model resolve alike")
void dottedAndDashedIdsAgree() {
assertEquals(262_144, ModelContextWindowCatalog.lookup("doubao-seed-2.0-pro"));
assertEquals(262_144, ModelContextWindowCatalog.lookup("doubao-seed-2-0-pro-260215"));
assertEquals(204_800, ModelContextWindowCatalog.lookup("MiniMax-M2.7-highspeed"));
assertEquals(204_800, ModelContextWindowCatalog.lookup("minimax-m2.7"));
assertEquals(1_000_000, ModelContextWindowCatalog.lookup("minimax-m3"));
}
@Test
@DisplayName("models outside the table return null so the caller keeps its default")
void unknownModelsReturnNull() {