aimodels 0.3.2 → 0.3.5

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- interface ModelPrice {
1
+ interface TokenBasedPricePerMillionTokens {
2
2
  /** Price per million input tokens */
3
3
  input: number;
4
4
  /** Price per million output tokens */
@@ -6,6 +6,16 @@ interface ModelPrice {
6
6
  /** Price type */
7
7
  type: 'token';
8
8
  }
9
+ interface ImagePrice {
10
+ /** Price per image */
11
+ price: number;
12
+ /** Image size */
13
+ size: string;
14
+ /** Price type */
15
+ type: 'image';
16
+ /** Price unit */
17
+ unit: 'per_image';
18
+ }
9
19
 
10
20
  /**
11
21
  * Defines all possible model capabilities
@@ -27,14 +37,22 @@ declare class ModelCollection extends Array<Model> {
27
37
  id(modelId: string): Model | undefined;
28
38
  /** Get models available from a specific provider */
29
39
  fromProvider(provider: string): ModelCollection;
40
+ /** Get models available from a specific creator */
41
+ fromCreator(creator: string): ModelCollection;
30
42
  /** Filter models by minimum context window size */
31
43
  withMinContext(tokens: number): ModelCollection;
32
44
  }
33
45
  interface TokenModelContext {
34
- /** Maximum total tokens (input + output) */
46
+ /** Maximum input tokens the model can accept */
35
47
  total: number | null;
36
- /** Maximum output tokens */
48
+ /** Maximum tokens the model can generate in response */
37
49
  maxOutput: number | null;
50
+ /**
51
+ * When set to 1, indicates the model can generate up to maxOutput tokens
52
+ * regardless of input size (as long as input is within total limit).
53
+ * When not set, available output tokens may be reduced based on input size.
54
+ */
55
+ outputIsFixed?: 1;
38
56
  }
39
57
  interface ImageModelContext {
40
58
  /** Maximum outputs per request */
@@ -66,6 +84,23 @@ interface Model {
66
84
  context: ModelContext;
67
85
  }
68
86
 
87
+ interface Provider {
88
+ /** Provider identifier */
89
+ id: string;
90
+ /** Display name */
91
+ name: string;
92
+ /** Website URL */
93
+ websiteUrl: string;
94
+ /** API endpoint */
95
+ apiUrl: string;
96
+ /** Default model */
97
+ defaultModel?: string;
98
+ /** Whether this is a local provider */
99
+ isLocal?: number;
100
+ /** Model pricing */
101
+ models: Record<string, TokenBasedPricePerMillionTokens | ImagePrice>;
102
+ }
103
+
69
104
  var creators = {
70
105
  openai: {
71
106
  name: "OpenAI",
@@ -88,12 +123,16 @@ var creators$1 = {
88
123
  creators: creators
89
124
  };
90
125
 
91
- declare class ModelsCollection extends ModelCollection {
126
+ declare class AIModels extends ModelCollection {
127
+ constructor(models?: Model[]);
92
128
  get creators(): string[];
93
129
  get providers(): string[];
94
- fromCreator(creator: string): ModelCollection;
95
- getPrice(modelId: string, provider: string): ModelPrice | undefined;
130
+ getPrice(modelId: string, provider: string): TokenBasedPricePerMillionTokens | undefined;
131
+ /** Get provider information by ID */
132
+ getProvider(providerId: string): Provider | undefined;
133
+ /** Get all providers that can serve a specific model */
134
+ getProvidersForModel(modelId: string): Provider[];
96
135
  }
97
- declare const models: ModelsCollection;
136
+ declare const models: AIModels;
98
137
 
99
- export { type Capability, type Model, ModelCollection, type ModelContext, type ModelPrice, creators$1 as creators, models };
138
+ export { AIModels, type Capability, type Model, ModelCollection, type ModelContext, type Provider, type TokenBasedPricePerMillionTokens, creators$1 as creators, models };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- interface ModelPrice {
1
+ interface TokenBasedPricePerMillionTokens {
2
2
  /** Price per million input tokens */
3
3
  input: number;
4
4
  /** Price per million output tokens */
@@ -6,6 +6,16 @@ interface ModelPrice {
6
6
  /** Price type */
7
7
  type: 'token';
8
8
  }
9
+ interface ImagePrice {
10
+ /** Price per image */
11
+ price: number;
12
+ /** Image size */
13
+ size: string;
14
+ /** Price type */
15
+ type: 'image';
16
+ /** Price unit */
17
+ unit: 'per_image';
18
+ }
9
19
 
10
20
  /**
11
21
  * Defines all possible model capabilities
@@ -27,14 +37,22 @@ declare class ModelCollection extends Array<Model> {
27
37
  id(modelId: string): Model | undefined;
28
38
  /** Get models available from a specific provider */
29
39
  fromProvider(provider: string): ModelCollection;
40
+ /** Get models available from a specific creator */
41
+ fromCreator(creator: string): ModelCollection;
30
42
  /** Filter models by minimum context window size */
31
43
  withMinContext(tokens: number): ModelCollection;
32
44
  }
33
45
  interface TokenModelContext {
34
- /** Maximum total tokens (input + output) */
46
+ /** Maximum input tokens the model can accept */
35
47
  total: number | null;
36
- /** Maximum output tokens */
48
+ /** Maximum tokens the model can generate in response */
37
49
  maxOutput: number | null;
50
+ /**
51
+ * When set to 1, indicates the model can generate up to maxOutput tokens
52
+ * regardless of input size (as long as input is within total limit).
53
+ * When not set, available output tokens may be reduced based on input size.
54
+ */
55
+ outputIsFixed?: 1;
38
56
  }
39
57
  interface ImageModelContext {
40
58
  /** Maximum outputs per request */
@@ -66,6 +84,23 @@ interface Model {
66
84
  context: ModelContext;
67
85
  }
68
86
 
87
+ interface Provider {
88
+ /** Provider identifier */
89
+ id: string;
90
+ /** Display name */
91
+ name: string;
92
+ /** Website URL */
93
+ websiteUrl: string;
94
+ /** API endpoint */
95
+ apiUrl: string;
96
+ /** Default model */
97
+ defaultModel?: string;
98
+ /** Whether this is a local provider */
99
+ isLocal?: number;
100
+ /** Model pricing */
101
+ models: Record<string, TokenBasedPricePerMillionTokens | ImagePrice>;
102
+ }
103
+
69
104
  var creators = {
70
105
  openai: {
71
106
  name: "OpenAI",
@@ -88,12 +123,16 @@ var creators$1 = {
88
123
  creators: creators
89
124
  };
90
125
 
91
- declare class ModelsCollection extends ModelCollection {
126
+ declare class AIModels extends ModelCollection {
127
+ constructor(models?: Model[]);
92
128
  get creators(): string[];
93
129
  get providers(): string[];
94
- fromCreator(creator: string): ModelCollection;
95
- getPrice(modelId: string, provider: string): ModelPrice | undefined;
130
+ getPrice(modelId: string, provider: string): TokenBasedPricePerMillionTokens | undefined;
131
+ /** Get provider information by ID */
132
+ getProvider(providerId: string): Provider | undefined;
133
+ /** Get all providers that can serve a specific model */
134
+ getProvidersForModel(modelId: string): Provider[];
96
135
  }
97
- declare const models: ModelsCollection;
136
+ declare const models: AIModels;
98
137
 
99
- export { type Capability, type Model, ModelCollection, type ModelContext, type ModelPrice, creators$1 as creators, models };
138
+ export { AIModels, type Capability, type Model, ModelCollection, type ModelContext, type Provider, type TokenBasedPricePerMillionTokens, creators$1 as creators, models };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AIModels: () => AIModels,
23
24
  ModelCollection: () => ModelCollection,
24
25
  creators: () => creators_default,
25
26
  models: () => models
@@ -64,11 +65,20 @@ var ModelCollection = class _ModelCollection extends Array {
64
65
  fromProvider(provider) {
65
66
  return this.filter((model) => model.providers.includes(provider));
66
67
  }
68
+ /** Get models available from a specific creator */
69
+ fromCreator(creator) {
70
+ return new _ModelCollection(
71
+ this.filter((model) => model.creator === creator)
72
+ );
73
+ }
67
74
  /** Filter models by minimum context window size */
68
75
  withMinContext(tokens) {
69
76
  return this.filter((model) => {
70
77
  const context = model.context;
71
- return "total" in context && context.total !== null && context.total >= tokens;
78
+ if (!("total" in context) || context.total === null) {
79
+ return false;
80
+ }
81
+ return context.total >= tokens;
72
82
  });
73
83
  }
74
84
  };
@@ -313,7 +323,7 @@ var anthropic_models_default = {
313
323
  creator: "anthropic",
314
324
  models: [
315
325
  {
316
- id: "claude-3-opus",
326
+ id: "claude-3-opus-20240229",
317
327
  name: "Claude 3 Opus",
318
328
  license: "proprietary",
319
329
  providers: [
@@ -331,11 +341,13 @@ var anthropic_models_default = {
331
341
  ],
332
342
  context: {
333
343
  total: 2e5,
334
- maxOutput: 4096
335
- }
344
+ maxOutput: 4096,
345
+ outputIsFixed: 1
346
+ },
347
+ aliases: ["claude-3-opus-latest"]
336
348
  },
337
349
  {
338
- id: "claude-3-sonnet",
350
+ id: "claude-3-5-sonnet-20241022",
339
351
  name: "Claude 3 Sonnet",
340
352
  license: "proprietary",
341
353
  providers: [
@@ -353,11 +365,13 @@ var anthropic_models_default = {
353
365
  ],
354
366
  context: {
355
367
  total: 2e5,
356
- maxOutput: 4096
357
- }
368
+ maxOutput: 8192,
369
+ outputIsFixed: 1
370
+ },
371
+ aliases: ["claude-3-sonnet-latest"]
358
372
  },
359
373
  {
360
- id: "claude-3-haiku",
374
+ id: "claude-3-5-haiku-20241022",
361
375
  name: "Claude 3 Haiku",
362
376
  license: "proprietary",
363
377
  providers: [
@@ -375,7 +389,8 @@ var anthropic_models_default = {
375
389
  ],
376
390
  context: {
377
391
  total: 2e5,
378
- maxOutput: 4096
392
+ maxOutput: 8192,
393
+ outputIsFixed: 1
379
394
  }
380
395
  }
381
396
  ]
@@ -645,7 +660,7 @@ var deepseek_models_default = {
645
660
  ],
646
661
  context: {
647
662
  total: 131072,
648
- maxOutput: 131072
663
+ maxOutput: 8192
649
664
  }
650
665
  },
651
666
  {
@@ -663,7 +678,7 @@ var deepseek_models_default = {
663
678
  ],
664
679
  context: {
665
680
  total: 131072,
666
- maxOutput: 131072
681
+ maxOutput: 8192
667
682
  }
668
683
  }
669
684
  ]
@@ -1195,31 +1210,39 @@ var creators_default = {
1195
1210
  // src/index.ts
1196
1211
  var allModels = buildAllModels();
1197
1212
  var providersData = buildProvidersData();
1198
- var ModelsCollection = class extends ModelCollection {
1213
+ var AIModels = class _AIModels extends ModelCollection {
1214
+ constructor(models2 = []) {
1215
+ super(models2);
1216
+ Object.setPrototypeOf(this, _AIModels.prototype);
1217
+ }
1199
1218
  get creators() {
1200
1219
  return Object.keys(creators_default.creators);
1201
1220
  }
1202
1221
  get providers() {
1203
1222
  return providersData.providers.map((p) => p.id);
1204
1223
  }
1205
- fromCreator(creator) {
1206
- return new ModelCollection(
1207
- this.filter(
1208
- (model) => model.license.startsWith(creator) || // For open source models
1209
- !!providersData.providers.find((p) => p.id === creator)?.models[model.id]
1210
- // For proprietary models
1211
- )
1212
- );
1213
- }
1214
1224
  getPrice(modelId, provider) {
1215
1225
  const providerData = providersData.providers.find((p) => p.id === provider);
1216
1226
  const price = providerData?.models[modelId];
1217
1227
  return price?.type === "token" ? price : void 0;
1218
1228
  }
1229
+ /** Get provider information by ID */
1230
+ getProvider(providerId) {
1231
+ return providersData.providers.find((p) => p.id === providerId);
1232
+ }
1233
+ /** Get all providers that can serve a specific model */
1234
+ getProvidersForModel(modelId) {
1235
+ const model = this.id(modelId);
1236
+ if (!model) return [];
1237
+ return providersData.providers.filter(
1238
+ (p) => model.providers.includes(p.id)
1239
+ );
1240
+ }
1219
1241
  };
1220
- var models = new ModelsCollection(allModels);
1242
+ var models = new AIModels(allModels);
1221
1243
  // Annotate the CommonJS export names for ESM import in node:
1222
1244
  0 && (module.exports = {
1245
+ AIModels,
1223
1246
  ModelCollection,
1224
1247
  creators,
1225
1248
  models
package/dist/index.mjs CHANGED
@@ -36,11 +36,20 @@ var ModelCollection = class _ModelCollection extends Array {
36
36
  fromProvider(provider) {
37
37
  return this.filter((model) => model.providers.includes(provider));
38
38
  }
39
+ /** Get models available from a specific creator */
40
+ fromCreator(creator) {
41
+ return new _ModelCollection(
42
+ this.filter((model) => model.creator === creator)
43
+ );
44
+ }
39
45
  /** Filter models by minimum context window size */
40
46
  withMinContext(tokens) {
41
47
  return this.filter((model) => {
42
48
  const context = model.context;
43
- return "total" in context && context.total !== null && context.total >= tokens;
49
+ if (!("total" in context) || context.total === null) {
50
+ return false;
51
+ }
52
+ return context.total >= tokens;
44
53
  });
45
54
  }
46
55
  };
@@ -285,7 +294,7 @@ var anthropic_models_default = {
285
294
  creator: "anthropic",
286
295
  models: [
287
296
  {
288
- id: "claude-3-opus",
297
+ id: "claude-3-opus-20240229",
289
298
  name: "Claude 3 Opus",
290
299
  license: "proprietary",
291
300
  providers: [
@@ -303,11 +312,13 @@ var anthropic_models_default = {
303
312
  ],
304
313
  context: {
305
314
  total: 2e5,
306
- maxOutput: 4096
307
- }
315
+ maxOutput: 4096,
316
+ outputIsFixed: 1
317
+ },
318
+ aliases: ["claude-3-opus-latest"]
308
319
  },
309
320
  {
310
- id: "claude-3-sonnet",
321
+ id: "claude-3-5-sonnet-20241022",
311
322
  name: "Claude 3 Sonnet",
312
323
  license: "proprietary",
313
324
  providers: [
@@ -325,11 +336,13 @@ var anthropic_models_default = {
325
336
  ],
326
337
  context: {
327
338
  total: 2e5,
328
- maxOutput: 4096
329
- }
339
+ maxOutput: 8192,
340
+ outputIsFixed: 1
341
+ },
342
+ aliases: ["claude-3-sonnet-latest"]
330
343
  },
331
344
  {
332
- id: "claude-3-haiku",
345
+ id: "claude-3-5-haiku-20241022",
333
346
  name: "Claude 3 Haiku",
334
347
  license: "proprietary",
335
348
  providers: [
@@ -347,7 +360,8 @@ var anthropic_models_default = {
347
360
  ],
348
361
  context: {
349
362
  total: 2e5,
350
- maxOutput: 4096
363
+ maxOutput: 8192,
364
+ outputIsFixed: 1
351
365
  }
352
366
  }
353
367
  ]
@@ -617,7 +631,7 @@ var deepseek_models_default = {
617
631
  ],
618
632
  context: {
619
633
  total: 131072,
620
- maxOutput: 131072
634
+ maxOutput: 8192
621
635
  }
622
636
  },
623
637
  {
@@ -635,7 +649,7 @@ var deepseek_models_default = {
635
649
  ],
636
650
  context: {
637
651
  total: 131072,
638
- maxOutput: 131072
652
+ maxOutput: 8192
639
653
  }
640
654
  }
641
655
  ]
@@ -1167,30 +1181,38 @@ var creators_default = {
1167
1181
  // src/index.ts
1168
1182
  var allModels = buildAllModels();
1169
1183
  var providersData = buildProvidersData();
1170
- var ModelsCollection = class extends ModelCollection {
1184
+ var AIModels = class _AIModels extends ModelCollection {
1185
+ constructor(models2 = []) {
1186
+ super(models2);
1187
+ Object.setPrototypeOf(this, _AIModels.prototype);
1188
+ }
1171
1189
  get creators() {
1172
1190
  return Object.keys(creators_default.creators);
1173
1191
  }
1174
1192
  get providers() {
1175
1193
  return providersData.providers.map((p) => p.id);
1176
1194
  }
1177
- fromCreator(creator) {
1178
- return new ModelCollection(
1179
- this.filter(
1180
- (model) => model.license.startsWith(creator) || // For open source models
1181
- !!providersData.providers.find((p) => p.id === creator)?.models[model.id]
1182
- // For proprietary models
1183
- )
1184
- );
1185
- }
1186
1195
  getPrice(modelId, provider) {
1187
1196
  const providerData = providersData.providers.find((p) => p.id === provider);
1188
1197
  const price = providerData?.models[modelId];
1189
1198
  return price?.type === "token" ? price : void 0;
1190
1199
  }
1200
+ /** Get provider information by ID */
1201
+ getProvider(providerId) {
1202
+ return providersData.providers.find((p) => p.id === providerId);
1203
+ }
1204
+ /** Get all providers that can serve a specific model */
1205
+ getProvidersForModel(modelId) {
1206
+ const model = this.id(modelId);
1207
+ if (!model) return [];
1208
+ return providersData.providers.filter(
1209
+ (p) => model.providers.includes(p.id)
1210
+ );
1211
+ }
1191
1212
  };
1192
- var models = new ModelsCollection(allModels);
1213
+ var models = new AIModels(allModels);
1193
1214
  export {
1215
+ AIModels,
1194
1216
  ModelCollection,
1195
1217
  creators_default as creators,
1196
1218
  models
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimodels",
3
- "version": "0.3.2",
3
+ "version": "0.3.5",
4
4
  "description": "A collection of AI model specifications across different providers",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",