aimodels 0.3.0 → 0.3.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.
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +14 -3
- package/dist/index.mjs +14 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -23,7 +23,7 @@ declare class ModelCollection extends Array<Model> {
|
|
|
23
23
|
filter(predicate: (value: Model, index: number, array: Model[]) => boolean): ModelCollection;
|
|
24
24
|
/** Override array slice to return ModelCollection */
|
|
25
25
|
slice(start?: number, end?: number): ModelCollection;
|
|
26
|
-
/** Find a model by its ID */
|
|
26
|
+
/** Find a model by its ID or alias */
|
|
27
27
|
id(modelId: string): Model | undefined;
|
|
28
28
|
/** Get models available from a specific provider */
|
|
29
29
|
fromProvider(provider: string): ModelCollection;
|
|
@@ -60,6 +60,8 @@ interface Model {
|
|
|
60
60
|
can: Capability[];
|
|
61
61
|
/** Languages the model knows */
|
|
62
62
|
languages?: string[];
|
|
63
|
+
/** Alternative identifiers for this model */
|
|
64
|
+
aliases?: string[];
|
|
63
65
|
/** Context window information */
|
|
64
66
|
context: ModelContext;
|
|
65
67
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare class ModelCollection extends Array<Model> {
|
|
|
23
23
|
filter(predicate: (value: Model, index: number, array: Model[]) => boolean): ModelCollection;
|
|
24
24
|
/** Override array slice to return ModelCollection */
|
|
25
25
|
slice(start?: number, end?: number): ModelCollection;
|
|
26
|
-
/** Find a model by its ID */
|
|
26
|
+
/** Find a model by its ID or alias */
|
|
27
27
|
id(modelId: string): Model | undefined;
|
|
28
28
|
/** Get models available from a specific provider */
|
|
29
29
|
fromProvider(provider: string): ModelCollection;
|
|
@@ -60,6 +60,8 @@ interface Model {
|
|
|
60
60
|
can: Capability[];
|
|
61
61
|
/** Languages the model knows */
|
|
62
62
|
languages?: string[];
|
|
63
|
+
/** Alternative identifiers for this model */
|
|
64
|
+
aliases?: string[];
|
|
63
65
|
/** Context window information */
|
|
64
66
|
context: ModelContext;
|
|
65
67
|
}
|
package/dist/index.js
CHANGED
|
@@ -54,9 +54,11 @@ var ModelCollection = class _ModelCollection extends Array {
|
|
|
54
54
|
const sliced = Array.from(this).slice(start, end);
|
|
55
55
|
return new _ModelCollection(sliced);
|
|
56
56
|
}
|
|
57
|
-
/** Find a model by its ID */
|
|
57
|
+
/** Find a model by its ID or alias */
|
|
58
58
|
id(modelId) {
|
|
59
|
-
return this.find(
|
|
59
|
+
return this.find(
|
|
60
|
+
(model) => model.id === modelId || model.aliases?.includes(modelId)
|
|
61
|
+
);
|
|
60
62
|
}
|
|
61
63
|
/** Get models available from a specific provider */
|
|
62
64
|
fromProvider(provider) {
|
|
@@ -761,6 +763,14 @@ function validateModel(raw) {
|
|
|
761
763
|
if (!model.can.every((c) => validCapabilities.includes(c))) {
|
|
762
764
|
throw new Error(`Model has invalid capabilities: ${model.can.join(", ")}`);
|
|
763
765
|
}
|
|
766
|
+
if (model.aliases !== void 0) {
|
|
767
|
+
if (!Array.isArray(model.aliases)) {
|
|
768
|
+
throw new Error("Model aliases must be an array");
|
|
769
|
+
}
|
|
770
|
+
if (!model.aliases.every((a) => typeof a === "string")) {
|
|
771
|
+
throw new Error("Model aliases must be strings");
|
|
772
|
+
}
|
|
773
|
+
}
|
|
764
774
|
if (typeof model.context !== "object" || model.context === null) {
|
|
765
775
|
throw new Error("Model context must be an object");
|
|
766
776
|
}
|
|
@@ -785,7 +795,8 @@ function validateModel(raw) {
|
|
|
785
795
|
providers: model.providers,
|
|
786
796
|
can: model.can,
|
|
787
797
|
context: model.context,
|
|
788
|
-
...model.languages ? { languages: model.languages } : {}
|
|
798
|
+
...model.languages ? { languages: model.languages } : {},
|
|
799
|
+
...model.aliases ? { aliases: model.aliases } : {}
|
|
789
800
|
};
|
|
790
801
|
}
|
|
791
802
|
function buildAllModels() {
|
package/dist/index.mjs
CHANGED
|
@@ -26,9 +26,11 @@ var ModelCollection = class _ModelCollection extends Array {
|
|
|
26
26
|
const sliced = Array.from(this).slice(start, end);
|
|
27
27
|
return new _ModelCollection(sliced);
|
|
28
28
|
}
|
|
29
|
-
/** Find a model by its ID */
|
|
29
|
+
/** Find a model by its ID or alias */
|
|
30
30
|
id(modelId) {
|
|
31
|
-
return this.find(
|
|
31
|
+
return this.find(
|
|
32
|
+
(model) => model.id === modelId || model.aliases?.includes(modelId)
|
|
33
|
+
);
|
|
32
34
|
}
|
|
33
35
|
/** Get models available from a specific provider */
|
|
34
36
|
fromProvider(provider) {
|
|
@@ -733,6 +735,14 @@ function validateModel(raw) {
|
|
|
733
735
|
if (!model.can.every((c) => validCapabilities.includes(c))) {
|
|
734
736
|
throw new Error(`Model has invalid capabilities: ${model.can.join(", ")}`);
|
|
735
737
|
}
|
|
738
|
+
if (model.aliases !== void 0) {
|
|
739
|
+
if (!Array.isArray(model.aliases)) {
|
|
740
|
+
throw new Error("Model aliases must be an array");
|
|
741
|
+
}
|
|
742
|
+
if (!model.aliases.every((a) => typeof a === "string")) {
|
|
743
|
+
throw new Error("Model aliases must be strings");
|
|
744
|
+
}
|
|
745
|
+
}
|
|
736
746
|
if (typeof model.context !== "object" || model.context === null) {
|
|
737
747
|
throw new Error("Model context must be an object");
|
|
738
748
|
}
|
|
@@ -757,7 +767,8 @@ function validateModel(raw) {
|
|
|
757
767
|
providers: model.providers,
|
|
758
768
|
can: model.can,
|
|
759
769
|
context: model.context,
|
|
760
|
-
...model.languages ? { languages: model.languages } : {}
|
|
770
|
+
...model.languages ? { languages: model.languages } : {},
|
|
771
|
+
...model.aliases ? { aliases: model.aliases } : {}
|
|
761
772
|
};
|
|
762
773
|
}
|
|
763
774
|
function buildAllModels() {
|