language-models 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Tests for model aliases
3
+ *
4
+ * These tests verify the alias mapping and ensure all documented
5
+ * aliases are present and correctly mapped.
6
+ */
7
+
8
+ import { describe, it, expect } from 'vitest'
9
+ import { ALIASES } from './aliases.js'
10
+
11
+ describe('ALIASES', () => {
12
+ it('is an object', () => {
13
+ expect(typeof ALIASES).toBe('object')
14
+ expect(ALIASES).not.toBeNull()
15
+ })
16
+
17
+ it('has string keys and values', () => {
18
+ for (const [key, value] of Object.entries(ALIASES)) {
19
+ expect(typeof key).toBe('string')
20
+ expect(typeof value).toBe('string')
21
+ }
22
+ })
23
+
24
+ it('has no empty keys or values', () => {
25
+ for (const [key, value] of Object.entries(ALIASES)) {
26
+ expect(key.length).toBeGreaterThan(0)
27
+ expect(value.length).toBeGreaterThan(0)
28
+ }
29
+ })
30
+
31
+ it('all values are valid model IDs with provider prefix', () => {
32
+ for (const [key, value] of Object.entries(ALIASES)) {
33
+ expect(value).toContain('/')
34
+ const [provider, modelName] = value.split('/')
35
+ expect(provider.length).toBeGreaterThan(0)
36
+ expect(modelName.length).toBeGreaterThan(0)
37
+ }
38
+ })
39
+
40
+ describe('Claude (Anthropic) aliases', () => {
41
+ it('has opus alias', () => {
42
+ expect(ALIASES['opus']).toBe('anthropic/claude-opus-4.5')
43
+ })
44
+
45
+ it('has sonnet alias', () => {
46
+ expect(ALIASES['sonnet']).toBe('anthropic/claude-sonnet-4.5')
47
+ })
48
+
49
+ it('has haiku alias', () => {
50
+ expect(ALIASES['haiku']).toBe('anthropic/claude-haiku-4.5')
51
+ })
52
+
53
+ it('has claude default alias', () => {
54
+ expect(ALIASES['claude']).toBe('anthropic/claude-sonnet-4.5')
55
+ })
56
+
57
+ it('claude aliases point to anthropic provider', () => {
58
+ expect(ALIASES['opus']).toContain('anthropic/')
59
+ expect(ALIASES['sonnet']).toContain('anthropic/')
60
+ expect(ALIASES['haiku']).toContain('anthropic/')
61
+ expect(ALIASES['claude']).toContain('anthropic/')
62
+ })
63
+ })
64
+
65
+ describe('GPT (OpenAI) aliases', () => {
66
+ it('has gpt alias', () => {
67
+ expect(ALIASES['gpt']).toBe('openai/gpt-4o')
68
+ })
69
+
70
+ it('has gpt-4o alias', () => {
71
+ expect(ALIASES['gpt-4o']).toBe('openai/gpt-4o')
72
+ })
73
+
74
+ it('has gpt-4o-mini alias', () => {
75
+ expect(ALIASES['gpt-4o-mini']).toBe('openai/gpt-4o-mini')
76
+ })
77
+
78
+ it('has 4o shorthand', () => {
79
+ expect(ALIASES['4o']).toBe('openai/gpt-4o')
80
+ })
81
+
82
+ it('has o1 alias', () => {
83
+ expect(ALIASES['o1']).toBe('openai/o1')
84
+ })
85
+
86
+ it('has o3 alias', () => {
87
+ expect(ALIASES['o3']).toBe('openai/o3')
88
+ })
89
+
90
+ it('has o3-mini alias', () => {
91
+ expect(ALIASES['o3-mini']).toBe('openai/o3-mini')
92
+ })
93
+
94
+ it('has o4-mini alias', () => {
95
+ expect(ALIASES['o4-mini']).toBe('openai/o4-mini')
96
+ })
97
+
98
+ it('openai aliases point to openai provider', () => {
99
+ expect(ALIASES['gpt']).toContain('openai/')
100
+ expect(ALIASES['gpt-4o']).toContain('openai/')
101
+ expect(ALIASES['4o']).toContain('openai/')
102
+ expect(ALIASES['o1']).toContain('openai/')
103
+ expect(ALIASES['o3']).toContain('openai/')
104
+ })
105
+ })
106
+
107
+ describe('Gemini (Google) aliases', () => {
108
+ it('has gemini alias', () => {
109
+ expect(ALIASES['gemini']).toBe('google/gemini-2.5-flash')
110
+ })
111
+
112
+ it('has flash alias', () => {
113
+ expect(ALIASES['flash']).toBe('google/gemini-2.5-flash')
114
+ })
115
+
116
+ it('has gemini-flash alias', () => {
117
+ expect(ALIASES['gemini-flash']).toBe('google/gemini-2.5-flash')
118
+ })
119
+
120
+ it('has gemini-pro alias', () => {
121
+ expect(ALIASES['gemini-pro']).toBe('google/gemini-2.5-pro')
122
+ })
123
+
124
+ it('google aliases point to google provider', () => {
125
+ expect(ALIASES['gemini']).toContain('google/')
126
+ expect(ALIASES['flash']).toContain('google/')
127
+ expect(ALIASES['gemini-flash']).toContain('google/')
128
+ expect(ALIASES['gemini-pro']).toContain('google/')
129
+ })
130
+ })
131
+
132
+ describe('Llama (Meta) aliases', () => {
133
+ it('has llama alias', () => {
134
+ expect(ALIASES['llama']).toBe('meta-llama/llama-4-maverick')
135
+ })
136
+
137
+ it('has llama-4 alias', () => {
138
+ expect(ALIASES['llama-4']).toBe('meta-llama/llama-4-maverick')
139
+ })
140
+
141
+ it('has llama-70b alias', () => {
142
+ expect(ALIASES['llama-70b']).toBe('meta-llama/llama-3.3-70b-instruct')
143
+ })
144
+
145
+ it('llama aliases point to meta-llama provider', () => {
146
+ expect(ALIASES['llama']).toContain('meta-llama/')
147
+ expect(ALIASES['llama-4']).toContain('meta-llama/')
148
+ expect(ALIASES['llama-70b']).toContain('meta-llama/')
149
+ })
150
+ })
151
+
152
+ describe('DeepSeek aliases', () => {
153
+ it('has deepseek alias', () => {
154
+ expect(ALIASES['deepseek']).toBe('deepseek/deepseek-chat')
155
+ })
156
+
157
+ it('has r1 alias', () => {
158
+ expect(ALIASES['r1']).toBe('deepseek/deepseek-r1')
159
+ })
160
+
161
+ it('deepseek aliases point to deepseek provider', () => {
162
+ expect(ALIASES['deepseek']).toContain('deepseek/')
163
+ expect(ALIASES['r1']).toContain('deepseek/')
164
+ })
165
+ })
166
+
167
+ describe('Mistral aliases', () => {
168
+ it('has mistral alias', () => {
169
+ expect(ALIASES['mistral']).toBe('mistralai/mistral-large-2411')
170
+ })
171
+
172
+ it('has codestral alias', () => {
173
+ expect(ALIASES['codestral']).toBe('mistralai/codestral-2501')
174
+ })
175
+
176
+ it('mistral aliases point to mistralai provider', () => {
177
+ expect(ALIASES['mistral']).toContain('mistralai/')
178
+ expect(ALIASES['codestral']).toContain('mistralai/')
179
+ })
180
+ })
181
+
182
+ describe('Qwen aliases', () => {
183
+ it('has qwen alias', () => {
184
+ expect(ALIASES['qwen']).toBe('qwen/qwen3-235b-a22b')
185
+ })
186
+
187
+ it('qwen alias points to qwen provider', () => {
188
+ expect(ALIASES['qwen']).toContain('qwen/')
189
+ })
190
+ })
191
+
192
+ describe('Grok (X.AI) aliases', () => {
193
+ it('has grok alias', () => {
194
+ expect(ALIASES['grok']).toBe('x-ai/grok-3')
195
+ })
196
+
197
+ it('grok alias points to x-ai provider', () => {
198
+ expect(ALIASES['grok']).toContain('x-ai/')
199
+ })
200
+ })
201
+
202
+ describe('Perplexity aliases', () => {
203
+ it('has sonar alias', () => {
204
+ expect(ALIASES['sonar']).toBe('perplexity/sonar-pro')
205
+ })
206
+
207
+ it('sonar alias points to perplexity provider', () => {
208
+ expect(ALIASES['sonar']).toContain('perplexity/')
209
+ })
210
+ })
211
+
212
+ describe('alias uniqueness', () => {
213
+ it('has no duplicate keys', () => {
214
+ const keys = Object.keys(ALIASES)
215
+ const uniqueKeys = new Set(keys)
216
+ expect(keys.length).toBe(uniqueKeys.size)
217
+ })
218
+
219
+ it('has unique lowercase keys', () => {
220
+ const lowerKeys = Object.keys(ALIASES).map(k => k.toLowerCase())
221
+ const uniqueLowerKeys = new Set(lowerKeys)
222
+ expect(lowerKeys.length).toBe(uniqueLowerKeys.size)
223
+ })
224
+ })
225
+
226
+ describe('alias conventions', () => {
227
+ it('uses lowercase keys', () => {
228
+ for (const key of Object.keys(ALIASES)) {
229
+ expect(key).toBe(key.toLowerCase())
230
+ }
231
+ })
232
+
233
+ it('uses lowercase provider names in values', () => {
234
+ for (const value of Object.values(ALIASES)) {
235
+ const provider = value.split('/')[0]
236
+ expect(provider).toBe(provider.toLowerCase())
237
+ }
238
+ })
239
+
240
+ it('uses kebab-case or lowercase for model names', () => {
241
+ for (const value of Object.values(ALIASES)) {
242
+ const modelName = value.split('/')[1]
243
+ // Model names should not have uppercase letters or spaces
244
+ expect(modelName).not.toMatch(/[A-Z]/)
245
+ expect(modelName).not.toContain(' ')
246
+ }
247
+ })
248
+ })
249
+
250
+ describe('provider coverage', () => {
251
+ it('covers major AI providers', () => {
252
+ const providers = new Set(
253
+ Object.values(ALIASES).map(v => v.split('/')[0])
254
+ )
255
+
256
+ expect(providers.has('anthropic')).toBe(true)
257
+ expect(providers.has('openai')).toBe(true)
258
+ expect(providers.has('google')).toBe(true)
259
+ expect(providers.has('meta-llama')).toBe(true)
260
+ })
261
+
262
+ it('has multiple aliases per major provider', () => {
263
+ const providerCounts: Record<string, number> = {}
264
+
265
+ for (const value of Object.values(ALIASES)) {
266
+ const provider = value.split('/')[0]
267
+ providerCounts[provider] = (providerCounts[provider] || 0) + 1
268
+ }
269
+
270
+ // Major providers should have multiple aliases
271
+ expect(providerCounts['anthropic']).toBeGreaterThanOrEqual(3)
272
+ expect(providerCounts['openai']).toBeGreaterThanOrEqual(5)
273
+ expect(providerCounts['google']).toBeGreaterThanOrEqual(3)
274
+ })
275
+ })
276
+
277
+ describe('README documentation alignment', () => {
278
+ it('matches all aliases documented in README', () => {
279
+ // These are the aliases listed in the README.md table
280
+ const documentedAliases = {
281
+ 'opus': 'anthropic/claude-opus-4.5',
282
+ 'sonnet': 'anthropic/claude-sonnet-4.5',
283
+ 'haiku': 'anthropic/claude-haiku-4.5',
284
+ 'claude': 'anthropic/claude-sonnet-4.5',
285
+ 'gpt': 'openai/gpt-4o',
286
+ 'gpt-4o': 'openai/gpt-4o',
287
+ '4o': 'openai/gpt-4o',
288
+ 'o1': 'openai/o1',
289
+ 'o3': 'openai/o3',
290
+ 'o3-mini': 'openai/o3-mini',
291
+ 'gemini': 'google/gemini-2.5-flash',
292
+ 'flash': 'google/gemini-2.5-flash',
293
+ 'gemini-pro': 'google/gemini-2.5-pro',
294
+ 'llama': 'meta-llama/llama-4-maverick',
295
+ 'llama-4': 'meta-llama/llama-4-maverick',
296
+ 'llama-70b': 'meta-llama/llama-3.3-70b-instruct',
297
+ 'mistral': 'mistralai/mistral-large-2411',
298
+ 'codestral': 'mistralai/codestral-2501',
299
+ 'deepseek': 'deepseek/deepseek-chat',
300
+ 'r1': 'deepseek/deepseek-r1',
301
+ 'qwen': 'qwen/qwen3-235b-a22b',
302
+ 'grok': 'x-ai/grok-3',
303
+ 'sonar': 'perplexity/sonar-pro',
304
+ }
305
+
306
+ for (const [alias, expectedId] of Object.entries(documentedAliases)) {
307
+ expect(ALIASES[alias]).toBe(expectedId)
308
+ }
309
+ })
310
+ })
311
+
312
+ describe('alias count', () => {
313
+ it('has reasonable number of aliases', () => {
314
+ const count = Object.keys(ALIASES).length
315
+ expect(count).toBeGreaterThanOrEqual(20)
316
+ expect(count).toBeLessThanOrEqual(100)
317
+ })
318
+ })
319
+ })
package/src/aliases.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Model aliases - map simple names to full model IDs
3
+ */
4
+
5
+ export const ALIASES: Record<string, string> = {
6
+ // Claude (Anthropic)
7
+ 'opus': 'anthropic/claude-opus-4.5',
8
+ 'sonnet': 'anthropic/claude-sonnet-4.5',
9
+ 'haiku': 'anthropic/claude-haiku-4.5',
10
+ 'claude': 'anthropic/claude-sonnet-4.5',
11
+
12
+ // GPT (OpenAI)
13
+ 'gpt': 'openai/gpt-4o',
14
+ 'gpt-4o': 'openai/gpt-4o',
15
+ 'gpt-4o-mini': 'openai/gpt-4o-mini',
16
+ '4o': 'openai/gpt-4o',
17
+ 'o1': 'openai/o1',
18
+ 'o3': 'openai/o3',
19
+ 'o3-mini': 'openai/o3-mini',
20
+ 'o4-mini': 'openai/o4-mini',
21
+
22
+ // Gemini (Google)
23
+ 'gemini': 'google/gemini-2.5-flash',
24
+ 'flash': 'google/gemini-2.5-flash',
25
+ 'gemini-flash': 'google/gemini-2.5-flash',
26
+ 'gemini-pro': 'google/gemini-2.5-pro',
27
+
28
+ // Llama (Meta)
29
+ 'llama': 'meta-llama/llama-4-maverick',
30
+ 'llama-4': 'meta-llama/llama-4-maverick',
31
+ 'llama-70b': 'meta-llama/llama-3.3-70b-instruct',
32
+
33
+ // DeepSeek
34
+ 'deepseek': 'deepseek/deepseek-chat',
35
+ 'r1': 'deepseek/deepseek-r1',
36
+
37
+ // Mistral
38
+ 'mistral': 'mistralai/mistral-large-2411',
39
+ 'codestral': 'mistralai/codestral-2501',
40
+
41
+ // Qwen
42
+ 'qwen': 'qwen/qwen3-235b-a22b',
43
+
44
+ // Grok
45
+ 'grok': 'x-ai/grok-3',
46
+
47
+ // Perplexity
48
+ 'sonar': 'perplexity/sonar-pro',
49
+ }