Open History to see the last commit
1import { readFileSync } from 'node:fs'
2import { describe, expect, it } from 'vitest'
3
4import {
5 dashscopeDocText,
6 dashscopeModelPageUrl,
7 loadDashscopeModelLimits,
8 parseDashscopeModelLimits,
9} from './dashscope-model-limits.ts'
10
11/** The rendered qwen3-omni-flash.md page, fetched 2026-10-29 (issue #520). */
12const OMNI_PAGE = readFileSync(
13 new URL('./fixtures/dashscope/qwen3-omni-flash.html', import.meta.url),
14 'utf8',
15)
16
17/** Context limits from qwen3-omni-flash.md, checked 2026-10-08. */
18const OMNI_FIXTURE = `# qwen3-omni-flash
19
20## Context Limits <span id="h-4b8ebeae72" />
21
22<table><thead><tr><th>Parameter</th><th>Value</th><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p>Max Input Length</p></td><td><p>49152</p></td><td><p>Max Output Length</p></td><td><p>16384</p></td></tr><tr><td><p>Context Window</p></td><td><p>65536</p></td><td><p>Max Input Length (Thinking Mode)</p></td><td><p>16384</p></td></tr><tr><td><p>Max Output Length (Thinking Mode)</p></td><td><p>16384</p></td><td><p>Max Chain-of-Thought Length</p></td><td><p>32768</p></td></tr></tbody></table>
23
24## Pricing <span id="h-d72e94e06d" />
25
26### qwen3-omni-flash-2025-09-15 <span id="h-0c5c74dc20" />
27
28#### Model Capabilities <span id="h-eca28b5fa5" />
29
30<table><thead><tr><th>Capability</th><th>Support</th></tr></thead><tbody><tr><td><p>Function Calling</p></td><td><p>Supported</p></td></tr></tbody></table>
31
32#### Context Limits <span id="h-8a43bf5ab2" />
33
34<table><thead><tr><th>Parameter</th><th>Value</th><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p>Max Input Length</p></td><td><p>49152</p></td><td><p>Max Output Length</p></td><td><p>16384</p></td></tr><tr><td><p>Context Window</p></td><td><p>65536</p></td><td><p>Max Input Length (Thinking Mode)</p></td><td><p>16384</p></td></tr></tbody></table>
35`
36
37/** Context limits from qwen3-8-omni-flash-realtime.md, checked 2026-10-08. */
38const REALTIME_FIXTURE = `# qwen3.8-omni-flash-realtime
39
40## Model capabilities
41
42| Capability | Support | Capability | Support |
43| --- | --- | --- | --- |
44| Input modalities | Text, streaming audio, and video | Output modalities | Text and audio |
45
46## Context limits
47
48| Parameter | Value | Parameter | Value |
49| -------------------------- | --------------------------------------- | --------------------- | ---------------------------------------- |
50| Maximum total input tokens | 196608 | Audio history | Up to 100 turns and 600 seconds in total |
51| Video history | Up to 50 turns and 240 seconds in total | Maximum output tokens | 65536 |
52
53## Model pricing
54`
55
56/** Context limits from decision-model-preview.md, checked 2026-10-08. */
57const DECISION_FIXTURE = `# decision-model-preview
58
59## Context Limits <span id="h-dm-ctx" />
60
61<table><thead><tr><th>Parameter</th><th>Value</th><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p>Max Input Length</p></td><td><p>65,536</p></td><td><p>Max Output Length</p></td><td><p>0</p></td></tr><tr><td><p>Context Window</p></td><td><p>65,536</p></td><td /><td /></tr></tbody></table>
62`
63
64describe('dashscope model limits', () => {
65 it('reads context and non-thinking max output, including snapshot sections', () => {
66 const models = parseDashscopeModelLimits(OMNI_FIXTURE)
67 expect(models['qwen3-omni-flash']).toEqual({
68 contextWindow: 65536,
69 maxOutput: 16384,
70 })
71 expect(models['qwen3-omni-flash-2025-09-15']).toEqual({
72 contextWindow: 65536,
73 maxOutput: 16384,
74 })
75 })
76
77 it('does not treat maximum input as the context window', () => {
78 expect(parseDashscopeModelLimits(REALTIME_FIXTURE)).toEqual({
79 'qwen3.8-omni-flash-realtime': {
80 contextWindow: null,
81 maxOutput: 65536,
82 },
83 })
84 })
85
86 it('keeps a published max output of zero', () => {
87 expect(parseDashscopeModelLimits(DECISION_FIXTURE)).toEqual({
88 'decision-model-preview': { contextWindow: 65536, maxOutput: 0 },
89 })
90 })
91
92 it('throws when the page has no context-limit row', () => {
93 expect(() => parseDashscopeModelLimits('# qwen-plus\n\nno table')).toThrow(
94 /parsed 0 context-limit rows/,
95 )
96 })
97
98 it('reads the rendered help page the .md URL serves since 2026-10-27', async () => {
99 const doc = await loadDashscopeModelLimits(OMNI_PAGE)
100 expect(doc.models).toEqual({
101 'qwen3-omni-flash': { contextWindow: 65536, maxOutput: 16384 },
102 })
103 // The page's traceid changes per request; the hash covers the article.
104 expect(doc.sourceHash).toBe(
105 (
106 await loadDashscopeModelLimits(
107 OMNI_PAGE.replace(/traceid="[^"]*"/, 'traceid="other"'),
108 )
109 ).sourceHash,
110 )
111 })
112
113 it('turns the article back into the markdown shape, keeping tables', () => {
114 const page = `<!DOCTYPE html><html traceid="x"><head><title>t</title></head><body>
115<h1 class="page-title">Alibaba Cloud Model Studio:qwen-plus</h1>
116<article class="product-description markdown-body"><div>
117<p>Use the <code>thinking_budget</code> parameter & see <a href="/x">docs</a>.</p>
118<h2 id="s">Supported Models <span id="a"></span></h2>
119<section><h4>Qwen3</h4><ul><li><strong>Plus</strong> (Hybrid thinking mode): qwen-plus, qwen-plus-latest</li></ul></section>
120<pre class="pre codeblock"><code>model="qwen-plus"</code></pre>
121<h2>Context Limits</h2>
122<table><tbody><tr><td><p>Context Window</p></td><td><p>1,000,000</p></td></tr></tbody></table>
123</div></article><div class="nav-footer"><h2>Feedback</h2></div></body></html>`
124 expect(dashscopeDocText(page, 'x')).toBe(`# qwen-plus
125
126Use the \`thinking_budget\` parameter & see docs.
127
128## Supported Models
129
130#### Qwen3
131
132Plus (Hybrid thinking mode): qwen-plus, qwen-plus-latest
133
134\`\`\`
135model="qwen-plus"
136\`\`\`
137
138## Context Limits
139
140<table><tbody><tr><td><p>Context Window</p></td><td><p>1,000,000</p></td></tr></tbody></table>
141`)
142 expect(parseDashscopeModelLimits(dashscopeDocText(page, 'x'))).toEqual({
143 'qwen-plus': { contextWindow: 1000000, maxOutput: null },
144 })
145 expect(dashscopeDocText('# md\n', 'x')).toBe('# md\n')
146 })
147
148 it('rejects an HTML shell', async () => {
149 await expect(
150 loadDashscopeModelLimits(
151 '<!DOCTYPE html><html><head>\n<title>Access denied</title></head></html>',
152 ),
153 ).rejects.toThrow(
154 /not markdown \(title: Access denied\): <!DOCTYPE html><html><head> <title>/,
155 )
156 })
157
158 it('points a dated snapshot at the stable model page', () => {
159 expect(dashscopeModelPageUrl('qwen3-omni-flash-2025-09-15')).toBe(
160 'https://www.alibabacloud.com/help/en/model-studio/qwen3-omni-flash.md',
161 )
162 expect(dashscopeModelPageUrl('qwen3.8-omni-flash-realtime')).toBe(
163 'https://www.alibabacloud.com/help/en/model-studio/qwen3-8-omni-flash-realtime.md',
164 )
165 })
166})