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

model-meta.test.ts

136 lines4.4 KB

1import { describe, expect, it } from 'vitest'
2import {
3 BYTEPLUS_CHAT_MODELS,
4 BYTEPLUS_IMAGE_MAX_REFERENCE_IMAGES,
5 BYTEPLUS_IMAGE_MODELS,
6 BYTEPLUS_STRUCTURED_OUTPUT_CHAT_MODELS,
7 BYTEPLUS_THINKING_SUMMARY_MODELS,
8 BYTEPLUS_VIDEO_DURATIONS,
9 BYTEPLUS_VIDEO_MODELS,
10 emitsEncryptedContent,
11 getBytePlusVideoDurationOptions,
12 supportsStructuredOutput,
13} from '../src/index'
14​
15describe('model lists', () => {
16 it('has no duplicate ids across a kind', () => {
17 for (const models of [
18 BYTEPLUS_CHAT_MODELS,
19 BYTEPLUS_VIDEO_MODELS,
20 BYTEPLUS_IMAGE_MODELS,
21 ]) {
22 expect(new Set(models).size).toBe(models.length)
23 }
24 })
25​
26 it('only ships dated model ids', () => {
27 for (const model of [
28 ...BYTEPLUS_CHAT_MODELS,
29 ...BYTEPLUS_VIDEO_MODELS,
30 ...BYTEPLUS_IMAGE_MODELS,
31 ]) {
32 expect(model).toMatch(/-\d{6}$/)
33 }
34 })
35​
36 it('keeps the prefixes the API requires', () => {
37 // Seedance 2.x only resolves with the `dreamina-` prefix, and the 2.1
38 // turbo chat model / 5.0 Pro image model echo back the `dola-` prefix.
39 for (const model of BYTEPLUS_VIDEO_MODELS) {
40 if (/seedance-2-[05]/.test(model)) {
41 expect(model.startsWith('dreamina-')).toBe(true)
42 }
43 }
44 expect(BYTEPLUS_VIDEO_MODELS).toContain('dreamina-seedance-2-5-260628')
45 expect(BYTEPLUS_CHAT_MODELS).toContain('dola-seed-2-1-turbo-260628')
46 expect(BYTEPLUS_IMAGE_MODELS).toContain('dola-seedream-5-0-pro-260628')
47 })
48})
49​
50describe('chat capability sets', () => {
51 it('draws thinking-summary models from the chat list', () => {
52 for (const model of BYTEPLUS_THINKING_SUMMARY_MODELS) {
53 expect(BYTEPLUS_CHAT_MODELS).toContain(model)
54 expect(emitsEncryptedContent(model)).toBe(true)
55 }
56 })
57​
58 it('draws structured-output models from the chat list', () => {
59 for (const model of BYTEPLUS_STRUCTURED_OUTPUT_CHAT_MODELS) {
60 expect(BYTEPLUS_CHAT_MODELS).toContain(model)
61 expect(supportsStructuredOutput(model)).toBe(true)
62 }
63 })
64​
65 // The live probe contradicts the BytePlus capability tables for five models,
66 // so both directions are pinned here.
67 it('excludes the models that reject a JSON schema', () => {
68 for (const model of [
69 'seed-2-0-lite-260428',
70 'seed-2-0-mini-260428',
71 'seed-2-0-code-preview-260328',
72 'deepseek-v4-pro-260425',
73 'deepseek-v4-flash-260425',
74 'deepseek-v3-2-251201',
75 'gpt-oss-120b-250805',
76 ]) {
77 expect(supportsStructuredOutput(model)).toBe(false)
78 }
79 })
80​
81 it('excludes glm-4-7, which accepts a schema but ignores it', () => {
82 // The only model that fails on adherence rather than on the request: it
83 // answers 200 and then returns prose. Pinned separately so a future
84 // status-code-only probe does not "restore" it.
85 expect(supportsStructuredOutput('glm-4-7-251222')).toBe(false)
86 })
87​
88 it('includes the models the docs wrongly mark as unsupported', () => {
89 for (const model of ['seed-2-0-pro-260328', 'glm-5-2-260617']) {
90 expect(supportsStructuredOutput(model)).toBe(true)
91 }
92 })
93​
94 it('has exactly the ten verified structured-output models', () => {
95 expect(BYTEPLUS_STRUCTURED_OUTPUT_CHAT_MODELS).toHaveLength(10)
96 })
97​
98 it('reports unknown models as unsupported rather than throwing', () => {
99 expect(supportsStructuredOutput('not-a-model')).toBe(false)
100 expect(emitsEncryptedContent('not-a-model')).toBe(false)
101 })
102})
103​
104describe('video durations', () => {
105 it('covers every video model', () => {
106 for (const model of BYTEPLUS_VIDEO_MODELS) {
107 expect(BYTEPLUS_VIDEO_DURATIONS[model].kind).toBe('range')
108 }
109 })
110​
111 it('encodes the per-family ranges', () => {
112 expect(
113 getBytePlusVideoDurationOptions('dreamina-seedance-2-5-260628'),
114 ).toMatchObject({ min: 4, max: 30 })
115 expect(
116 getBytePlusVideoDurationOptions('dreamina-seedance-2-0-260128'),
117 ).toMatchObject({ min: 4, max: 15 })
118 expect(
119 getBytePlusVideoDurationOptions('seedance-1-5-pro-251215'),
120 ).toMatchObject({ min: 4, max: 12 })
121 expect(
122 getBytePlusVideoDurationOptions('seedance-1-0-pro-250528'),
123 ).toMatchObject({ min: 2, max: 12 })
124 })
125})
126​
127describe('image reference limits', () => {
128 it('caps Seedream 5.0 Pro lower than the rest', () => {
129 expect(
130 BYTEPLUS_IMAGE_MAX_REFERENCE_IMAGES['dola-seedream-5-0-pro-260628'],
131 ).toBe(10)
132 for (const model of BYTEPLUS_IMAGE_MODELS) {
133 expect(BYTEPLUS_IMAGE_MAX_REFERENCE_IMAGES[model]).toBeGreaterThan(0)
134 }
135 })
136})