Open History to see the last commit
1import { readFileSync } from 'node:fs'
2
3import { describe, expect, it } from 'vitest'
4
5import { parseCohereModelTable } from './cohere-model-docs.ts'
6
7// The Command, North, Embed and Aya sections of
8// https://docs.cohere.com/docs/models.md, fetched 2026-10-07.
9const PAGE = readFileSync(
10 new URL('./fixtures/cohere-models.md.txt', import.meta.url),
11 'utf8',
12)
13
14describe('cohere models page', () => {
15 const rows = parseCohereModelTable(PAGE)
16
17 it('reads the output cap and input modalities of each chat row', () => {
18 expect(rows.get('command-a-plus-05-2026')).toEqual({
19 live: true,
20 input: ['text', 'image'],
21 maxOutput: 64000,
22 })
23 expect(rows.get('command-a-03-2025')).toEqual({
24 live: true,
25 input: ['text'],
26 maxOutput: 8000,
27 })
28 expect(rows.get('command-a-reasoning-08-2025')?.maxOutput).toBe(32000)
29 expect(rows.get('command-a-vision-07-2025')).toEqual({
30 live: true,
31 input: ['text', 'image'],
32 maxOutput: 8000,
33 })
34 expect(rows.get('north-mini-code-1-0')?.maxOutput).toBe(64000)
35 expect(rows.get('c4ai-aya-vision-32b')?.input).toEqual(['text', 'image'])
36 expect(rows.get('tiny-aya-fire')?.maxOutput).toBe(8000)
37 })
38
39 it('marks only `Live` rows live', () => {
40 expect(rows.get('command-r-08-2024')?.live).toBe(true)
41 expect(rows.get('command-r-03-2024')?.live).toBe(false)
42 expect(rows.get('c4ai-aya-expanse-8b')?.live).toBe(false)
43 })
44
45 it('skips tables without the chat columns', () => {
46 expect(rows.has('embed-v4.0')).toBe(false)
47 expect(rows.has('command-r-plus')).toBe(true)
48 expect(rows.size).toBe(24)
49 })
50
51 it('drops a row whose cells are reworded rather than guessing', () => {
52 const row = (modality: string, output: string, endpoint: string) =>
53 [
54 '| Model Name | Status | Description | Modality | Context Length | Maximum Output Tokens | Endpoints |',
55 '| --- | --- | --- | --- | --- | --- | --- |',
56 `| \`command-x-01-2027\` | Live | New | ${modality} | 256k | ${output} | ${endpoint} |`,
57 ].join('\n')
58 const chat = '[Chat](../reference/chat)'
59 expect(parseCohereModelTable(row('Text', '8k', chat)).size).toBe(1)
60 expect(parseCohereModelTable(row('Text, Audio', '8k', chat)).size).toBe(0)
61 expect(parseCohereModelTable(row('Text', '8,192', chat)).size).toBe(0)
62 expect(parseCohereModelTable(row('Text', 'up to 8k', chat)).size).toBe(0)
63 expect(parseCohereModelTable(row('Text', '8k (32k beta)', chat)).size).toBe(
64 0,
65 )
66 expect(
67 parseCohereModelTable(row('Text', '8k', '[Embed](../reference/embed)'))
68 .size,
69 ).toBe(0)
70 // A renamed column takes the whole table with it.
71 expect(
72 parseCohereModelTable(
73 row('Text', '8k', chat).replace('Maximum Output Tokens', 'Max Output'),
74 ).size,
75 ).toBe(0)
76 // A 200 "Page Not Found" body has no table.
77 expect(parseCohereModelTable('# Page Not Found\n').size).toBe(0)
78 })
79})