aimodels 0.1.0 → 0.1.2

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.
package/dist/index.mjs CHANGED
@@ -1,83 +1,480 @@
1
- // src/data/models.json
2
- var models_default = [
3
- {
4
- id: "gpt-4",
5
- name: "GPT-4",
6
- provider: "openai",
7
- contextWindow: 8192,
8
- capabilities: ["chat", "completion"],
9
- pricing: {
10
- input: 0.03,
11
- output: 0.06
12
- },
13
- released: "2023-03-14",
14
- parameters: 11e11
15
- },
16
- {
17
- id: "gpt-3.5-turbo",
18
- name: "GPT-3.5 Turbo",
19
- provider: "openai",
20
- contextWindow: 4096,
21
- capabilities: ["chat", "completion"],
22
- pricing: {
23
- input: 15e-4,
24
- output: 2e-3
25
- },
26
- released: "2022-11-30"
27
- },
28
- {
29
- id: "claude-2.1",
30
- name: "Claude 2.1",
31
- provider: "anthropic",
32
- contextWindow: 2e5,
33
- capabilities: ["chat", "completion"],
34
- pricing: {
35
- input: 8e-3,
36
- output: 0.024
37
- },
38
- released: "2023-11-21"
39
- },
40
- {
41
- id: "llama-2-70b",
42
- name: "Llama 2 70B",
43
- provider: "meta",
44
- contextWindow: 4096,
45
- capabilities: ["chat", "completion"],
46
- pricing: {
47
- input: 0,
48
- output: 0
49
- },
50
- released: "2023-07-18",
51
- license: "Llama 2 Community License",
52
- parameters: 7e10
1
+ // src/data/models/openai.json
2
+ var openai_default = {
3
+ models: [
4
+ {
5
+ id: "whisper-1",
6
+ name: "Whisper-1",
7
+ license: "proprietary",
8
+ providers: ["openai"],
9
+ can: ["sound-in", "text-out"],
10
+ context: {
11
+ total: null,
12
+ maxOutput: null
13
+ }
14
+ },
15
+ {
16
+ id: "tts-1",
17
+ name: "TTS-1",
18
+ license: "proprietary",
19
+ providers: ["openai"],
20
+ can: ["text-in", "sound-out"],
21
+ context: {
22
+ total: null,
23
+ maxOutput: null
24
+ }
25
+ },
26
+ {
27
+ id: "tts-1-hd",
28
+ name: "TTS-1 HD",
29
+ license: "proprietary",
30
+ providers: ["openai"],
31
+ can: ["text-in", "sound-out"],
32
+ context: {
33
+ total: null,
34
+ maxOutput: null
35
+ }
36
+ },
37
+ {
38
+ id: "gpt-4o",
39
+ name: "GPT-4O",
40
+ license: "proprietary",
41
+ providers: ["openai"],
42
+ can: ["chat", "img-in", "json-out", "function-out"],
43
+ context: {
44
+ total: 128e3,
45
+ maxOutput: 16384
46
+ }
47
+ },
48
+ {
49
+ id: "gpt-4o-mini",
50
+ name: "GPT-4O Mini",
51
+ license: "proprietary",
52
+ providers: ["openai"],
53
+ can: ["chat", "img-in", "json-out", "function-out"],
54
+ context: {
55
+ total: 128e3,
56
+ maxOutput: 16384
57
+ }
58
+ },
59
+ {
60
+ id: "o1",
61
+ name: "OpenAI O1",
62
+ license: "proprietary",
63
+ providers: ["openai"],
64
+ can: ["chat", "img-in", "json-out", "function-out"],
65
+ context: {
66
+ total: 2e5,
67
+ maxOutput: 1e5
68
+ }
69
+ },
70
+ {
71
+ id: "o1-mini",
72
+ name: "OpenAI O1 Mini",
73
+ license: "proprietary",
74
+ providers: ["openai"],
75
+ can: ["chat", "json-out", "function-out"],
76
+ context: {
77
+ total: 128e3,
78
+ maxOutput: 65536
79
+ }
80
+ },
81
+ {
82
+ id: "o3-mini",
83
+ name: "OpenAI O3 Mini",
84
+ license: "proprietary",
85
+ providers: ["openai"],
86
+ can: ["chat", "json-out", "function-out"],
87
+ context: {
88
+ total: 2e5,
89
+ maxOutput: 1e5
90
+ }
91
+ },
92
+ {
93
+ id: "gpt-4o-audio-preview",
94
+ name: "GPT-4O Audio",
95
+ license: "proprietary",
96
+ providers: ["openai"],
97
+ can: ["chat", "sound-in", "json-out", "function-out"],
98
+ context: {
99
+ total: 128e3,
100
+ maxOutput: 16384
101
+ }
102
+ },
103
+ {
104
+ id: "gpt-4o-realtime-preview",
105
+ name: "GPT-4O Realtime",
106
+ license: "proprietary",
107
+ providers: ["openai"],
108
+ can: ["chat", "sound-in", "json-out", "function-out"],
109
+ context: {
110
+ total: 128e3,
111
+ maxOutput: 4096
112
+ }
113
+ },
114
+ {
115
+ id: "dall-e-3",
116
+ name: "DALL-E 3",
117
+ license: "proprietary",
118
+ providers: ["openai"],
119
+ can: ["img-out"],
120
+ context: {
121
+ maxOutput: 1,
122
+ sizes: [
123
+ "1024x1024",
124
+ "1024x1792",
125
+ "1792x1024"
126
+ ],
127
+ qualities: [
128
+ "standard",
129
+ "hd"
130
+ ]
131
+ }
132
+ }
133
+ ]
134
+ };
135
+
136
+ // src/data/models/anthropic.json
137
+ var anthropic_default = {
138
+ models: [
139
+ {
140
+ id: "claude-3-opus",
141
+ name: "Claude 3 Opus",
142
+ license: "proprietary",
143
+ providers: ["anthropic"],
144
+ can: ["chat", "img-in", "json-out", "function-out"],
145
+ context: {
146
+ total: 2e5,
147
+ maxOutput: 4096
148
+ }
149
+ },
150
+ {
151
+ id: "claude-3-sonnet",
152
+ name: "Claude 3 Sonnet",
153
+ license: "proprietary",
154
+ providers: ["anthropic"],
155
+ can: ["chat", "img-in", "json-out", "function-out"],
156
+ context: {
157
+ total: 2e5,
158
+ maxOutput: 4096
159
+ }
160
+ },
161
+ {
162
+ id: "claude-3-haiku",
163
+ name: "Claude 3 Haiku",
164
+ license: "proprietary",
165
+ providers: ["anthropic"],
166
+ can: ["chat", "img-in", "json-out", "function-out"],
167
+ context: {
168
+ total: 2e5,
169
+ maxOutput: 4096
170
+ }
171
+ }
172
+ ]
173
+ };
174
+
175
+ // src/data/models/meta.json
176
+ var meta_default = {
177
+ models: [
178
+ {
179
+ id: "llama2-70b-4096",
180
+ name: "Llama 2 70B",
181
+ license: "llama-2-community",
182
+ providers: ["groq", "ollama"],
183
+ can: ["chat", "json-out", "function-out"],
184
+ context: {
185
+ total: 4096,
186
+ maxOutput: 4096
187
+ }
188
+ }
189
+ ]
190
+ };
191
+
192
+ // src/data/models/mistral.json
193
+ var mistral_default = {
194
+ models: [
195
+ {
196
+ id: "mixtral-8x7b-32768",
197
+ name: "Mixtral 8x7B",
198
+ license: "apache-2.0",
199
+ providers: ["groq"],
200
+ can: ["chat", "json-out", "function-out"],
201
+ context: {
202
+ total: 32768,
203
+ maxOutput: 4096
204
+ }
205
+ }
206
+ ]
207
+ };
208
+
209
+ // src/builders/models.ts
210
+ function buildAllModels() {
211
+ return [
212
+ ...openai_default.models,
213
+ ...anthropic_default.models,
214
+ ...meta_default.models,
215
+ ...mistral_default.models
216
+ ];
217
+ }
218
+
219
+ // src/data/providers/openai.json
220
+ var openai_default2 = {
221
+ id: "openai",
222
+ name: "OpenAI",
223
+ websiteUrl: "https://openai.com/",
224
+ apiUrl: "https://api.openai.com/v1",
225
+ defaultModel: "gpt-4o",
226
+ models: {
227
+ "gpt-4o": {
228
+ type: "token",
229
+ input: 20,
230
+ output: 80
231
+ },
232
+ "gpt-3.5-turbo": {
233
+ type: "token",
234
+ input: 5,
235
+ output: 20
236
+ },
237
+ "gpt-4o-vision": {
238
+ type: "token",
239
+ input: 15,
240
+ input_cached: 7.5,
241
+ output: 60
242
+ },
243
+ "o1-mini": {
244
+ type: "token",
245
+ input: 3,
246
+ input_cached: 1.5,
247
+ output: 15
248
+ },
249
+ "o3-mini": {
250
+ type: "token",
251
+ input: 3,
252
+ input_cached: 1.5,
253
+ output: 15
254
+ },
255
+ "gpt-4o-audio-preview": {
256
+ type: "token",
257
+ input: 20,
258
+ output: 80
259
+ },
260
+ "gpt-4o-vision-preview": {
261
+ type: "token",
262
+ input: 20,
263
+ output: 80
264
+ },
265
+ "whisper-1": {
266
+ type: "minute",
267
+ price: 6e-3
268
+ },
269
+ "tts-1": {
270
+ type: "character",
271
+ price: 15e-6
272
+ },
273
+ "tts-1-hd": {
274
+ type: "character",
275
+ price: 3e-5
276
+ },
277
+ "dall-e-2": {
278
+ type: "image",
279
+ price: 0.016,
280
+ size: "256x256",
281
+ unit: "per_image"
282
+ },
283
+ "dall-e-2-512": {
284
+ type: "image",
285
+ price: 0.018,
286
+ size: "512x512",
287
+ unit: "per_image"
288
+ },
289
+ "dall-e-2-1024": {
290
+ type: "image",
291
+ price: 0.02,
292
+ size: "1024x1024",
293
+ unit: "per_image"
294
+ },
295
+ "dall-e-3": {
296
+ type: "image",
297
+ price: 0.04,
298
+ size: "1024x1024",
299
+ unit: "per_image"
300
+ },
301
+ "dall-e-3-hd": {
302
+ type: "image",
303
+ price: 0.08,
304
+ size: "1024x1024",
305
+ unit: "per_image"
306
+ }
53
307
  }
54
- ];
308
+ };
309
+
310
+ // src/data/providers/anthropic.json
311
+ var anthropic_default2 = {
312
+ id: "anthropic",
313
+ name: "Anthropic",
314
+ websiteUrl: "https://www.anthropic.com/",
315
+ apiUrl: "https://api.anthropic.com/v1",
316
+ defaultModel: "claude-3-sonnet",
317
+ models: {
318
+ "claude-3-opus": {
319
+ type: "token",
320
+ input: 15,
321
+ output: 75
322
+ },
323
+ "claude-3-sonnet": {
324
+ type: "token",
325
+ input: 3,
326
+ output: 15
327
+ },
328
+ "claude-3-haiku": {
329
+ type: "token",
330
+ input: 2.5,
331
+ output: 12.5
332
+ }
333
+ }
334
+ };
335
+
336
+ // src/data/providers/mistral.json
337
+ var mistral_default2 = {
338
+ id: "mistral",
339
+ name: "Mistral",
340
+ websiteUrl: "https://mistral.ai/",
341
+ apiUrl: "https://api.mistral.ai/v1",
342
+ defaultModel: "mixtral-8x7b-32768",
343
+ models: {
344
+ "mixtral-8x7b-32768": {
345
+ type: "token",
346
+ input: 0.7,
347
+ output: 0.7
348
+ },
349
+ "mistral-large-latest": {
350
+ type: "token",
351
+ input: 0.7,
352
+ output: 0.7
353
+ }
354
+ }
355
+ };
356
+
357
+ // src/builders/providers.ts
358
+ function isTokenPrice(price) {
359
+ return typeof price === "object" && price !== null && "type" in price && price.type === "token" && "input" in price && typeof price.input === "number" && "output" in price && typeof price.output === "number";
360
+ }
361
+ function isImagePrice(price) {
362
+ return typeof price === "object" && price !== null && "type" in price && price.type === "image" && "price" in price && typeof price.price === "number" && "size" in price && typeof price.size === "string" && "unit" in price && price.unit === "per_image";
363
+ }
364
+ function isCharacterPrice(price) {
365
+ return typeof price === "object" && price !== null && "type" in price && price.type === "character" && "price" in price && typeof price.price === "number";
366
+ }
367
+ function isMinutePrice(price) {
368
+ return typeof price === "object" && price !== null && "type" in price && price.type === "minute" && "price" in price && typeof price.price === "number";
369
+ }
370
+ function validateProvider(raw) {
371
+ if (typeof raw !== "object" || raw === null) {
372
+ throw new Error("Provider data must be an object");
373
+ }
374
+ const provider = raw;
375
+ if (typeof provider.id !== "string") {
376
+ throw new Error("Provider id must be a string");
377
+ }
378
+ if (typeof provider.name !== "string") {
379
+ throw new Error("Provider name must be a string");
380
+ }
381
+ if (typeof provider.websiteUrl !== "string") {
382
+ throw new Error("Provider websiteUrl must be a string");
383
+ }
384
+ if (typeof provider.apiUrl !== "string") {
385
+ throw new Error("Provider apiUrl must be a string");
386
+ }
387
+ if (typeof provider.models !== "object" || provider.models === null) {
388
+ throw new Error("Provider models must be an object");
389
+ }
390
+ const models2 = provider.models;
391
+ Object.values(models2).forEach((price) => {
392
+ if (!isTokenPrice(price) && !isImagePrice(price) && !isCharacterPrice(price) && !isMinutePrice(price)) {
393
+ throw new Error(`Invalid price data: ${JSON.stringify(price)}`);
394
+ }
395
+ });
396
+ return {
397
+ id: provider.id,
398
+ name: provider.name,
399
+ websiteUrl: provider.websiteUrl,
400
+ apiUrl: provider.apiUrl,
401
+ models: provider.models
402
+ };
403
+ }
404
+ function buildAllProviders() {
405
+ return [
406
+ validateProvider(openai_default2),
407
+ validateProvider(anthropic_default2),
408
+ validateProvider(mistral_default2)
409
+ ];
410
+ }
411
+ function buildProvidersData() {
412
+ return {
413
+ providers: buildAllProviders()
414
+ };
415
+ }
416
+
417
+ // src/data/creators.json
418
+ var creators_default = {
419
+ creators: {
420
+ openai: {
421
+ name: "OpenAI",
422
+ website: "https://openai.com"
423
+ },
424
+ anthropic: {
425
+ name: "Anthropic",
426
+ website: "https://anthropic.com"
427
+ },
428
+ meta: {
429
+ name: "Meta",
430
+ website: "https://ai.meta.com"
431
+ },
432
+ mistral: {
433
+ name: "Mistral AI",
434
+ website: "https://mistral.ai"
435
+ }
436
+ }
437
+ };
55
438
 
56
439
  // src/index.ts
57
- var aimodels = models_default;
440
+ var allModels = buildAllModels();
441
+ var providersData = buildProvidersData();
58
442
  var models = {
59
- all: aimodels,
443
+ all: allModels,
444
+ get creators() {
445
+ return Object.keys(creators_default.creators);
446
+ },
60
447
  get providers() {
61
- return [...new Set(aimodels.map((model) => model.provider))];
448
+ return providersData.providers.map((p) => p.id);
62
449
  },
63
- from(provider) {
64
- return aimodels.filter((model) => model.provider === provider);
450
+ fromCreator(creator) {
451
+ return allModels.filter(
452
+ (model) => model.license.startsWith(creator) || // For open source models
453
+ providersData.providers.find((p) => p.id === creator)?.models[model.id]
454
+ // For proprietary models
455
+ );
456
+ },
457
+ fromProvider(provider) {
458
+ return allModels.filter((model) => model.providers.includes(provider));
65
459
  },
66
460
  find(id) {
67
- return aimodels.find((model) => model.id === id);
461
+ return allModels.find((model) => model.id === id);
68
462
  },
69
- withCapability(capability) {
70
- return aimodels.filter((model) => model.capabilities.includes(capability));
463
+ can(...capabilities) {
464
+ return allModels.filter(
465
+ (model) => capabilities.every((capability) => model.can.includes(capability))
466
+ );
71
467
  },
72
468
  withMinContext(tokens) {
73
- return aimodels.filter((model) => model.contextWindow >= tokens);
469
+ return allModels.filter((model) => model.context.total >= tokens);
74
470
  },
75
- withMaxPrice(price) {
76
- return aimodels.filter(
77
- (model) => model.pricing.input <= price && model.pricing.output <= price
78
- );
471
+ getPrice(modelId, provider) {
472
+ const providerData = providersData.providers.find((p) => p.id === provider);
473
+ const price = providerData?.models[modelId];
474
+ return price?.type === "token" ? price : void 0;
79
475
  }
80
476
  };
81
477
  export {
478
+ creators_default as creators,
82
479
  models
83
480
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimodels",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A collection of AI model specifications across different providers",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -13,34 +13,54 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "LICENSE"
17
18
  ],
18
19
  "scripts": {
20
+ "prebuild": "npm run typecheck && npm run lint && npm test",
19
21
  "build": "tsup src/index.ts --format cjs,esm --dts",
20
- "test": "jest",
22
+ "test": "deno test tests/",
23
+ "test:watch": "deno test --watch tests/",
21
24
  "typecheck": "tsc --noEmit",
22
25
  "lint": "eslint src --ext .ts",
23
- "prepublishOnly": "npm run build"
26
+ "clean": "rm -rf dist",
27
+ "prepare": "npm run build",
28
+ "preversion": "npm run typecheck && npm run lint && npm test",
29
+ "version": "git add -A",
30
+ "postversion": "git push && git push --tags",
31
+ "prepublishOnly": "npm run clean && npm run typecheck && npm test && npm run lint",
32
+ "postpublish": "npm run clean"
24
33
  },
25
34
  "keywords": [
26
35
  "ai",
27
36
  "models",
37
+ "ai models",
28
38
  "llm",
29
39
  "machine-learning",
30
40
  "specifications",
31
41
  "openai",
32
42
  "anthropic",
43
+ "mistral",
33
44
  "open-source"
34
45
  ],
35
46
  "author": "Dmitry Kury (d@dkury.com)",
36
47
  "license": "MIT",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/mitkury/aimodels.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/mitkury/aimodels/issues"
54
+ },
55
+ "homepage": "https://github.com/mitkury/aimodels#readme",
56
+ "engines": {
57
+ "deno": ">=1.40.0"
58
+ },
37
59
  "devDependencies": {
38
60
  "@types/node": "^20.0.0",
39
61
  "@typescript-eslint/eslint-plugin": "^6.0.0",
40
62
  "@typescript-eslint/parser": "^6.0.0",
41
63
  "eslint": "^8.0.0",
42
- "jest": "^29.0.0",
43
- "ts-jest": "^29.0.0",
44
64
  "tsup": "^8.0.0",
45
65
  "typescript": "^5.0.0"
46
66
  }