Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

minimax-docs.test.ts

801 lines27.5 KB

1import { afterEach, describe, expect, it } from 'vitest'
2​
3import {
4 MINIMAX_CN_MAX_COMPLETION_TOKENS,
5 MINIMAX_CN_PRICING_PAGE,
6 MINIMAX_CN_SDK_PAGE,
7 MINIMAX_MAX_COMPLETION_TOKENS,
8 MINIMAX_PRICING_PAGE,
9 MINIMAX_SDK_PAGE,
10} from './fixtures/minimax-docs.ts'
11import {
12 fetchMinimaxPage,
13 MINIMAX,
14 MINIMAX_CN,
15 minimaxModelFacts,
16 parseMinimaxContextWindows,
17 parseMinimaxInputModalities,
18 parseMinimaxMaxOutput,
19 parseMinimaxPricing,
20 parseMinimaxReasoning,
21} from './minimax-docs.ts'
22​
23const IDS = [
24 'MiniMax-M3.1-Flash-Preview',
25 'MiniMax-M3',
26 'MiniMax-M2.7',
27 'MiniMax-M2.7-highspeed',
28 'MiniMax-M2.5',
29 'MiniMax-M2.5-highspeed',
30 'MiniMax-M2.1',
31 'MiniMax-M2.1-highspeed',
32 'MiniMax-M2',
34​
35describe('minimax docs', () => {
36 it('reads every context window from the Supported Models table', () => {
37 const windows = parseMinimaxContextWindows(MINIMAX_SDK_PAGE)
38 expect([...windows.keys()]).toEqual(IDS)
39 expect(windows.get('MiniMax-M3.1-Flash-Preview')).toBe(1_000_000)
40 expect(windows.get('MiniMax-M2')).toBe(204_800)
41 })
42​
43 it('gives image and video input only to the models the table names', () => {
44 const inputs = parseMinimaxInputModalities(MINIMAX_SDK_PAGE, IDS)
45 expect(inputs.get('MiniMax-M3.1-Flash-Preview')).toEqual([
46 'text',
47 'image',
48 'video',
49 ])
50 expect(inputs.get('MiniMax-M3')).toEqual(['text', 'image', 'video'])
51 expect(inputs.get('MiniMax-M2.7-highspeed')).toEqual(['text'])
52 expect(inputs.size).toBe(IDS.length)
53 })
54​
55 it('reads thinking from the control table and efforts for M3.1 only', () => {
56 const reasoning = parseMinimaxReasoning(MINIMAX_SDK_PAGE, IDS)
57 expect(reasoning.get('MiniMax-M3.1-Flash-Preview')).toEqual({
58 mode: 'adaptive',
59 mandatory: true,
60 efforts: ['low', 'medium', 'high', 'xhigh', 'max'],
61 })
62 expect(reasoning.get('MiniMax-M3')).toEqual({
63 mode: 'adaptive',
64 mandatory: false,
65 })
66 for (const id of IDS.slice(2)) {
67 expect(reasoning.get(id)).toEqual({ mode: 'adaptive', mandatory: true })
68 }
69 })
70​
71 it('reads the output cap for the named models and for the rest', () => {
72 const caps = parseMinimaxMaxOutput(MINIMAX_MAX_COMPLETION_TOKENS, IDS)
73 expect(caps.get('MiniMax-M3.1-Flash-Preview')).toBe(524_288)
74 expect(caps.get('MiniMax-M3')).toBe(524_288)
75 expect(caps.get('MiniMax-M2.7')).toBe(204_800)
76 expect(caps.size).toBe(IDS.length)
77 })
78​
79 it('leaves the output cap empty when the sentence changes shape', () => {
80 expect(
81 parseMinimaxMaxOutput('Upper limit for generated tokens.', IDS).size,
82 ).toBe(0)
83 })
84​
85 it('stores no output cap when the clause naming a model is reworded', () => {
86 // Only the M3 clause changes; `other models` still parses and must not
87 // be handed to the models the sentence names.
88 const reworded = MINIMAX_MAX_COMPLETION_TOKENS.replace(
89 'the maximum is 524288',
90 'the upper bound is 524288',
91 )
92 expect(reworded).not.toBe(MINIMAX_MAX_COMPLETION_TOKENS)
93 expect(parseMinimaxMaxOutput(reworded, IDS).size).toBe(0)
94 })
95​
96 it('never gives a named model the other-models cap, whatever the clause order', () => {
97 const swapped =
98 'For other models the recommended value is 65536 (64K) and the maximum is 204800 (200K); for MiniMax-M3.1-Flash-Preview and MiniMax-M3 the recommended value is 131072 (128K) and the maximum is 524288 (512K).'
99 const caps = parseMinimaxMaxOutput(swapped, IDS)
100 expect(caps.get('MiniMax-M3')).toBe(524_288)
101 expect(caps.get('MiniMax-M3.1-Flash-Preview')).toBe(524_288)
102 expect(caps.get('MiniMax-M2')).toBe(204_800)
103​
104 const othersOnly =
105 'For other models the maximum is 204800 (200K); MiniMax-M3 has a higher limit.'
106 expect(parseMinimaxMaxOutput(othersOnly, IDS).size).toBe(0)
107 expect(
108 parseMinimaxMaxOutput('For other models the maximum is 204800.', IDS)
109 .size,
110 ).toBe(0)
111 })
112​
113 it('refuses a struck price whose badge is not permanent', () => {
114 const promo = MINIMAX_PRICING_PAGE.replaceAll(
115 'Permanent 50% off',
116 '50% off until Dec 31',
117 )
118 expect(promo).not.toBe(MINIMAX_PRICING_PAGE)
119 const prices = parseMinimaxPricing(promo)
120 expect(prices.has('MiniMax-M3')).toBe(false)
121 expect(prices.size).toBe(7)
122​
123 // One row losing its badge refuses the whole model, not just that tier.
124 const half = MINIMAX_PRICING_PAGE.replace(
125 'Permanent 50% off',
126 'Limited offer',
127 )
128 expect(parseMinimaxPricing(half).has('MiniMax-M3')).toBe(false)
129 })
130​
131 it('prices the standard tier at the billed amount, with the long-context tier', () => {
132 const prices = parseMinimaxPricing(MINIMAX_PRICING_PAGE)
133 // The Priority tab ($0.45) and the struck list price ($0.60) are not used.
134 expect(prices.get('MiniMax-M3')).toEqual({
135 base: {
136 input_tokens: 0.3 / 1e6,
137 output_tokens: 1.2 / 1e6,
138 cache_read_tokens: 0.06 / 1e6,
139 },
140 tiers: [
141 {
142 minPromptTokens: 512_000,
143 rates: {
144 input_tokens: 0.6 / 1e6,
145 output_tokens: 2.4 / 1e6,
146 cache_read_tokens: 0.12 / 1e6,
147 },
148 },
149 ],
150 })
151 expect(prices.get('MiniMax-M2.7-highspeed')).toEqual({
152 base: {
153 input_tokens: 0.6 / 1e6,
154 output_tokens: 2.4 / 1e6,
155 cache_read_tokens: 0.06 / 1e6,
156 cache_write_tokens: 0.375 / 1e6,
157 },
158 tiers: [],
159 })
160 expect(prices.get('MiniMax-M2')?.base.cache_read_tokens).toBe(0.03 / 1e6)
161 // No pay-as-you-go price is published for the M Plan preview model.
162 expect(prices.has('MiniMax-M3.1-Flash-Preview')).toBe(false)
163 expect(prices.size).toBe(8)
164 })
165})
166​
167describe('minimax-cn pricing', () => {
168 const cn = (page: string) => parseMinimaxPricing(page, MINIMAX_CN)
169​
170 it('prices the 标准 tier in yuan at the billed amount, with the long-context tier', () => {
171 const prices = cn(MINIMAX_CN_PRICING_PAGE)
172 // The 优先 tab (3.15) and the struck list price (4.20) are not used.
173 expect(prices.get('MiniMax-M3')).toEqual({
174 base: {
175 input_tokens: 2.1 / 1e6,
176 output_tokens: 8.4 / 1e6,
177 cache_read_tokens: 0.42 / 1e6,
178 },
179 tiers: [
180 {
181 minPromptTokens: 512_000,
182 rates: {
183 input_tokens: 4.2 / 1e6,
184 output_tokens: 16.8 / 1e6,
185 cache_read_tokens: 0.84 / 1e6,
186 },
187 },
188 ],
189 })
190 expect(prices.get('MiniMax-M2.7-highspeed')).toEqual({
191 base: {
192 input_tokens: 4.2 / 1e6,
193 output_tokens: 16.8 / 1e6,
194 cache_read_tokens: 0.42 / 1e6,
195 cache_write_tokens: 2.625 / 1e6,
196 },
197 tiers: [],
198 })
199 expect(prices.get('MiniMax-M2')?.base.cache_read_tokens).toBe(0.21 / 1e6)
200 // No pay-as-you-go price is published for the M Plan preview model.
201 expect(prices.has('MiniMax-M3.1-Flash-Preview')).toBe(false)
202 expect(prices.size).toBe(8)
203 })
204​
205 it('reads nothing across platforms', () => {
206 expect(parseMinimaxPricing(MINIMAX_CN_PRICING_PAGE).size).toBe(0)
207 expect(cn(MINIMAX_PRICING_PAGE).size).toBe(0)
208 })
209​
210 it('refuses a struck price whose badge is not permanent', () => {
211 const promo = MINIMAX_CN_PRICING_PAGE.replaceAll('永久五折', '限时五折')
212 expect(promo).not.toBe(MINIMAX_CN_PRICING_PAGE)
213 expect(cn(promo).has('MiniMax-M3')).toBe(false)
214 expect(cn(promo).size).toBe(7)
215 // One row losing its badge refuses the whole model, not just that tier.
216 const half = MINIMAX_CN_PRICING_PAGE.replace('永久五折', '限时五折')
217 expect(cn(half).has('MiniMax-M3')).toBe(false)
218 })
219​
220 it.each([
221 [
222 'a unit in the cell',
223 '| 2.1 | 8.4 | 0.42 | 2.625 |',
224 '| 2.1 元 | 8.4 | 0.42 | 2.625 |',
225 ],
226 [
227 'a 万 suffix',
228 '| 2.1 | 8.4 | 0.42 | 2.625 |',
229 '| 2.1万 | 8.4 | 0.42 | 2.625 |',
230 ],
231 [
232 'a range',
233 '| 2.1 | 8.4 | 0.42 | 2.625 |',
234 '| 2.1 | 8.4-16.8 | 0.42 | 2.625 |',
235 ],
236 ['a reworded unit', '元/百万 tokens', '元/千 tokens'],
237 ['a renamed section', '## 语言模型', '## 文本模型'],
238 ])('stores no price for %s', (_name, from, to) => {
239 const page = MINIMAX_CN_PRICING_PAGE.replaceAll(from, to)
240 expect(page).not.toBe(MINIMAX_CN_PRICING_PAGE)
241 expect(cn(page).has('MiniMax-M2.7')).toBe(false)
242 })
243})
244​
245/**
246 * Page shapes that once stored a wrong number with no throw. Each must
247 * leave the model unpriced (or the page empty) on both platforms.
248 */
249describe.each([
250 {
251 name: 'minimax',
252 platform: MINIMAX,
253 page: MINIMAX_PRICING_PAGE,
254 tier: '> 512k input tokens',
255 tierRewordings: [
256 'over 512k input tokens',
257 '512k+ input tokens',
258 '> 512k input tokens',
259 '> 51.2万 input tokens',
260 ],
261 priority: '<Tab title="Priority*">',
262 row: '| **MiniMax-M2.7** | \\$0.3 / M tokens | \\$1.2 / M tokens | \\$0.06 / M tokens | \\$0.375 / M tokens |',
263 batchRow:
264 '| **MiniMax-M2.7** | \\$0.15 / M tokens | \\$0.6 / M tokens | \\$0.03 / M tokens | \\$0.1875 / M tokens |',
265 header:
266 '| Model | Input | Output | Prompt caching Read | Prompt caching Write |',
267 cacheHeader: 'Prompt caching Read',
268 cacheCell: ['\\$0.06 / M tokens | \\$0.375', 'free | \\$0.375'],
269 base: { input_tokens: 0.3 / 1e6, output_tokens: 1.2 / 1e6 },
270 },
271 {
272 name: 'minimax-cn',
273 platform: MINIMAX_CN,
274 page: MINIMAX_CN_PRICING_PAGE,
275 tier: '> 512k 输入 tokens',
276 tierRewordings: [
277 '超过 512k 输入 tokens',
278 '512k 以上',
279 '> 512k 输入 tokens',
280 '> 51.2万 输入 tokens',
281 ],
282 priority: '<Tab title="优先*">',
283 row: '| **MiniMax-M2.7** | 2.1 | 8.4 | 0.42 | 2.625 |',
284 batchRow: '| **MiniMax-M2.7** | 1.05 | 4.2 | 0.21 | 1.3125 |',
285 header:
286 '| **模型** | **输入价格**<br /> 元/百万 tokens | **输出价格**<br /> 元/百万 tokens | **缓存读取**<br /> 元/百万 tokens | **缓存写入**<br /> 元/百万 tokens |',
287 cacheHeader: '**缓存读取**<br /> 元/百万 tokens',
288 cacheCell: ['| 2.1 | 8.4 | 0.42 |', '| 2.1 | 8.4 | 免费 |'],
289 base: { input_tokens: 2.1 / 1e6, output_tokens: 8.4 / 1e6 },
290 },
291])('$name pricing refuses what it cannot attribute', (c) => {
292 const parse = (page: string) => parseMinimaxPricing(page, c.platform)
293 const edit = (from: string, to: string, all = true) => {
294 const page = all ? c.page.replaceAll(from, to) : c.page.replace(from, to)
295 expect(page).not.toBe(c.page)
296 return parse(page)
297 }
298​
299 it('reads the page as published', () => {
300 const prices = parse(c.page)
301 expect(prices.size).toBe(8)
302 expect(prices.get('MiniMax-M3')?.tiers).toHaveLength(1)
303 expect(prices.get('MiniMax-M2.7')?.base).toMatchObject(c.base)
304 })
305​
306 it.each(c.tierRewordings)(
307 'a tier bound reworded to %j is never the base price',
308 (reworded) => {
309 const prices = edit(c.tier, reworded)
310 expect(prices.has('MiniMax-M3')).toBe(false)
311 expect(prices.size).toBe(7)
312 },
313 )
314​
315 it.each([
316 ['an extra attribute', (tag: string) => tag.replace('>', ' icon="bolt">')],
317 ['single quotes', (tag: string) => tag.replaceAll('"', "'")],
318 ])('prices nothing when the priority tab tag has %s', (_name, mutate) => {
319 expect(edit(c.priority, mutate(c.priority)).size).toBe(0)
320 })
321​
322 it('refuses the model when tabs become headings and both tiers show', () => {
323 const page = c.page
324 .replace(/<Tab title="[^"]*">/g, '**tier**')
325 .replaceAll('</Tab>', '')
326 expect(page).not.toBe(c.page)
327 const prices = parse(page)
328 expect(prices.has('MiniMax-M3')).toBe(false)
329 expect(prices.size).toBe(7)
330 })
331​
332 it('prices nothing under a sub-heading it cannot attribute', () => {
333 expect(edit(c.header, `### Batch\n\n${c.header}`, false).size).toBe(0)
334 })
335​
336 it('refuses a model a second table prices again', () => {
337 const batch = [c.header, '| :- | :- | :- | :- | :- |', c.batchRow].join(
338 '\n',
339 )
340 const prices = edit(c.row, `${c.row}\n\n**Batch**\n\n${batch}`, false)
341 expect(prices.has('MiniMax-M2.7')).toBe(false)
342 expect(prices.size).toBe(7)
343 })
344​
345 it('refuses a model whose tier threshold repeats', () => {
346 const tierRow = c.page.split('\n').find((line) => line.includes(c.tier))
347 if (!tierRow) throw new Error('no tier row')
348 const prices = edit(tierRow, `${tierRow}\n${tierRow}`, false)
349 expect(prices.has('MiniMax-M3')).toBe(false)
350 })
351​
352 it('refuses a row with a qualifier beside the id', () => {
353 const prices = edit(
354 '**MiniMax-M2.7** |',
355 '**MiniMax-M2.7** (batch) |',
356 false,
357 )
358 expect(prices.has('MiniMax-M2.7')).toBe(false)
359 })
360​
361 it('refuses a row whose cache cell does not read, rather than drop the lever', () => {
362 const prices = edit(c.cacheCell[0] ?? '', c.cacheCell[1] ?? '', false)
363 expect(prices.has('MiniMax-M2.7')).toBe(false)
364 expect(prices.size).toBe(7)
365 })
366​
367 describe('accordions', () => {
368 const legacy = `<Accordion title="${c.platform.legacyAccordion}">`
369 const published = JSON.stringify([...parse(c.page)])
370 const same = (page: string) => {
371 expect(page).not.toBe(c.page)
372 expect(JSON.stringify([...parse(page)])).toBe(published)
373 }
374​
375 it('ignores a text-only accordion, whatever its title or attributes', () => {
376 const faq =
377 '<Accordion title="FAQ" icon="circle-question">\n Prices exclude tax.\n\n | Tier | Note |\n | :- | :- |\n | Standard | default |\n</Accordion>\n\n'
378 same(c.page.replace(legacy, faq + legacy))
379 same(c.page.replace('<Tabs>', `${faq}<Tabs>`))
380 })
381​
382 it('still reads the legacy accordion when it gains an attribute', () => {
383 same(c.page.replace(legacy, legacy.replace('>', ' defaultOpen>')))
384 same(
385 c.page.replace(
386 legacy,
387 legacy.replace('<Accordion ', '<Accordion icon="clock" '),
388 ),
389 )
390 })
391​
392 it('prices nothing when the legacy accordion is retitled', () => {
393 expect(edit(legacy, '<Accordion title="Batch">').size).toBe(0)
394 })
395​
396 it('prices nothing when an unknown accordion holds a price table', () => {
397 const batch = [
398 '<Accordion title="Batch">',
399 c.header,
400 '| :- | :- | :- | :- | :- |',
401 c.batchRow.replace('MiniMax-M2.7', 'MiniMax-B1'),
402 '</Accordion>',
403 '',
404 legacy,
405 ].join('\n')
406 expect(edit(legacy, batch).size).toBe(0)
407 })
408 })
409​
410 it('refuses a base bound that does not meet the tier', () => {
411 const prices = edit('≤ 512k', '≤ 256k')
412 expect(prices.has('MiniMax-M3')).toBe(false)
413 expect(prices.size).toBe(7)
414 // A bounded base with no tier above it, and a tier over an open base.
415 const tierRow = c.page.split('\n').find((line) => line.includes(c.tier))
416 if (!tierRow) throw new Error('no tier row')
417 expect(edit(`${tierRow}\n`, '', false).has('MiniMax-M3')).toBe(false)
418 expect(edit(c.tier.replace('>', '≤'), '').has('MiniMax-M3')).toBe(false)
419 })
420​
421 it('prices nothing under a header it does not know', () => {
422 expect(edit(c.cacheHeader, `${c.cacheHeader} (peak)`).size).toBe(0)
423 })
424})
425​
426describe('minimax-cn docs', () => {
427 it('reads every context window from the 支持的模型 table', () => {
428 const windows = parseMinimaxContextWindows(MINIMAX_CN_SDK_PAGE, MINIMAX_CN)
429 expect([...windows.keys()]).toEqual(IDS)
430 expect(windows.get('MiniMax-M3.1-Flash-Preview')).toBe(1_000_000)
431 expect(windows.get('MiniMax-M2')).toBe(204_800)
432 // The English wording reads nothing off the Chinese page, and back.
433 expect(parseMinimaxContextWindows(MINIMAX_CN_SDK_PAGE).size).toBe(0)
434 expect(parseMinimaxContextWindows(MINIMAX_SDK_PAGE, MINIMAX_CN).size).toBe(
435 0,
436 )
437 })
438​
439 it('gives image and video input only to the models the table names', () => {
440 const inputs = parseMinimaxInputModalities(
441 MINIMAX_CN_SDK_PAGE,
442 IDS,
443 MINIMAX_CN,
444 )
445 expect(inputs.get('MiniMax-M3.1-Flash-Preview')).toEqual([
446 'text',
447 'image',
448 'video',
449 ])
450 expect(inputs.get('MiniMax-M3')).toEqual(['text', 'image', 'video'])
451 for (const id of IDS.slice(2)) expect(inputs.get(id)).toEqual(['text'])
452 })
453​
454 it('stores no modalities when a support status is reworded', () => {
455 // `M3 不支持` names M3 as the one model without video: it must not
456 // read as the one model with it, nor leave every model text-only.
457 for (const status of ['M3 不支持', '部分支持', 'M3.1-Flash-Preview / M3']) {
458 const reworded = MINIMAX_CN_SDK_PAGE.replace(
459 '| `type="video"` | 仅 M3.1-Flash-Preview / M3 |',
460 `| \`type="video"\` | ${status} |`,
461 )
462 expect(reworded).not.toBe(MINIMAX_CN_SDK_PAGE)
463 expect(parseMinimaxInputModalities(reworded, IDS, MINIMAX_CN).size).toBe(
464 0,
465 )
466 }
467 })
468​
469 it('reads thinking from the control table and efforts for M3.1 only', () => {
470 const reasoning = parseMinimaxReasoning(
471 MINIMAX_CN_SDK_PAGE,
472 IDS,
473 MINIMAX_CN,
474 )
475 expect(reasoning.get('MiniMax-M3.1-Flash-Preview')).toEqual({
476 mode: 'adaptive',
477 mandatory: true,
478 efforts: ['low', 'medium', 'high', 'xhigh', 'max'],
479 })
480 expect(reasoning.get('MiniMax-M3')).toEqual({
481 mode: 'adaptive',
482 mandatory: false,
483 })
484 for (const id of IDS.slice(2)) {
485 expect(reasoning.get(id)).toEqual({ mode: 'adaptive', mandatory: true })
486 }
487 })
488​
489 it('stores no reasoning for a row whose disabled cell is reworded', () => {
490 const reworded = MINIMAX_CN_SDK_PAGE.replace(
491 '保持 thinking 关闭',
492 '可能保持 thinking 关闭',
493 ).replace('thinking 仍保持开启', 'thinking 行为不变')
494 const reasoning = parseMinimaxReasoning(reworded, IDS, MINIMAX_CN)
495 expect([...reasoning.keys()]).toEqual(['MiniMax-M3.1-Flash-Preview'])
496 })
497​
498 it('reads the output cap for the named models and for the rest', () => {
499 const caps = parseMinimaxMaxOutput(
500 MINIMAX_CN_MAX_COMPLETION_TOKENS,
501 IDS,
502 MINIMAX_CN,
503 )
504 // 131072 and 65536 are the recommended values, not the caps.
505 expect(caps.get('MiniMax-M3.1-Flash-Preview')).toBe(524_288)
506 expect(caps.get('MiniMax-M3')).toBe(524_288)
507 for (const id of IDS.slice(2)) expect(caps.get(id)).toBe(204_800)
508 })
509​
510 it('stores no output cap when the clause naming a model is reworded', () => {
511 const reworded = MINIMAX_CN_MAX_COMPLETION_TOKENS.replace(
512 '上限为 524288',
513 '最多 524288',
514 )
515 expect(reworded).not.toBe(MINIMAX_CN_MAX_COMPLETION_TOKENS)
516 expect(parseMinimaxMaxOutput(reworded, IDS, MINIMAX_CN).size).toBe(0)
517 expect(
518 parseMinimaxMaxOutput('其他模型上限为 204800。', IDS, MINIMAX_CN).size,
519 ).toBe(0)
520 })
521})
522​
523// Each rewording below once stored a wrong value. All must store nothing.
524describe('minimax docs rewordings that must not store a value', () => {
525 const EN_M3 =
526 'for MiniMax-M3.1-Flash-Preview and MiniMax-M3 the recommended value is 131072 (128K) and the maximum is 524288 (512K)'
527 const EN_REST =
528 'for other models the recommended value is 65536 (64K) and the maximum is 204800 (200K)'
529 const CN_M3 =
530 'MiniMax-M3.1-Flash-Preview 和 MiniMax-M3 推荐值为 131072(128K),上限为 524288(512K)'
531 const CN_REST = '其他模型推荐值为 65536(64K),上限为 204800(200K)'
532​
533 it('keeps the fixtures in step with the clauses these tests rebuild', () => {
534 expect(MINIMAX_MAX_COMPLETION_TOKENS.toLowerCase()).toContain(
535 `${EN_M3}; ${EN_REST}.`.toLowerCase(),
536 )
537 expect(MINIMAX_CN_MAX_COMPLETION_TOKENS).toContain(`${CN_M3};${CN_REST}。`)
538 })
539​
540 it('refuses a catch-all clause run together with the clause naming ids', () => {
541 for (const text of [
542 `${EN_REST}, ${EN_M3}.`,
543 `${EN_REST} and ${EN_M3}.`,
544 `${EN_M3}, ${EN_REST}.`,
545 ]) {
546 expect(parseMinimaxMaxOutput(text, IDS).size).toBe(0)
547 }
548 for (const text of [
549 `${CN_REST},${CN_M3}。`,
550 `${CN_REST};${CN_M3}。`,
551 `${CN_M3},${CN_REST}。`,
552 ]) {
553 expect(parseMinimaxMaxOutput(text, IDS, MINIMAX_CN).size).toBe(0)
554 }
555 // Reordered with the separator kept, both still parse.
556 expect(
557 parseMinimaxMaxOutput(`${EN_REST}; ${EN_M3}.`, IDS).get('MiniMax-M3'),
558 ).toBe(524_288)
559 expect(
560 parseMinimaxMaxOutput(`${CN_REST};${CN_M3}。`, IDS, MINIMAX_CN).get(
561 'MiniMax-M3',
562 ),
563 ).toBe(524_288)
564 })
565​
566 it('refuses a clause with two maximums', () => {
567 expect(
568 parseMinimaxMaxOutput(
569 'For MiniMax-M3 the maximum is 524288 and for MiniMax-M3.1-Flash-Preview the maximum is 262144; for other models the maximum is 204800.',
570 IDS,
571 ).size,
572 ).toBe(0)
573 expect(
574 parseMinimaxMaxOutput(
575 'MiniMax-M3 上限为 524288,MiniMax-M3.1-Flash-Preview 上限为 262144;其他模型上限为 204800。',
576 IDS,
577 MINIMAX_CN,
578 ).size,
579 ).toBe(0)
580 })
581​
582 it('refuses a maximum written with a unit or a decimal', () => {
583 for (const [m3, rest] of [
584 ['512K', '200K'],
585 ['512k', '200k'],
586 ['512 K', '200 K'],
587 ['0.5M', '0.2M'],
588 ['1M', '200K'],
589 ]) {
590 expect(
591 parseMinimaxMaxOutput(
592 `For MiniMax-M3.1-Flash-Preview and MiniMax-M3 the maximum is ${m3}; for other models the maximum is ${rest}.`,
593 IDS,
594 ).size,
595 ).toBe(0)
596 expect(
597 parseMinimaxMaxOutput(
598 `MiniMax-M3.1-Flash-Preview 和 MiniMax-M3 推荐值为 128K,上限为 ${m3};其他模型推荐值为 64K,上限为 ${rest}。`,
599 IDS,
600 MINIMAX_CN,
601 ).size,
602 ).toBe(0)
603 }
604 expect(
605 parseMinimaxMaxOutput(
606 'MiniMax-M3.1-Flash-Preview 和 MiniMax-M3 上限为 52 万;其他模型上限为 20 万。',
607 IDS,
608 MINIMAX_CN,
609 ).size,
610 ).toBe(0)
611 // One clause with a unit refuses the rest too.
612 expect(
613 parseMinimaxMaxOutput(`${CN_M3};其他模型上限为 200K。`, IDS, MINIMAX_CN)
614 .size,
615 ).toBe(0)
616 })
617​
618 it('does not read a cap on the recommended value as the output cap', () => {
619 expect(
620 parseMinimaxMaxOutput(
621 'MiniMax-M3.1-Flash-Preview 和 MiniMax-M3 推荐值上限为 131072,最高 524288;其他模型推荐值上限为 65536,最高 204800。',
622 IDS,
623 MINIMAX_CN,
624 ).size,
625 ).toBe(0)
626 })
627​
628 it('refuses an input status that names models but is not an only-list', () => {
629 const en = (status: string) => {
630 const page = MINIMAX_SDK_PAGE.replace(
631 '| `type="image"` | M3.1-Flash-Preview / M3 only |',
632 `| \`type="image"\` | ${status} |`,
633 )
634 expect(page).not.toBe(MINIMAX_SDK_PAGE)
635 return parseMinimaxInputModalities(page, IDS)
636 }
637 for (const status of [
638 'Not supported on M2.x',
639 'M2.7 not supported',
640 'All models except M2.7',
641 'M3.1-Flash-Preview / M3',
642 'M2.x only',
643 'M9 only',
644 'Partial support',
645 ]) {
646 expect(en(status).size).toBe(0)
647 }
648 expect(en('M3 only').get('MiniMax-M3.1-Flash-Preview')).toEqual([
649 'text',
650 'video',
651 ])
652​
653 const cn = (status: string) => {
654 const page = MINIMAX_CN_SDK_PAGE.replace(
655 '| `type="image"` | 仅 M3.1-Flash-Preview / M3 |',
656 `| \`type="image"\` | ${status} |`,
657 )
658 expect(page).not.toBe(MINIMAX_CN_SDK_PAGE)
659 return parseMinimaxInputModalities(page, IDS, MINIMAX_CN)
660 }
661 for (const status of [
662 '仅 M2.x 不支持',
663 '仅 M2.7 不支持',
664 '仅 M2.x',
665 '仅 M9',
666 '只支持 M3.1-Flash-Preview / M3',
667 'M3.1-Flash-Preview / M3 专属',
668 ]) {
669 expect(cn(status).size).toBe(0)
670 }
671 expect(cn('仅 M3').get('MiniMax-M3.1-Flash-Preview')).toEqual([
672 'text',
673 'video',
674 ])
675 })
676​
677 it('stores no reasoning for a disabled cell that only mentions the phrase', () => {
678 const en = MINIMAX_SDK_PAGE.replace(
679 '| Thinking stays off |',
680 '| Can be turned off (unlike M2.x, where thinking cannot be disabled) |',
681 ).replace(
682 '| Accepted but ignored; thinking remains on |',
683 '| Thinking can be switched off |',
684 )
685 expect([...parseMinimaxReasoning(en, IDS).keys()]).toEqual([
686 'MiniMax-M3.1-Flash-Preview',
687 ])
688 const cn = MINIMAX_CN_SDK_PAGE.replace(
689 '| 保持 thinking 关闭 |',
690 '| 可关闭(不同于 M2.x 的 thinking 无法关闭) |',
691 ).replace(
692 '| 被接收但不生效,thinking 仍保持开启 |',
693 '| 可以关闭 thinking |',
694 )
695 expect([...parseMinimaxReasoning(cn, IDS, MINIMAX_CN).keys()]).toEqual([
696 'MiniMax-M3.1-Flash-Preview',
697 ])
698 })
699})
700​
701describe('fetchMinimaxPage', () => {
702 const originalFetch = globalThis.fetch
703 afterEach(() => {
704 globalThis.fetch = originalFetch
705 })
706​
707 function answerFrom(finalUrl: string): void {
708 globalThis.fetch = () => {
709 const response = new Response('{}')
710 Object.defineProperty(response, 'url', { value: finalUrl })
711 return Promise.resolve(response)
712 }
713 }
714​
715 it('follows the China redirect and refuses any other host', async () => {
716 const url = MINIMAX_CN.chatSpecUrl
717 answerFrom(url.replace('platform.minimaxi.com', 'platform.minimax.cn'))
718 await expect(fetchMinimaxPage(url, MINIMAX_CN)).resolves.toBe('{}')
719 answerFrom(url)
720 await expect(fetchMinimaxPage(url, MINIMAX_CN)).resolves.toBe('{}')
721​
722 // The international platform publishes the same path.
723 answerFrom(MINIMAX.chatSpecUrl)
724 await expect(fetchMinimaxPage(url, MINIMAX_CN)).rejects.toThrow(
725 'minimax-cn: https://platform.minimaxi.com/docs/api-reference/text/api/openapi-chat-openai.json was answered by platform.minimax.io',
726 )
727 answerFrom('https://platform.minimax.cn.example.com/docs/x.json')
728 await expect(fetchMinimaxPage(url, MINIMAX_CN)).rejects.toThrow(
729 'was answered by platform.minimax.cn.example.com',
730 )
731 answerFrom(url)
732 await expect(
733 fetchMinimaxPage(MINIMAX.chatSpecUrl, MINIMAX),
734 ).rejects.toThrow('minimax: ')
735 })
736})
737​
738describe('a maximum equal to the context window is not an output cap', () => {
739 const originalFetch = globalThis.fetch
740 afterEach(() => {
741 globalThis.fetch = originalFetch
742 })
743​
744 const PLATFORMS = [
745 {
746 platform: MINIMAX,
747 sdk: MINIMAX_SDK_PAGE,
748 pricing: MINIMAX_PRICING_PAGE,
749 description: MINIMAX_MAX_COMPLETION_TOKENS,
750 },
751 {
752 platform: MINIMAX_CN,
753 sdk: MINIMAX_CN_SDK_PAGE,
754 pricing: MINIMAX_CN_PRICING_PAGE,
755 description: MINIMAX_CN_MAX_COMPLETION_TOKENS,
756 },
757 ]
758​
759 for (const { platform, sdk, pricing, description } of PLATFORMS) {
760 const facts = (text: string) => {
761 const pages: Record<string, string> = {
762 [platform.sdkUrl]: sdk,
763 [platform.pricingUrl]: pricing,
764 [platform.chatSpecUrl]: JSON.stringify({
765 max_completion_tokens: { description: text },
766 }),
767 }
768 globalThis.fetch = ((url: string) =>
769 Promise.resolve(new Response(pages[String(url)]))) as typeof fetch
770 return minimaxModelFacts(undefined, platform)
771 }
772​
773 it(`${platform.label}: stores no cap for the M2 rows, 524288 for M3`, async () => {
774 const of = await facts(description)
775 for (const id of IDS.slice(0, 2)) {
776 expect(of(id).contextWindow).toBe(1_000_000)
777 expect(of(id).maxOutput).toBe(524_288)
778 expect(of(id).factSources?.maxOutput?.sourceUrl).toBe(
779 platform.chatSpecUrl,
780 )
781 }
782 expect(IDS.slice(2)).toHaveLength(7)
783 for (const id of IDS.slice(2)) {
784 expect(of(id).contextWindow).toBe(204_800)
785 expect(of(id).maxOutput).toBeNull()
786 expect(of(id).factSources?.maxOutput).toBeUndefined()
787 }
788 })
789​
790 it(`${platform.label}: stores an M2 cap that differs from the window`, async () => {
791 const of = await facts(description.replace('204800', '131072'))
792 for (const id of IDS.slice(2)) {
793 expect(of(id).maxOutput).toBe(131_072)
794 expect(of(id).factSources?.maxOutput?.sourceUrl).toBe(
795 platform.chatSpecUrl,
796 )
797 }
798 expect(of('MiniMax-M3').maxOutput).toBe(524_288)
799 })
800 }
801})