aimodels 0.2.4 → 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 CHANGED
@@ -23,24 +23,35 @@ 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;
30
30
  /** Filter models by minimum context window size */
31
31
  withMinContext(tokens: number): ModelCollection;
32
32
  }
33
- interface ModelContext {
33
+ interface TokenModelContext {
34
34
  /** Maximum total tokens (input + output) */
35
- total: number;
35
+ total: number | null;
36
36
  /** Maximum output tokens */
37
+ maxOutput: number | null;
38
+ }
39
+ interface ImageModelContext {
40
+ /** Maximum outputs per request */
37
41
  maxOutput: number;
42
+ /** Available image sizes */
43
+ sizes: string[];
44
+ /** Available quality settings */
45
+ qualities: string[];
38
46
  }
47
+ type ModelContext = TokenModelContext | ImageModelContext;
39
48
  interface Model {
40
49
  /** Unique identifier */
41
50
  id: string;
42
51
  /** Display name */
43
52
  name: string;
53
+ /** Creator of the model */
54
+ creator: string;
44
55
  /** License type (e.g., "proprietary", "apache-2.0", "llama-2-community") */
45
56
  license: string;
46
57
  /** List of providers that can serve this model */
@@ -49,6 +60,8 @@ interface Model {
49
60
  can: Capability[];
50
61
  /** Languages the model knows */
51
62
  languages?: string[];
63
+ /** Alternative identifiers for this model */
64
+ aliases?: string[];
52
65
  /** Context window information */
53
66
  context: ModelContext;
54
67
  }
package/dist/index.d.ts CHANGED
@@ -23,24 +23,35 @@ 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;
30
30
  /** Filter models by minimum context window size */
31
31
  withMinContext(tokens: number): ModelCollection;
32
32
  }
33
- interface ModelContext {
33
+ interface TokenModelContext {
34
34
  /** Maximum total tokens (input + output) */
35
- total: number;
35
+ total: number | null;
36
36
  /** Maximum output tokens */
37
+ maxOutput: number | null;
38
+ }
39
+ interface ImageModelContext {
40
+ /** Maximum outputs per request */
37
41
  maxOutput: number;
42
+ /** Available image sizes */
43
+ sizes: string[];
44
+ /** Available quality settings */
45
+ qualities: string[];
38
46
  }
47
+ type ModelContext = TokenModelContext | ImageModelContext;
39
48
  interface Model {
40
49
  /** Unique identifier */
41
50
  id: string;
42
51
  /** Display name */
43
52
  name: string;
53
+ /** Creator of the model */
54
+ creator: string;
44
55
  /** License type (e.g., "proprietary", "apache-2.0", "llama-2-community") */
45
56
  license: string;
46
57
  /** List of providers that can serve this model */
@@ -49,6 +60,8 @@ interface Model {
49
60
  can: Capability[];
50
61
  /** Languages the model knows */
51
62
  languages?: string[];
63
+ /** Alternative identifiers for this model */
64
+ aliases?: string[];
52
65
  /** Context window information */
53
66
  context: ModelContext;
54
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((model) => model.id === modelId);
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) {
@@ -64,12 +66,16 @@ var ModelCollection = class _ModelCollection extends Array {
64
66
  }
65
67
  /** Filter models by minimum context window size */
66
68
  withMinContext(tokens) {
67
- return this.filter((model) => model.context.total >= tokens);
69
+ return this.filter((model) => {
70
+ const context = model.context;
71
+ return "total" in context && context.total !== null && context.total >= tokens;
72
+ });
68
73
  }
69
74
  };
70
75
 
71
76
  // src/data/models/openai-models.json
72
77
  var openai_models_default = {
78
+ creator: "openai",
73
79
  models: [
74
80
  {
75
81
  id: "whisper-large-v3",
@@ -143,7 +149,7 @@ var openai_models_default = {
143
149
  },
144
150
  {
145
151
  id: "gpt-4o",
146
- name: "GPT-4O",
152
+ name: "GPT-4o",
147
153
  license: "proprietary",
148
154
  providers: [
149
155
  "openai",
@@ -304,13 +310,25 @@ var openai_models_default = {
304
310
 
305
311
  // src/data/models/anthropic-models.json
306
312
  var anthropic_models_default = {
313
+ creator: "anthropic",
307
314
  models: [
308
315
  {
309
316
  id: "claude-3-opus",
310
317
  name: "Claude 3 Opus",
311
318
  license: "proprietary",
312
- providers: ["anthropic", "aws", "google"],
313
- can: ["chat", "img-in", "json-out", "function-out"],
319
+ providers: [
320
+ "anthropic",
321
+ "aws",
322
+ "google"
323
+ ],
324
+ can: [
325
+ "chat",
326
+ "text-in",
327
+ "text-out",
328
+ "img-in",
329
+ "json-out",
330
+ "function-out"
331
+ ],
314
332
  context: {
315
333
  total: 2e5,
316
334
  maxOutput: 4096
@@ -320,8 +338,19 @@ var anthropic_models_default = {
320
338
  id: "claude-3-sonnet",
321
339
  name: "Claude 3 Sonnet",
322
340
  license: "proprietary",
323
- providers: ["anthropic", "aws", "google"],
324
- can: ["chat", "img-in", "json-out", "function-out"],
341
+ providers: [
342
+ "anthropic",
343
+ "aws",
344
+ "google"
345
+ ],
346
+ can: [
347
+ "chat",
348
+ "text-in",
349
+ "text-out",
350
+ "img-in",
351
+ "json-out",
352
+ "function-out"
353
+ ],
325
354
  context: {
326
355
  total: 2e5,
327
356
  maxOutput: 4096
@@ -331,8 +360,19 @@ var anthropic_models_default = {
331
360
  id: "claude-3-haiku",
332
361
  name: "Claude 3 Haiku",
333
362
  license: "proprietary",
334
- providers: ["anthropic", "aws", "google"],
335
- can: ["chat", "img-in", "json-out", "function-out"],
363
+ providers: [
364
+ "anthropic",
365
+ "aws",
366
+ "google"
367
+ ],
368
+ can: [
369
+ "chat",
370
+ "text-in",
371
+ "text-out",
372
+ "img-in",
373
+ "json-out",
374
+ "function-out"
375
+ ],
336
376
  context: {
337
377
  total: 2e5,
338
378
  maxOutput: 4096
@@ -343,6 +383,7 @@ var anthropic_models_default = {
343
383
 
344
384
  // src/data/models/meta-models.json
345
385
  var meta_models_default = {
386
+ creator: "meta",
346
387
  models: [
347
388
  {
348
389
  id: "llama3-70b-8192",
@@ -404,6 +445,7 @@ var meta_models_default = {
404
445
 
405
446
  // src/data/models/mistral-models.json
406
447
  var mistral_models_default = {
448
+ creator: "mistral",
407
449
  models: [
408
450
  {
409
451
  id: "mistral-large-2402",
@@ -489,12 +531,93 @@ var mistral_models_default = {
489
531
 
490
532
  // src/data/models/google-models.json
491
533
  var google_models_default = {
534
+ creator: "google",
492
535
  models: [
493
536
  {
494
- id: "gemma2-9b-it",
495
- name: "Gemma 2 9B Instruct",
537
+ id: "gemini-2.0-flash",
538
+ name: "Gemini 2.0 Flash",
539
+ license: "proprietary",
540
+ providers: ["google"],
541
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in", "reason"],
542
+ context: {
543
+ total: 1048576,
544
+ maxOutput: 8192
545
+ },
546
+ aliases: ["gemini-2.0-flash-001"]
547
+ },
548
+ {
549
+ id: "gemini-2.0-flash-lite",
550
+ name: "Gemini 2.0 Flash Lite",
551
+ license: "proprietary",
552
+ providers: ["google"],
553
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in"],
554
+ context: {
555
+ total: 1048576,
556
+ maxOutput: 8192
557
+ },
558
+ aliases: ["gemini-2.0-flash-lite-preview-02-05"]
559
+ },
560
+ {
561
+ id: "gemini-1.5-flash",
562
+ name: "Gemini 1.5 Flash",
563
+ license: "proprietary",
564
+ providers: ["google"],
565
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in"],
566
+ context: {
567
+ total: 2097152,
568
+ maxOutput: 8192
569
+ }
570
+ },
571
+ {
572
+ id: "gemini-1.5-flash-8b",
573
+ name: "Gemini 1.5 Flash 8B",
574
+ license: "proprietary",
575
+ providers: ["google"],
576
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in"],
577
+ context: {
578
+ total: 2097152,
579
+ maxOutput: 8192
580
+ }
581
+ },
582
+ {
583
+ id: "gemini-1.5-pro",
584
+ name: "Gemini 1.5 Pro",
585
+ license: "proprietary",
586
+ providers: ["google"],
587
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in", "reason"],
588
+ context: {
589
+ total: 2097152,
590
+ maxOutput: 8192
591
+ },
592
+ aliases: ["gemini-1.5-pro-latest", "gemini-1.5-pro-001", "gemini-1.5-pro-002"]
593
+ },
594
+ {
595
+ id: "text-embedding-004",
596
+ name: "Text Embedding 004",
597
+ license: "proprietary",
598
+ providers: ["google"],
599
+ can: ["text-in", "vectors-out"],
600
+ context: {
601
+ total: 2048,
602
+ maxOutput: 768
603
+ }
604
+ },
605
+ {
606
+ id: "gemma-7b-it",
607
+ name: "Gemma 7B Instruct",
496
608
  license: "apache-2.0",
497
- providers: ["groq"],
609
+ providers: ["google"],
610
+ can: ["chat", "text-in", "text-out", "json-out", "function-out"],
611
+ context: {
612
+ total: 8192,
613
+ maxOutput: 4096
614
+ }
615
+ },
616
+ {
617
+ id: "gemma-2b-it",
618
+ name: "Gemma 2B Instruct",
619
+ license: "apache-2.0",
620
+ providers: ["google"],
498
621
  can: ["chat", "text-in", "text-out", "json-out", "function-out"],
499
622
  context: {
500
623
  total: 8192,
@@ -506,6 +629,7 @@ var google_models_default = {
506
629
 
507
630
  // src/data/models/deepseek-models.json
508
631
  var deepseek_models_default = {
632
+ creator: "deepseek",
509
633
  models: [
510
634
  {
511
635
  id: "deepseek-chat",
@@ -545,16 +669,153 @@ var deepseek_models_default = {
545
669
  ]
546
670
  };
547
671
 
672
+ // src/data/models/xai-models.json
673
+ var xai_models_default = {
674
+ creator: "xai",
675
+ models: [
676
+ {
677
+ id: "grok-2-vision-1212",
678
+ name: "Grok 2 Vision",
679
+ creator: "xai",
680
+ license: "proprietary",
681
+ providers: ["xai"],
682
+ can: ["chat", "text-in", "text-out", "img-in"],
683
+ context: {
684
+ total: 32768,
685
+ maxOutput: 4096
686
+ },
687
+ aliases: ["grok-2-vision", "grok-2-vision-latest"]
688
+ },
689
+ {
690
+ id: "grok-2-1212",
691
+ name: "Grok 2",
692
+ creator: "xai",
693
+ license: "proprietary",
694
+ providers: ["xai"],
695
+ can: ["chat", "text-in", "text-out"],
696
+ context: {
697
+ total: 131072,
698
+ maxOutput: 4096
699
+ },
700
+ aliases: ["grok-2", "grok-2-latest"]
701
+ },
702
+ {
703
+ id: "grok-vision-beta",
704
+ name: "Grok Vision Beta",
705
+ creator: "xai",
706
+ license: "proprietary",
707
+ providers: ["xai"],
708
+ can: ["chat", "text-in", "text-out", "img-in"],
709
+ context: {
710
+ total: 8192,
711
+ maxOutput: 4096
712
+ }
713
+ },
714
+ {
715
+ id: "grok-beta",
716
+ name: "Grok Beta",
717
+ creator: "xai",
718
+ license: "proprietary",
719
+ providers: ["xai"],
720
+ can: ["chat", "text-in", "text-out"],
721
+ context: {
722
+ total: 131072,
723
+ maxOutput: 4096
724
+ }
725
+ }
726
+ ]
727
+ };
728
+
548
729
  // src/builders/models.ts
730
+ function validateModel(raw) {
731
+ if (typeof raw !== "object" || raw === null) {
732
+ throw new Error("Model data must be an object");
733
+ }
734
+ const model = raw;
735
+ const stringFields = ["id", "name", "creator", "license"];
736
+ for (const field of stringFields) {
737
+ if (typeof model[field] !== "string") {
738
+ throw new Error(`Model ${field} must be a string`);
739
+ }
740
+ }
741
+ if (!Array.isArray(model.providers)) {
742
+ throw new Error("Model providers must be an array");
743
+ }
744
+ if (!model.providers.every((p) => typeof p === "string")) {
745
+ throw new Error("Model providers must be strings");
746
+ }
747
+ if (!Array.isArray(model.can)) {
748
+ throw new Error("Model capabilities must be an array");
749
+ }
750
+ const validCapabilities = [
751
+ "chat",
752
+ "reason",
753
+ "text-in",
754
+ "text-out",
755
+ "img-in",
756
+ "img-out",
757
+ "sound-in",
758
+ "sound-out",
759
+ "json-out",
760
+ "function-out",
761
+ "vectors-out"
762
+ ];
763
+ if (!model.can.every((c) => validCapabilities.includes(c))) {
764
+ throw new Error(`Model has invalid capabilities: ${model.can.join(", ")}`);
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
+ }
774
+ if (typeof model.context !== "object" || model.context === null) {
775
+ throw new Error("Model context must be an object");
776
+ }
777
+ const context = model.context;
778
+ if (Array.isArray(context.sizes) && Array.isArray(context.qualities)) {
779
+ if (typeof context.maxOutput !== "number") {
780
+ throw new Error("Image model context.maxOutput must be a number");
781
+ }
782
+ } else {
783
+ if (typeof context.total !== "number" && context.total !== null) {
784
+ throw new Error("Token model context.total must be a number or null");
785
+ }
786
+ if (typeof context.maxOutput !== "number" && context.maxOutput !== null) {
787
+ throw new Error("Token model context.maxOutput must be a number or null");
788
+ }
789
+ }
790
+ return {
791
+ id: model.id,
792
+ name: model.name,
793
+ creator: model.creator,
794
+ license: model.license,
795
+ providers: model.providers,
796
+ can: model.can,
797
+ context: model.context,
798
+ ...model.languages ? { languages: model.languages } : {},
799
+ ...model.aliases ? { aliases: model.aliases } : {}
800
+ };
801
+ }
549
802
  function buildAllModels() {
550
- return [
551
- ...openai_models_default.models,
552
- ...anthropic_models_default.models,
553
- ...meta_models_default.models,
554
- ...mistral_models_default.models,
555
- ...google_models_default.models,
556
- ...deepseek_models_default.models
803
+ const allModelData = [
804
+ openai_models_default,
805
+ anthropic_models_default,
806
+ meta_models_default,
807
+ mistral_models_default,
808
+ google_models_default,
809
+ deepseek_models_default,
810
+ xai_models_default
557
811
  ];
812
+ const allModels2 = allModelData.flatMap(
813
+ (data) => data.models.map((model) => ({
814
+ ...model,
815
+ creator: data.creator
816
+ }))
817
+ );
818
+ return allModels2.map((model) => validateModel(model));
558
819
  }
559
820
 
560
821
  // src/data/providers/openai-provider.json
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((model) => model.id === modelId);
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) {
@@ -36,12 +38,16 @@ var ModelCollection = class _ModelCollection extends Array {
36
38
  }
37
39
  /** Filter models by minimum context window size */
38
40
  withMinContext(tokens) {
39
- return this.filter((model) => model.context.total >= tokens);
41
+ return this.filter((model) => {
42
+ const context = model.context;
43
+ return "total" in context && context.total !== null && context.total >= tokens;
44
+ });
40
45
  }
41
46
  };
42
47
 
43
48
  // src/data/models/openai-models.json
44
49
  var openai_models_default = {
50
+ creator: "openai",
45
51
  models: [
46
52
  {
47
53
  id: "whisper-large-v3",
@@ -115,7 +121,7 @@ var openai_models_default = {
115
121
  },
116
122
  {
117
123
  id: "gpt-4o",
118
- name: "GPT-4O",
124
+ name: "GPT-4o",
119
125
  license: "proprietary",
120
126
  providers: [
121
127
  "openai",
@@ -276,13 +282,25 @@ var openai_models_default = {
276
282
 
277
283
  // src/data/models/anthropic-models.json
278
284
  var anthropic_models_default = {
285
+ creator: "anthropic",
279
286
  models: [
280
287
  {
281
288
  id: "claude-3-opus",
282
289
  name: "Claude 3 Opus",
283
290
  license: "proprietary",
284
- providers: ["anthropic", "aws", "google"],
285
- can: ["chat", "img-in", "json-out", "function-out"],
291
+ providers: [
292
+ "anthropic",
293
+ "aws",
294
+ "google"
295
+ ],
296
+ can: [
297
+ "chat",
298
+ "text-in",
299
+ "text-out",
300
+ "img-in",
301
+ "json-out",
302
+ "function-out"
303
+ ],
286
304
  context: {
287
305
  total: 2e5,
288
306
  maxOutput: 4096
@@ -292,8 +310,19 @@ var anthropic_models_default = {
292
310
  id: "claude-3-sonnet",
293
311
  name: "Claude 3 Sonnet",
294
312
  license: "proprietary",
295
- providers: ["anthropic", "aws", "google"],
296
- can: ["chat", "img-in", "json-out", "function-out"],
313
+ providers: [
314
+ "anthropic",
315
+ "aws",
316
+ "google"
317
+ ],
318
+ can: [
319
+ "chat",
320
+ "text-in",
321
+ "text-out",
322
+ "img-in",
323
+ "json-out",
324
+ "function-out"
325
+ ],
297
326
  context: {
298
327
  total: 2e5,
299
328
  maxOutput: 4096
@@ -303,8 +332,19 @@ var anthropic_models_default = {
303
332
  id: "claude-3-haiku",
304
333
  name: "Claude 3 Haiku",
305
334
  license: "proprietary",
306
- providers: ["anthropic", "aws", "google"],
307
- can: ["chat", "img-in", "json-out", "function-out"],
335
+ providers: [
336
+ "anthropic",
337
+ "aws",
338
+ "google"
339
+ ],
340
+ can: [
341
+ "chat",
342
+ "text-in",
343
+ "text-out",
344
+ "img-in",
345
+ "json-out",
346
+ "function-out"
347
+ ],
308
348
  context: {
309
349
  total: 2e5,
310
350
  maxOutput: 4096
@@ -315,6 +355,7 @@ var anthropic_models_default = {
315
355
 
316
356
  // src/data/models/meta-models.json
317
357
  var meta_models_default = {
358
+ creator: "meta",
318
359
  models: [
319
360
  {
320
361
  id: "llama3-70b-8192",
@@ -376,6 +417,7 @@ var meta_models_default = {
376
417
 
377
418
  // src/data/models/mistral-models.json
378
419
  var mistral_models_default = {
420
+ creator: "mistral",
379
421
  models: [
380
422
  {
381
423
  id: "mistral-large-2402",
@@ -461,12 +503,93 @@ var mistral_models_default = {
461
503
 
462
504
  // src/data/models/google-models.json
463
505
  var google_models_default = {
506
+ creator: "google",
464
507
  models: [
465
508
  {
466
- id: "gemma2-9b-it",
467
- name: "Gemma 2 9B Instruct",
509
+ id: "gemini-2.0-flash",
510
+ name: "Gemini 2.0 Flash",
511
+ license: "proprietary",
512
+ providers: ["google"],
513
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in", "reason"],
514
+ context: {
515
+ total: 1048576,
516
+ maxOutput: 8192
517
+ },
518
+ aliases: ["gemini-2.0-flash-001"]
519
+ },
520
+ {
521
+ id: "gemini-2.0-flash-lite",
522
+ name: "Gemini 2.0 Flash Lite",
523
+ license: "proprietary",
524
+ providers: ["google"],
525
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in"],
526
+ context: {
527
+ total: 1048576,
528
+ maxOutput: 8192
529
+ },
530
+ aliases: ["gemini-2.0-flash-lite-preview-02-05"]
531
+ },
532
+ {
533
+ id: "gemini-1.5-flash",
534
+ name: "Gemini 1.5 Flash",
535
+ license: "proprietary",
536
+ providers: ["google"],
537
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in"],
538
+ context: {
539
+ total: 2097152,
540
+ maxOutput: 8192
541
+ }
542
+ },
543
+ {
544
+ id: "gemini-1.5-flash-8b",
545
+ name: "Gemini 1.5 Flash 8B",
546
+ license: "proprietary",
547
+ providers: ["google"],
548
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in"],
549
+ context: {
550
+ total: 2097152,
551
+ maxOutput: 8192
552
+ }
553
+ },
554
+ {
555
+ id: "gemini-1.5-pro",
556
+ name: "Gemini 1.5 Pro",
557
+ license: "proprietary",
558
+ providers: ["google"],
559
+ can: ["chat", "text-in", "text-out", "json-out", "function-out", "img-in", "sound-in", "reason"],
560
+ context: {
561
+ total: 2097152,
562
+ maxOutput: 8192
563
+ },
564
+ aliases: ["gemini-1.5-pro-latest", "gemini-1.5-pro-001", "gemini-1.5-pro-002"]
565
+ },
566
+ {
567
+ id: "text-embedding-004",
568
+ name: "Text Embedding 004",
569
+ license: "proprietary",
570
+ providers: ["google"],
571
+ can: ["text-in", "vectors-out"],
572
+ context: {
573
+ total: 2048,
574
+ maxOutput: 768
575
+ }
576
+ },
577
+ {
578
+ id: "gemma-7b-it",
579
+ name: "Gemma 7B Instruct",
468
580
  license: "apache-2.0",
469
- providers: ["groq"],
581
+ providers: ["google"],
582
+ can: ["chat", "text-in", "text-out", "json-out", "function-out"],
583
+ context: {
584
+ total: 8192,
585
+ maxOutput: 4096
586
+ }
587
+ },
588
+ {
589
+ id: "gemma-2b-it",
590
+ name: "Gemma 2B Instruct",
591
+ license: "apache-2.0",
592
+ providers: ["google"],
470
593
  can: ["chat", "text-in", "text-out", "json-out", "function-out"],
471
594
  context: {
472
595
  total: 8192,
@@ -478,6 +601,7 @@ var google_models_default = {
478
601
 
479
602
  // src/data/models/deepseek-models.json
480
603
  var deepseek_models_default = {
604
+ creator: "deepseek",
481
605
  models: [
482
606
  {
483
607
  id: "deepseek-chat",
@@ -517,16 +641,153 @@ var deepseek_models_default = {
517
641
  ]
518
642
  };
519
643
 
644
+ // src/data/models/xai-models.json
645
+ var xai_models_default = {
646
+ creator: "xai",
647
+ models: [
648
+ {
649
+ id: "grok-2-vision-1212",
650
+ name: "Grok 2 Vision",
651
+ creator: "xai",
652
+ license: "proprietary",
653
+ providers: ["xai"],
654
+ can: ["chat", "text-in", "text-out", "img-in"],
655
+ context: {
656
+ total: 32768,
657
+ maxOutput: 4096
658
+ },
659
+ aliases: ["grok-2-vision", "grok-2-vision-latest"]
660
+ },
661
+ {
662
+ id: "grok-2-1212",
663
+ name: "Grok 2",
664
+ creator: "xai",
665
+ license: "proprietary",
666
+ providers: ["xai"],
667
+ can: ["chat", "text-in", "text-out"],
668
+ context: {
669
+ total: 131072,
670
+ maxOutput: 4096
671
+ },
672
+ aliases: ["grok-2", "grok-2-latest"]
673
+ },
674
+ {
675
+ id: "grok-vision-beta",
676
+ name: "Grok Vision Beta",
677
+ creator: "xai",
678
+ license: "proprietary",
679
+ providers: ["xai"],
680
+ can: ["chat", "text-in", "text-out", "img-in"],
681
+ context: {
682
+ total: 8192,
683
+ maxOutput: 4096
684
+ }
685
+ },
686
+ {
687
+ id: "grok-beta",
688
+ name: "Grok Beta",
689
+ creator: "xai",
690
+ license: "proprietary",
691
+ providers: ["xai"],
692
+ can: ["chat", "text-in", "text-out"],
693
+ context: {
694
+ total: 131072,
695
+ maxOutput: 4096
696
+ }
697
+ }
698
+ ]
699
+ };
700
+
520
701
  // src/builders/models.ts
702
+ function validateModel(raw) {
703
+ if (typeof raw !== "object" || raw === null) {
704
+ throw new Error("Model data must be an object");
705
+ }
706
+ const model = raw;
707
+ const stringFields = ["id", "name", "creator", "license"];
708
+ for (const field of stringFields) {
709
+ if (typeof model[field] !== "string") {
710
+ throw new Error(`Model ${field} must be a string`);
711
+ }
712
+ }
713
+ if (!Array.isArray(model.providers)) {
714
+ throw new Error("Model providers must be an array");
715
+ }
716
+ if (!model.providers.every((p) => typeof p === "string")) {
717
+ throw new Error("Model providers must be strings");
718
+ }
719
+ if (!Array.isArray(model.can)) {
720
+ throw new Error("Model capabilities must be an array");
721
+ }
722
+ const validCapabilities = [
723
+ "chat",
724
+ "reason",
725
+ "text-in",
726
+ "text-out",
727
+ "img-in",
728
+ "img-out",
729
+ "sound-in",
730
+ "sound-out",
731
+ "json-out",
732
+ "function-out",
733
+ "vectors-out"
734
+ ];
735
+ if (!model.can.every((c) => validCapabilities.includes(c))) {
736
+ throw new Error(`Model has invalid capabilities: ${model.can.join(", ")}`);
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
+ }
746
+ if (typeof model.context !== "object" || model.context === null) {
747
+ throw new Error("Model context must be an object");
748
+ }
749
+ const context = model.context;
750
+ if (Array.isArray(context.sizes) && Array.isArray(context.qualities)) {
751
+ if (typeof context.maxOutput !== "number") {
752
+ throw new Error("Image model context.maxOutput must be a number");
753
+ }
754
+ } else {
755
+ if (typeof context.total !== "number" && context.total !== null) {
756
+ throw new Error("Token model context.total must be a number or null");
757
+ }
758
+ if (typeof context.maxOutput !== "number" && context.maxOutput !== null) {
759
+ throw new Error("Token model context.maxOutput must be a number or null");
760
+ }
761
+ }
762
+ return {
763
+ id: model.id,
764
+ name: model.name,
765
+ creator: model.creator,
766
+ license: model.license,
767
+ providers: model.providers,
768
+ can: model.can,
769
+ context: model.context,
770
+ ...model.languages ? { languages: model.languages } : {},
771
+ ...model.aliases ? { aliases: model.aliases } : {}
772
+ };
773
+ }
521
774
  function buildAllModels() {
522
- return [
523
- ...openai_models_default.models,
524
- ...anthropic_models_default.models,
525
- ...meta_models_default.models,
526
- ...mistral_models_default.models,
527
- ...google_models_default.models,
528
- ...deepseek_models_default.models
775
+ const allModelData = [
776
+ openai_models_default,
777
+ anthropic_models_default,
778
+ meta_models_default,
779
+ mistral_models_default,
780
+ google_models_default,
781
+ deepseek_models_default,
782
+ xai_models_default
529
783
  ];
784
+ const allModels2 = allModelData.flatMap(
785
+ (data) => data.models.map((model) => ({
786
+ ...model,
787
+ creator: data.creator
788
+ }))
789
+ );
790
+ return allModels2.map((model) => validateModel(model));
530
791
  }
531
792
 
532
793
  // src/data/providers/openai-provider.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimodels",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "description": "A collection of AI model specifications across different providers",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -19,7 +19,6 @@
19
19
  "scripts": {
20
20
  "prebuild": "npm run typecheck && npm run lint && npm test",
21
21
  "build": "tsup src/index.ts --format cjs,esm --dts",
22
- "gen-ai-rules": "node scripts/gen-ai-rules.js",
23
22
  "test": "deno test tests/",
24
23
  "test:watch": "deno test --watch tests/",
25
24
  "typecheck": "tsc --noEmit",
@@ -30,7 +29,11 @@
30
29
  "version": "git add -A",
31
30
  "postversion": "git push && git push --tags",
32
31
  "prepublishOnly": "npm run clean && npm run typecheck && npm test && npm run lint",
33
- "postpublish": "npm run clean"
32
+ "postpublish": "npm run clean",
33
+ "rules": "airul generate",
34
+ "rules:comment": "# Generate AI rules from documentation",
35
+ "pregenerate": "[ -f .airul.json ] || airul init",
36
+ "postinstall": "echo \"\nRun 'npm run rules' to generate AI rules from your documentation\""
34
37
  },
35
38
  "keywords": [
36
39
  "ai",
@@ -61,6 +64,7 @@
61
64
  "@types/node": "^20.0.0",
62
65
  "@typescript-eslint/eslint-plugin": "^6.0.0",
63
66
  "@typescript-eslint/parser": "^6.0.0",
67
+ "airul": "^0.1.10",
64
68
  "eslint": "^8.0.0",
65
69
  "tsup": "^8.0.0",
66
70
  "typescript": "^5.0.0"