Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { replicateReadmeFacts } from './replicate-readme.ts'
4
5/** GET /v1/models/openai/gpt-5.4/readme, specs section, 2026-10-08. */
6const GPT_54 = `
7- **Long context**: Up to 1,050,000 token context window
8
9## Specs
10
11| | |
12|---|---|
13| **Context window** | 1,050,000 tokens |
14| **Max output tokens** | 128,000 |
15| **Knowledge cutoff** | August 31, 2025 |
16`
17
18/** GET /v1/models/anthropic/claude-opus-4.7/readme, 2026-10-08. */
19const OPUS = `Claude Opus 4.7 features a one million token context window, letting it process and reason across large amounts of information. It can output up to 128,000 tokens.`
20
21/** GET /v1/models/qwen/qwen3-235b-a22b-instruct-2507/readme, 2026-10-08. */
22const QWEN = `
23- **Enhanced capabilities** in **256K long-context understanding**.
24- Context Length: **262,144 natively**.
25\`\`\`
26python -m sglang.launch_server --context-length 262144
27\`\`\`
28**Note: consider reducing the context length to a shorter value, such as \`32,768\`.**
29`
30
31/** GET /v1/models/prunaai/qwen-3.5-35b-a3b-fast/readme, 2026-10-08. */
32const QWEN_35 = ` Context length: 262,144 tokens natively, extensible up to 1,010,000 tokens`
33
34/** GET /v1/models/ibm-granite/granite-4.2-8b/readme, 2026-10-08. Two windows. */
35const GRANITE = `
36| **Context Length** | Natively Supports 128K (Long-context extension to 512K) |
37- **512K Context Window:** Supports long documents.
38`
39
40/** GET /v1/models/deepseek-ai/deepseek-v3.1/readme, 2026-10-08. An eval note, not the model. */
41const DEEPSEEK = `Search agents use a commercial search API + webpage filter + 128K context window.`
42
43/** GET /v1/models/google/gemini-2.5-flash/readme, 2026-10-08. The published sentence is approximate (`~`). */
44const GEMINI_TILDE = `- **Long Context Handling**: Works with extremely long inputs (up to ~1 million token context window).`
45
46/** GET /v1/models/anthropic/claude-fable-5/readme, 2026-10-08. */
47const FABLE = `- \`max_tokens\` - maximum number of output tokens, up to 128,000. Adaptive thinking shares this budget.`
48
49/** GET /v1/models/jeffgreen311/eve-v2-unleashed/readme, 2026-10-08. */
50const EVE = `
51| Context Window | 16,384 tokens |
52| Max Output | 8,192 tokens |
53- 262K context window capability
54| num_ctx | 16384 | Balanced context window |
55`
56
57/** Listing description of moonshotai/kimi-k2.6, 2026-10-08, beside its README sentence. */
58const KIMI_README = `It has 1 trillion total parameters and a 262,144 token context window.`
59const KIMI_DESCRIPTION =
60 'Moonshot AI frontier model. 1 trillion parameters, 262k context window, vision and tool use.'
61
62describe('replicate README facts', () => {
63 it('reads a specs table and the same count restated in prose', () => {
64 expect(replicateReadmeFacts(GPT_54)).toMatchObject({
65 contextWindow: 1_050_000,
66 maxOutput: 128_000,
67 context: { from: 'readme', path: 'context window' },
68 max: { path: 'max output tokens' },
69 })
70 })
71
72 it('reads "one million token context window"', () => {
73 expect(replicateReadmeFacts(OPUS).contextWindow).toBe(1_000_000)
74 expect(replicateReadmeFacts(OPUS).maxOutput).toBeNull()
75 })
76
77 it('keeps the exact native window and ignores a rounded aside and a code sample', () => {
78 expect(replicateReadmeFacts(QWEN)).toMatchObject({
79 contextWindow: 262_144,
80 context: { path: 'context length' },
81 })
82 expect(replicateReadmeFacts(QWEN_35).contextWindow).toBe(262_144)
83 })
84
85 it('states nothing when the README names two windows, an eval note, or an approximation', () => {
86 expect(replicateReadmeFacts(GRANITE).contextWindow).toBeNull()
87 expect(replicateReadmeFacts(DEEPSEEK).contextWindow).toBeNull()
88 expect(replicateReadmeFacts(GEMINI_TILDE).contextWindow).toBeNull()
89 })
90
91 it('reads an output cap from a max_tokens bullet and a spec table', () => {
92 expect(replicateReadmeFacts(FABLE)).toMatchObject({
93 contextWindow: null,
94 maxOutput: 128_000,
95 max: { path: 'max_tokens' },
96 })
97 expect(replicateReadmeFacts(EVE)).toMatchObject({
98 contextWindow: 16_384,
99 maxOutput: 8_192,
100 })
101 })
102
103 it('prefers the exact README count over the description abbreviation', () => {
104 const facts = replicateReadmeFacts(KIMI_README, KIMI_DESCRIPTION)
105 expect(facts.contextWindow).toBe(262_144)
106 expect(facts.context?.from).toBe('readme')
107 })
108
109 it('reads a description abbreviation when the README states no window', () => {
110 const facts = replicateReadmeFacts('', KIMI_DESCRIPTION)
111 expect(facts.contextWindow).toBe(262_000)
112 expect(facts.context).toEqual({ from: 'description', path: 'description' })
113 })
114})