aimodels 0.2.2 → 0.2.3

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
@@ -13,11 +13,22 @@ interface ModelPrice {
13
13
  type Capability = "chat" | "reason" | "text-in" | "text-out" | "img-in" | "img-out" | "sound-in" | "sound-out" | "json-out" | "function-out" | "vectors-out";
14
14
 
15
15
  declare class ModelCollection extends Array<Model> {
16
- constructor(models: Model[]);
16
+ /** Create a new ModelCollection from an array of models */
17
+ constructor(models?: Model[]);
18
+ /** Filter models by one or more capabilities (all must be present) */
17
19
  can(...capabilities: Capability[]): ModelCollection;
20
+ /** Filter models by one or more languages (all must be supported) */
18
21
  know(...languages: string[]): ModelCollection;
22
+ /** Override array filter to return ModelCollection */
19
23
  filter(predicate: (value: Model, index: number, array: Model[]) => boolean): ModelCollection;
24
+ /** Override array slice to return ModelCollection */
20
25
  slice(start?: number, end?: number): ModelCollection;
26
+ /** Find a model by its ID */
27
+ id(modelId: string): Model | undefined;
28
+ /** Get models available from a specific provider */
29
+ fromProvider(provider: string): ModelCollection;
30
+ /** Filter models by minimum context window size */
31
+ withMinContext(tokens: number): ModelCollection;
21
32
  }
22
33
  interface ModelContext {
23
34
  /** Maximum total tokens (input + output) */
@@ -41,26 +52,6 @@ interface Model {
41
52
  /** Context window information */
42
53
  context: ModelContext;
43
54
  }
44
- interface ModelsAPI {
45
- /** All available models */
46
- all: ModelCollection;
47
- /** List of all creators */
48
- creators: string[];
49
- /** List of all providers */
50
- providers: string[];
51
- /** Get models from a specific creator */
52
- fromCreator(creator: string): ModelCollection;
53
- /** Get models from a specific provider */
54
- fromProvider(provider: string): ModelCollection;
55
- /** Find a specific model by ID */
56
- find(id: string): Model | undefined;
57
- /** Filter models by one or more capabilities (all must be present) */
58
- can(...capabilities: string[]): ModelCollection;
59
- /** Filter models by minimum context window */
60
- withMinContext(tokens: number): ModelCollection;
61
- /** Get pricing for a model from a specific provider */
62
- getPrice(modelId: string, provider: string): ModelPrice | undefined;
63
- }
64
55
 
65
56
  var creators = {
66
57
  openai: {
@@ -84,6 +75,12 @@ var creators$1 = {
84
75
  creators: creators
85
76
  };
86
77
 
87
- declare const models: ModelsAPI;
78
+ declare class ModelsCollection extends ModelCollection {
79
+ get creators(): string[];
80
+ get providers(): string[];
81
+ fromCreator(creator: string): ModelCollection;
82
+ getPrice(modelId: string, provider: string): ModelPrice | undefined;
83
+ }
84
+ declare const models: ModelsCollection;
88
85
 
89
- export { creators$1 as creators, models };
86
+ export { type Capability, type Model, ModelCollection, type ModelContext, type ModelPrice, creators$1 as creators, models };
package/dist/index.d.ts CHANGED
@@ -13,11 +13,22 @@ interface ModelPrice {
13
13
  type Capability = "chat" | "reason" | "text-in" | "text-out" | "img-in" | "img-out" | "sound-in" | "sound-out" | "json-out" | "function-out" | "vectors-out";
14
14
 
15
15
  declare class ModelCollection extends Array<Model> {
16
- constructor(models: Model[]);
16
+ /** Create a new ModelCollection from an array of models */
17
+ constructor(models?: Model[]);
18
+ /** Filter models by one or more capabilities (all must be present) */
17
19
  can(...capabilities: Capability[]): ModelCollection;
20
+ /** Filter models by one or more languages (all must be supported) */
18
21
  know(...languages: string[]): ModelCollection;
22
+ /** Override array filter to return ModelCollection */
19
23
  filter(predicate: (value: Model, index: number, array: Model[]) => boolean): ModelCollection;
24
+ /** Override array slice to return ModelCollection */
20
25
  slice(start?: number, end?: number): ModelCollection;
26
+ /** Find a model by its ID */
27
+ id(modelId: string): Model | undefined;
28
+ /** Get models available from a specific provider */
29
+ fromProvider(provider: string): ModelCollection;
30
+ /** Filter models by minimum context window size */
31
+ withMinContext(tokens: number): ModelCollection;
21
32
  }
22
33
  interface ModelContext {
23
34
  /** Maximum total tokens (input + output) */
@@ -41,26 +52,6 @@ interface Model {
41
52
  /** Context window information */
42
53
  context: ModelContext;
43
54
  }
44
- interface ModelsAPI {
45
- /** All available models */
46
- all: ModelCollection;
47
- /** List of all creators */
48
- creators: string[];
49
- /** List of all providers */
50
- providers: string[];
51
- /** Get models from a specific creator */
52
- fromCreator(creator: string): ModelCollection;
53
- /** Get models from a specific provider */
54
- fromProvider(provider: string): ModelCollection;
55
- /** Find a specific model by ID */
56
- find(id: string): Model | undefined;
57
- /** Filter models by one or more capabilities (all must be present) */
58
- can(...capabilities: string[]): ModelCollection;
59
- /** Filter models by minimum context window */
60
- withMinContext(tokens: number): ModelCollection;
61
- /** Get pricing for a model from a specific provider */
62
- getPrice(modelId: string, provider: string): ModelPrice | undefined;
63
- }
64
55
 
65
56
  var creators = {
66
57
  openai: {
@@ -84,6 +75,12 @@ var creators$1 = {
84
75
  creators: creators
85
76
  };
86
77
 
87
- declare const models: ModelsAPI;
78
+ declare class ModelsCollection extends ModelCollection {
79
+ get creators(): string[];
80
+ get providers(): string[];
81
+ fromCreator(creator: string): ModelCollection;
82
+ getPrice(modelId: string, provider: string): ModelPrice | undefined;
83
+ }
84
+ declare const models: ModelsCollection;
88
85
 
89
- export { creators$1 as creators, models };
86
+ export { type Capability, type Model, ModelCollection, type ModelContext, type ModelPrice, 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
+ ModelCollection: () => ModelCollection,
23
24
  creators: () => creators_default,
24
25
  models: () => models
25
26
  });
@@ -27,26 +28,43 @@ module.exports = __toCommonJS(index_exports);
27
28
 
28
29
  // src/types/models.ts
29
30
  var ModelCollection = class _ModelCollection extends Array {
30
- constructor(models2) {
31
- super(...models2);
31
+ /** Create a new ModelCollection from an array of models */
32
+ constructor(models2 = []) {
33
+ super();
34
+ if (models2.length > 0) {
35
+ this.push(...models2);
36
+ }
32
37
  Object.setPrototypeOf(this, _ModelCollection.prototype);
33
38
  }
39
+ /** Filter models by one or more capabilities (all must be present) */
34
40
  can(...capabilities) {
35
- return new _ModelCollection(
36
- this.filter((model) => capabilities.every((cap) => model.can.includes(cap)))
37
- );
41
+ return this.filter((model) => capabilities.every((cap) => model.can.includes(cap)));
38
42
  }
43
+ /** Filter models by one or more languages (all must be supported) */
39
44
  know(...languages) {
40
- return new _ModelCollection(
41
- this.filter((model) => languages.every((lang) => model.languages?.includes(lang)))
42
- );
45
+ return this.filter((model) => languages.every((lang) => model.languages?.includes(lang)));
43
46
  }
44
- // Override array methods to return ModelCollection
47
+ /** Override array filter to return ModelCollection */
45
48
  filter(predicate) {
46
- return new _ModelCollection(super.filter(predicate));
49
+ const filtered = Array.from(this).filter(predicate);
50
+ return new _ModelCollection(filtered);
47
51
  }
52
+ /** Override array slice to return ModelCollection */
48
53
  slice(start, end) {
49
- return new _ModelCollection(super.slice(start, end));
54
+ const sliced = Array.from(this).slice(start, end);
55
+ return new _ModelCollection(sliced);
56
+ }
57
+ /** Find a model by its ID */
58
+ id(modelId) {
59
+ return this.find((model) => model.id === modelId);
60
+ }
61
+ /** Get models available from a specific provider */
62
+ fromProvider(provider) {
63
+ return this.filter((model) => model.providers.includes(provider));
64
+ }
65
+ /** Filter models by minimum context window size */
66
+ withMinContext(tokens) {
67
+ return this.filter((model) => model.context.total >= tokens);
50
68
  }
51
69
  };
52
70
 
@@ -762,51 +780,32 @@ var creators_default = {
762
780
  // src/index.ts
763
781
  var allModels = buildAllModels();
764
782
  var providersData = buildProvidersData();
765
- var models = {
766
- all: new ModelCollection(allModels),
783
+ var ModelsCollection = class extends ModelCollection {
767
784
  get creators() {
768
785
  return Object.keys(creators_default.creators);
769
- },
786
+ }
770
787
  get providers() {
771
788
  return providersData.providers.map((p) => p.id);
772
- },
789
+ }
773
790
  fromCreator(creator) {
774
791
  return new ModelCollection(
775
- allModels.filter(
792
+ this.filter(
776
793
  (model) => model.license.startsWith(creator) || // For open source models
777
- providersData.providers.find((p) => p.id === creator)?.models[model.id]
794
+ !!providersData.providers.find((p) => p.id === creator)?.models[model.id]
778
795
  // For proprietary models
779
796
  )
780
797
  );
781
- },
782
- fromProvider(provider) {
783
- return new ModelCollection(
784
- allModels.filter((model) => model.providers.includes(provider))
785
- );
786
- },
787
- find(id) {
788
- return allModels.find((model) => model.id === id);
789
- },
790
- can(...capabilities) {
791
- return new ModelCollection(
792
- allModels.filter(
793
- (model) => capabilities.every((capability) => model.can.includes(capability))
794
- )
795
- );
796
- },
797
- withMinContext(tokens) {
798
- return new ModelCollection(
799
- allModels.filter((model) => model.context.total >= tokens)
800
- );
801
- },
798
+ }
802
799
  getPrice(modelId, provider) {
803
800
  const providerData = providersData.providers.find((p) => p.id === provider);
804
801
  const price = providerData?.models[modelId];
805
802
  return price?.type === "token" ? price : void 0;
806
803
  }
807
804
  };
805
+ var models = new ModelsCollection(allModels);
808
806
  // Annotate the CommonJS export names for ESM import in node:
809
807
  0 && (module.exports = {
808
+ ModelCollection,
810
809
  creators,
811
810
  models
812
811
  });
package/dist/index.mjs CHANGED
@@ -1,25 +1,42 @@
1
1
  // src/types/models.ts
2
2
  var ModelCollection = class _ModelCollection extends Array {
3
- constructor(models2) {
4
- super(...models2);
3
+ /** Create a new ModelCollection from an array of models */
4
+ constructor(models2 = []) {
5
+ super();
6
+ if (models2.length > 0) {
7
+ this.push(...models2);
8
+ }
5
9
  Object.setPrototypeOf(this, _ModelCollection.prototype);
6
10
  }
11
+ /** Filter models by one or more capabilities (all must be present) */
7
12
  can(...capabilities) {
8
- return new _ModelCollection(
9
- this.filter((model) => capabilities.every((cap) => model.can.includes(cap)))
10
- );
13
+ return this.filter((model) => capabilities.every((cap) => model.can.includes(cap)));
11
14
  }
15
+ /** Filter models by one or more languages (all must be supported) */
12
16
  know(...languages) {
13
- return new _ModelCollection(
14
- this.filter((model) => languages.every((lang) => model.languages?.includes(lang)))
15
- );
17
+ return this.filter((model) => languages.every((lang) => model.languages?.includes(lang)));
16
18
  }
17
- // Override array methods to return ModelCollection
19
+ /** Override array filter to return ModelCollection */
18
20
  filter(predicate) {
19
- return new _ModelCollection(super.filter(predicate));
21
+ const filtered = Array.from(this).filter(predicate);
22
+ return new _ModelCollection(filtered);
20
23
  }
24
+ /** Override array slice to return ModelCollection */
21
25
  slice(start, end) {
22
- return new _ModelCollection(super.slice(start, end));
26
+ const sliced = Array.from(this).slice(start, end);
27
+ return new _ModelCollection(sliced);
28
+ }
29
+ /** Find a model by its ID */
30
+ id(modelId) {
31
+ return this.find((model) => model.id === modelId);
32
+ }
33
+ /** Get models available from a specific provider */
34
+ fromProvider(provider) {
35
+ return this.filter((model) => model.providers.includes(provider));
36
+ }
37
+ /** Filter models by minimum context window size */
38
+ withMinContext(tokens) {
39
+ return this.filter((model) => model.context.total >= tokens);
23
40
  }
24
41
  };
25
42
 
@@ -735,50 +752,31 @@ var creators_default = {
735
752
  // src/index.ts
736
753
  var allModels = buildAllModels();
737
754
  var providersData = buildProvidersData();
738
- var models = {
739
- all: new ModelCollection(allModels),
755
+ var ModelsCollection = class extends ModelCollection {
740
756
  get creators() {
741
757
  return Object.keys(creators_default.creators);
742
- },
758
+ }
743
759
  get providers() {
744
760
  return providersData.providers.map((p) => p.id);
745
- },
761
+ }
746
762
  fromCreator(creator) {
747
763
  return new ModelCollection(
748
- allModels.filter(
764
+ this.filter(
749
765
  (model) => model.license.startsWith(creator) || // For open source models
750
- providersData.providers.find((p) => p.id === creator)?.models[model.id]
766
+ !!providersData.providers.find((p) => p.id === creator)?.models[model.id]
751
767
  // For proprietary models
752
768
  )
753
769
  );
754
- },
755
- fromProvider(provider) {
756
- return new ModelCollection(
757
- allModels.filter((model) => model.providers.includes(provider))
758
- );
759
- },
760
- find(id) {
761
- return allModels.find((model) => model.id === id);
762
- },
763
- can(...capabilities) {
764
- return new ModelCollection(
765
- allModels.filter(
766
- (model) => capabilities.every((capability) => model.can.includes(capability))
767
- )
768
- );
769
- },
770
- withMinContext(tokens) {
771
- return new ModelCollection(
772
- allModels.filter((model) => model.context.total >= tokens)
773
- );
774
- },
770
+ }
775
771
  getPrice(modelId, provider) {
776
772
  const providerData = providersData.providers.find((p) => p.id === provider);
777
773
  const price = providerData?.models[modelId];
778
774
  return price?.type === "token" ? price : void 0;
779
775
  }
780
776
  };
777
+ var models = new ModelsCollection(allModels);
781
778
  export {
779
+ ModelCollection,
782
780
  creators_default as creators,
783
781
  models
784
782
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimodels",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "A collection of AI model specifications across different providers",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",