aimodels 0.3.3 → 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,6 +37,8 @@ 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
  }
@@ -72,6 +84,23 @@ interface Model {
72
84
  context: ModelContext;
73
85
  }
74
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
+
75
104
  var creators = {
76
105
  openai: {
77
106
  name: "OpenAI",
@@ -94,12 +123,16 @@ var creators$1 = {
94
123
  creators: creators
95
124
  };
96
125
 
97
- declare class ModelsCollection extends ModelCollection {
126
+ declare class AIModels extends ModelCollection {
127
+ constructor(models?: Model[]);
98
128
  get creators(): string[];
99
129
  get providers(): string[];
100
- fromCreator(creator: string): ModelCollection;
101
- 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[];
102
135
  }
103
- declare const models: ModelsCollection;
136
+ declare const models: AIModels;
104
137
 
105
- 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,6 +37,8 @@ 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
  }
@@ -72,6 +84,23 @@ interface Model {
72
84
  context: ModelContext;
73
85
  }
74
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
+
75
104
  var creators = {
76
105
  openai: {
77
106
  name: "OpenAI",
@@ -94,12 +123,16 @@ var creators$1 = {
94
123
  creators: creators
95
124
  };
96
125
 
97
- declare class ModelsCollection extends ModelCollection {
126
+ declare class AIModels extends ModelCollection {
127
+ constructor(models?: Model[]);
98
128
  get creators(): string[];
99
129
  get providers(): string[];
100
- fromCreator(creator: string): ModelCollection;
101
- 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[];
102
135
  }
103
- declare const models: ModelsCollection;
136
+ declare const models: AIModels;
104
137
 
105
- 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,6 +65,12 @@ 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) => {
@@ -336,7 +343,8 @@ var anthropic_models_default = {
336
343
  total: 2e5,
337
344
  maxOutput: 4096,
338
345
  outputIsFixed: 1
339
- }
346
+ },
347
+ aliases: ["claude-3-opus-latest"]
340
348
  },
341
349
  {
342
350
  id: "claude-3-5-sonnet-20241022",
@@ -359,7 +367,8 @@ var anthropic_models_default = {
359
367
  total: 2e5,
360
368
  maxOutput: 8192,
361
369
  outputIsFixed: 1
362
- }
370
+ },
371
+ aliases: ["claude-3-sonnet-latest"]
363
372
  },
364
373
  {
365
374
  id: "claude-3-5-haiku-20241022",
@@ -1201,31 +1210,39 @@ var creators_default = {
1201
1210
  // src/index.ts
1202
1211
  var allModels = buildAllModels();
1203
1212
  var providersData = buildProvidersData();
1204
- 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
+ }
1205
1218
  get creators() {
1206
1219
  return Object.keys(creators_default.creators);
1207
1220
  }
1208
1221
  get providers() {
1209
1222
  return providersData.providers.map((p) => p.id);
1210
1223
  }
1211
- fromCreator(creator) {
1212
- return new ModelCollection(
1213
- this.filter(
1214
- (model) => model.license.startsWith(creator) || // For open source models
1215
- !!providersData.providers.find((p) => p.id === creator)?.models[model.id]
1216
- // For proprietary models
1217
- )
1218
- );
1219
- }
1220
1224
  getPrice(modelId, provider) {
1221
1225
  const providerData = providersData.providers.find((p) => p.id === provider);
1222
1226
  const price = providerData?.models[modelId];
1223
1227
  return price?.type === "token" ? price : void 0;
1224
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
+ }
1225
1241
  };
1226
- var models = new ModelsCollection(allModels);
1242
+ var models = new AIModels(allModels);
1227
1243
  // Annotate the CommonJS export names for ESM import in node:
1228
1244
  0 && (module.exports = {
1245
+ AIModels,
1229
1246
  ModelCollection,
1230
1247
  creators,
1231
1248
  models
package/dist/index.mjs CHANGED
@@ -36,6 +36,12 @@ 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) => {
@@ -308,7 +314,8 @@ var anthropic_models_default = {
308
314
  total: 2e5,
309
315
  maxOutput: 4096,
310
316
  outputIsFixed: 1
311
- }
317
+ },
318
+ aliases: ["claude-3-opus-latest"]
312
319
  },
313
320
  {
314
321
  id: "claude-3-5-sonnet-20241022",
@@ -331,7 +338,8 @@ var anthropic_models_default = {
331
338
  total: 2e5,
332
339
  maxOutput: 8192,
333
340
  outputIsFixed: 1
334
- }
341
+ },
342
+ aliases: ["claude-3-sonnet-latest"]
335
343
  },
336
344
  {
337
345
  id: "claude-3-5-haiku-20241022",
@@ -1173,30 +1181,38 @@ var creators_default = {
1173
1181
  // src/index.ts
1174
1182
  var allModels = buildAllModels();
1175
1183
  var providersData = buildProvidersData();
1176
- 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
+ }
1177
1189
  get creators() {
1178
1190
  return Object.keys(creators_default.creators);
1179
1191
  }
1180
1192
  get providers() {
1181
1193
  return providersData.providers.map((p) => p.id);
1182
1194
  }
1183
- fromCreator(creator) {
1184
- return new ModelCollection(
1185
- this.filter(
1186
- (model) => model.license.startsWith(creator) || // For open source models
1187
- !!providersData.providers.find((p) => p.id === creator)?.models[model.id]
1188
- // For proprietary models
1189
- )
1190
- );
1191
- }
1192
1195
  getPrice(modelId, provider) {
1193
1196
  const providerData = providersData.providers.find((p) => p.id === provider);
1194
1197
  const price = providerData?.models[modelId];
1195
1198
  return price?.type === "token" ? price : void 0;
1196
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
+ }
1197
1212
  };
1198
- var models = new ModelsCollection(allModels);
1213
+ var models = new AIModels(allModels);
1199
1214
  export {
1215
+ AIModels,
1200
1216
  ModelCollection,
1201
1217
  creators_default as creators,
1202
1218
  models
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimodels",
3
- "version": "0.3.3",
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",