@ai-sdk/fireworks 2.0.0-beta.60 → 2.0.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/CHANGELOG.md +88 -235
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @ai-sdk/fireworks
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [29264a3]
|
|
8
|
+
- @ai-sdk/provider-utils@4.0.1
|
|
9
|
+
- @ai-sdk/openai-compatible@2.0.1
|
|
10
|
+
|
|
11
|
+
## 2.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- dee8b05: ai SDK 6 beta
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 78928cb: release: start 5.1 beta
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 0c3b58b: fix(provider): add specificationVersion to ProviderV3
|
|
24
|
+
- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
|
|
25
|
+
|
|
26
|
+
Before
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
model.textEmbeddingModel('my-model-id');
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
After
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
model.embeddingModel('my-model-id');
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- 95f65c2: chore: use import \* from zod/v4
|
|
39
|
+
- 0c4822d: feat: `EmbeddingModelV3`
|
|
40
|
+
- ed329cb: feat: `Provider-V3`
|
|
41
|
+
- 1cad0ab: feat: add provider version to user-agent header
|
|
42
|
+
- 8dac895: feat: `LanguageModelV3`
|
|
43
|
+
- 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
|
|
44
|
+
- 9061dc0: feat: image editing
|
|
45
|
+
- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
|
|
46
|
+
- 4616b86: chore: update zod peer depenedency version
|
|
47
|
+
- 522f6b8: feat: `ImageModelV3`
|
|
48
|
+
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
|
49
|
+
- Updated dependencies
|
|
50
|
+
- @ai-sdk/openai-compatible@2.0.0
|
|
51
|
+
- @ai-sdk/provider@3.0.0
|
|
52
|
+
- @ai-sdk/provider-utils@4.0.0
|
|
53
|
+
|
|
3
54
|
## 2.0.0-beta.60
|
|
4
55
|
|
|
5
56
|
### Patch Changes
|
|
@@ -440,8 +491,7 @@
|
|
|
440
491
|
### Patch Changes
|
|
441
492
|
|
|
442
493
|
- 95f65c2: chore: use import \* from zod/v4
|
|
443
|
-
- Updated dependencies
|
|
444
|
-
- Updated dependencies [95f65c2]
|
|
494
|
+
- Updated dependencies
|
|
445
495
|
- @ai-sdk/openai-compatible@2.0.0-beta.11
|
|
446
496
|
- @ai-sdk/provider-utils@4.0.0-beta.11
|
|
447
497
|
|
|
@@ -478,8 +528,7 @@
|
|
|
478
528
|
|
|
479
529
|
### Patch Changes
|
|
480
530
|
|
|
481
|
-
- Updated dependencies
|
|
482
|
-
- Updated dependencies [e8109d3]
|
|
531
|
+
- Updated dependencies
|
|
483
532
|
- @ai-sdk/provider@2.1.0-beta.5
|
|
484
533
|
- @ai-sdk/openai-compatible@1.1.0-beta.7
|
|
485
534
|
- @ai-sdk/provider-utils@3.1.0-beta.7
|
|
@@ -488,8 +537,7 @@
|
|
|
488
537
|
|
|
489
538
|
### Patch Changes
|
|
490
539
|
|
|
491
|
-
- Updated dependencies
|
|
492
|
-
- Updated dependencies [2b0caef]
|
|
540
|
+
- Updated dependencies
|
|
493
541
|
- @ai-sdk/openai-compatible@1.1.0-beta.6
|
|
494
542
|
- @ai-sdk/provider-utils@3.1.0-beta.6
|
|
495
543
|
- @ai-sdk/provider@2.1.0-beta.4
|
|
@@ -500,8 +548,7 @@
|
|
|
500
548
|
|
|
501
549
|
- 8dac895: feat: `LanguageModelV3`
|
|
502
550
|
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
|
503
|
-
- Updated dependencies
|
|
504
|
-
- Updated dependencies [10c1322]
|
|
551
|
+
- Updated dependencies
|
|
505
552
|
- @ai-sdk/openai-compatible@1.1.0-beta.5
|
|
506
553
|
- @ai-sdk/provider-utils@3.1.0-beta.5
|
|
507
554
|
- @ai-sdk/provider@2.1.0-beta.3
|
|
@@ -521,8 +568,7 @@
|
|
|
521
568
|
|
|
522
569
|
- ed329cb: feat: `Provider-V3`
|
|
523
570
|
- 522f6b8: feat: `ImageModelV3`
|
|
524
|
-
- Updated dependencies
|
|
525
|
-
- Updated dependencies [522f6b8]
|
|
571
|
+
- Updated dependencies
|
|
526
572
|
- @ai-sdk/openai-compatible@1.1.0-beta.3
|
|
527
573
|
- @ai-sdk/provider@2.1.0-beta.2
|
|
528
574
|
- @ai-sdk/provider-utils@3.1.0-beta.3
|
|
@@ -542,8 +588,7 @@
|
|
|
542
588
|
|
|
543
589
|
### Patch Changes
|
|
544
590
|
|
|
545
|
-
- Updated dependencies
|
|
546
|
-
- Updated dependencies [cbb1d35]
|
|
591
|
+
- Updated dependencies
|
|
547
592
|
- @ai-sdk/test-server@1.0.0-beta.0
|
|
548
593
|
- @ai-sdk/provider-utils@3.1.0-beta.1
|
|
549
594
|
- @ai-sdk/openai-compatible@1.1.0-beta.1
|
|
@@ -648,8 +693,7 @@
|
|
|
648
693
|
|
|
649
694
|
### Patch Changes
|
|
650
695
|
|
|
651
|
-
- Updated dependencies
|
|
652
|
-
- Updated dependencies [f25040d]
|
|
696
|
+
- Updated dependencies
|
|
653
697
|
- @ai-sdk/provider-utils@3.0.3
|
|
654
698
|
- @ai-sdk/openai-compatible@1.0.7
|
|
655
699
|
|
|
@@ -665,16 +709,14 @@
|
|
|
665
709
|
|
|
666
710
|
### Patch Changes
|
|
667
711
|
|
|
668
|
-
- Updated dependencies
|
|
669
|
-
- Updated dependencies [e92b78b]
|
|
712
|
+
- Updated dependencies
|
|
670
713
|
- @ai-sdk/openai-compatible@1.0.5
|
|
671
714
|
|
|
672
715
|
## 1.0.4
|
|
673
716
|
|
|
674
717
|
### Patch Changes
|
|
675
718
|
|
|
676
|
-
- Updated dependencies
|
|
677
|
-
- Updated dependencies [da314cd]
|
|
719
|
+
- Updated dependencies
|
|
678
720
|
- @ai-sdk/openai-compatible@1.0.4
|
|
679
721
|
|
|
680
722
|
## 1.0.3
|
|
@@ -688,8 +730,7 @@
|
|
|
688
730
|
|
|
689
731
|
### Patch Changes
|
|
690
732
|
|
|
691
|
-
- Updated dependencies
|
|
692
|
-
- Updated dependencies [90d212f]
|
|
733
|
+
- Updated dependencies
|
|
693
734
|
- @ai-sdk/openai-compatible@1.0.2
|
|
694
735
|
- @ai-sdk/provider-utils@3.0.1
|
|
695
736
|
|
|
@@ -748,120 +789,7 @@
|
|
|
748
789
|
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
|
749
790
|
- d1a034f: feature: using Zod 4 for internal stuff
|
|
750
791
|
- 205077b: fix: improve Zod compatibility
|
|
751
|
-
- Updated dependencies
|
|
752
|
-
- Updated dependencies [742b7be]
|
|
753
|
-
- Updated dependencies [e7fcc86]
|
|
754
|
-
- Updated dependencies [7cddb72]
|
|
755
|
-
- Updated dependencies [ccce59b]
|
|
756
|
-
- Updated dependencies [e2b9e4b]
|
|
757
|
-
- Updated dependencies [95857aa]
|
|
758
|
-
- Updated dependencies [45c1ea2]
|
|
759
|
-
- Updated dependencies [6f6bb89]
|
|
760
|
-
- Updated dependencies [060370c]
|
|
761
|
-
- Updated dependencies [dc714f3]
|
|
762
|
-
- Updated dependencies [b5da06a]
|
|
763
|
-
- Updated dependencies [d1a1aa1]
|
|
764
|
-
- Updated dependencies [63f9e9b]
|
|
765
|
-
- Updated dependencies [5d142ab]
|
|
766
|
-
- Updated dependencies [d5f588f]
|
|
767
|
-
- Updated dependencies [e025824]
|
|
768
|
-
- Updated dependencies [0571b98]
|
|
769
|
-
- Updated dependencies [6db02c9]
|
|
770
|
-
- Updated dependencies [b6b43c7]
|
|
771
|
-
- Updated dependencies [4fef487]
|
|
772
|
-
- Updated dependencies [48d257a]
|
|
773
|
-
- Updated dependencies [0c0c0b3]
|
|
774
|
-
- Updated dependencies [0d2c085]
|
|
775
|
-
- Updated dependencies [fa49207]
|
|
776
|
-
- Updated dependencies [40acf9b]
|
|
777
|
-
- Updated dependencies [cf8280e]
|
|
778
|
-
- Updated dependencies [9222aeb]
|
|
779
|
-
- Updated dependencies [b9a6121]
|
|
780
|
-
- Updated dependencies [e2aceaf]
|
|
781
|
-
- Updated dependencies [411e483]
|
|
782
|
-
- Updated dependencies [8ba77a7]
|
|
783
|
-
- Updated dependencies [db72adc]
|
|
784
|
-
- Updated dependencies [7b3ae3f]
|
|
785
|
-
- Updated dependencies [a166433]
|
|
786
|
-
- Updated dependencies [26735b5]
|
|
787
|
-
- Updated dependencies [443d8ec]
|
|
788
|
-
- Updated dependencies [42e32b0]
|
|
789
|
-
- Updated dependencies [a8c8bd5]
|
|
790
|
-
- Updated dependencies [abf9a79]
|
|
791
|
-
- Updated dependencies [14c9410]
|
|
792
|
-
- Updated dependencies [e86be6f]
|
|
793
|
-
- Updated dependencies [9bf7291]
|
|
794
|
-
- Updated dependencies [2e13791]
|
|
795
|
-
- Updated dependencies [7b069ed]
|
|
796
|
-
- Updated dependencies [9f95b35]
|
|
797
|
-
- Updated dependencies [66962ed]
|
|
798
|
-
- Updated dependencies [0d06df6]
|
|
799
|
-
- Updated dependencies [472524a]
|
|
800
|
-
- Updated dependencies [dd3ff01]
|
|
801
|
-
- Updated dependencies [d9209ca]
|
|
802
|
-
- Updated dependencies [d9c98f4]
|
|
803
|
-
- Updated dependencies [05d2819]
|
|
804
|
-
- Updated dependencies [9301f86]
|
|
805
|
-
- Updated dependencies [0a87932]
|
|
806
|
-
- Updated dependencies [737f1e2]
|
|
807
|
-
- Updated dependencies [c4a2fec]
|
|
808
|
-
- Updated dependencies [957b739]
|
|
809
|
-
- Updated dependencies [79457bd]
|
|
810
|
-
- Updated dependencies [a3f768e]
|
|
811
|
-
- Updated dependencies [7435eb5]
|
|
812
|
-
- Updated dependencies [8aa9e20]
|
|
813
|
-
- Updated dependencies [4617fab]
|
|
814
|
-
- Updated dependencies [516be5b]
|
|
815
|
-
- Updated dependencies [ac34802]
|
|
816
|
-
- Updated dependencies [0054544]
|
|
817
|
-
- Updated dependencies [cb68df0]
|
|
818
|
-
- Updated dependencies [ad80501]
|
|
819
|
-
- Updated dependencies [68ecf2f]
|
|
820
|
-
- Updated dependencies [9e9c809]
|
|
821
|
-
- Updated dependencies [32831c6]
|
|
822
|
-
- Updated dependencies [6dc848c]
|
|
823
|
-
- Updated dependencies [6b98118]
|
|
824
|
-
- Updated dependencies [d0f9495]
|
|
825
|
-
- Updated dependencies [63d791d]
|
|
826
|
-
- Updated dependencies [87b828f]
|
|
827
|
-
- Updated dependencies [3f2f00c]
|
|
828
|
-
- Updated dependencies [bfdca8d]
|
|
829
|
-
- Updated dependencies [0ff02bb]
|
|
830
|
-
- Updated dependencies [7979f7f]
|
|
831
|
-
- Updated dependencies [39a4fab]
|
|
832
|
-
- Updated dependencies [44f4aba]
|
|
833
|
-
- Updated dependencies [9bd5ab5]
|
|
834
|
-
- Updated dependencies [57edfcb]
|
|
835
|
-
- Updated dependencies [faf8446]
|
|
836
|
-
- Updated dependencies [7ea4132]
|
|
837
|
-
- Updated dependencies [d1a034f]
|
|
838
|
-
- Updated dependencies [5c56081]
|
|
839
|
-
- Updated dependencies [fd65bc6]
|
|
840
|
-
- Updated dependencies [023ba40]
|
|
841
|
-
- Updated dependencies [ea7a7c9]
|
|
842
|
-
- Updated dependencies [1b101e1]
|
|
843
|
-
- Updated dependencies [26535e0]
|
|
844
|
-
- Updated dependencies [e030615]
|
|
845
|
-
- Updated dependencies [5e57fae]
|
|
846
|
-
- Updated dependencies [393138b]
|
|
847
|
-
- Updated dependencies [c57e248]
|
|
848
|
-
- Updated dependencies [88a8ee5]
|
|
849
|
-
- Updated dependencies [41fa418]
|
|
850
|
-
- Updated dependencies [205077b]
|
|
851
|
-
- Updated dependencies [71f938d]
|
|
852
|
-
- Updated dependencies [3795467]
|
|
853
|
-
- Updated dependencies [28a5ed5]
|
|
854
|
-
- Updated dependencies [7182d14]
|
|
855
|
-
- Updated dependencies [c1e6647]
|
|
856
|
-
- Updated dependencies [1766ede]
|
|
857
|
-
- Updated dependencies [811dff3]
|
|
858
|
-
- Updated dependencies [f10304b]
|
|
859
|
-
- Updated dependencies [dd5fd43]
|
|
860
|
-
- Updated dependencies [33f4a6a]
|
|
861
|
-
- Updated dependencies [383cbfa]
|
|
862
|
-
- Updated dependencies [27deb4d]
|
|
863
|
-
- Updated dependencies [c4df419]
|
|
864
|
-
- Updated dependencies [281bb1c]
|
|
792
|
+
- Updated dependencies
|
|
865
793
|
- @ai-sdk/provider-utils@3.0.0
|
|
866
794
|
- @ai-sdk/provider@2.0.0
|
|
867
795
|
- @ai-sdk/openai-compatible@1.0.0
|
|
@@ -904,8 +832,7 @@
|
|
|
904
832
|
|
|
905
833
|
### Patch Changes
|
|
906
834
|
|
|
907
|
-
- Updated dependencies
|
|
908
|
-
- Updated dependencies [ac34802]
|
|
835
|
+
- Updated dependencies
|
|
909
836
|
- @ai-sdk/openai-compatible@1.0.0-beta.9
|
|
910
837
|
- @ai-sdk/provider-utils@3.0.0-beta.6
|
|
911
838
|
|
|
@@ -913,8 +840,7 @@
|
|
|
913
840
|
|
|
914
841
|
### Patch Changes
|
|
915
842
|
|
|
916
|
-
- Updated dependencies
|
|
917
|
-
- Updated dependencies [383cbfa]
|
|
843
|
+
- Updated dependencies
|
|
918
844
|
- @ai-sdk/provider-utils@3.0.0-beta.5
|
|
919
845
|
- @ai-sdk/openai-compatible@1.0.0-beta.8
|
|
920
846
|
|
|
@@ -961,9 +887,7 @@
|
|
|
961
887
|
### Patch Changes
|
|
962
888
|
|
|
963
889
|
- d1a034f: feature: using Zod 4 for internal stuff
|
|
964
|
-
- Updated dependencies
|
|
965
|
-
- Updated dependencies [39a4fab]
|
|
966
|
-
- Updated dependencies [d1a034f]
|
|
890
|
+
- Updated dependencies
|
|
967
891
|
- @ai-sdk/provider-utils@3.0.0-beta.2
|
|
968
892
|
- @ai-sdk/openai-compatible@1.0.0-beta.2
|
|
969
893
|
|
|
@@ -971,23 +895,7 @@
|
|
|
971
895
|
|
|
972
896
|
### Patch Changes
|
|
973
897
|
|
|
974
|
-
- Updated dependencies
|
|
975
|
-
- Updated dependencies [7cddb72]
|
|
976
|
-
- Updated dependencies [ccce59b]
|
|
977
|
-
- Updated dependencies [e2b9e4b]
|
|
978
|
-
- Updated dependencies [45c1ea2]
|
|
979
|
-
- Updated dependencies [e025824]
|
|
980
|
-
- Updated dependencies [0d06df6]
|
|
981
|
-
- Updated dependencies [472524a]
|
|
982
|
-
- Updated dependencies [dd3ff01]
|
|
983
|
-
- Updated dependencies [7435eb5]
|
|
984
|
-
- Updated dependencies [cb68df0]
|
|
985
|
-
- Updated dependencies [bfdca8d]
|
|
986
|
-
- Updated dependencies [44f4aba]
|
|
987
|
-
- Updated dependencies [023ba40]
|
|
988
|
-
- Updated dependencies [5e57fae]
|
|
989
|
-
- Updated dependencies [71f938d]
|
|
990
|
-
- Updated dependencies [28a5ed5]
|
|
898
|
+
- Updated dependencies
|
|
991
899
|
- @ai-sdk/provider@2.0.0-beta.1
|
|
992
900
|
- @ai-sdk/provider-utils@3.0.0-beta.1
|
|
993
901
|
- @ai-sdk/openai-compatible@1.0.0-beta.1
|
|
@@ -996,8 +904,7 @@
|
|
|
996
904
|
|
|
997
905
|
### Patch Changes
|
|
998
906
|
|
|
999
|
-
- Updated dependencies
|
|
1000
|
-
- Updated dependencies [8ba77a7]
|
|
907
|
+
- Updated dependencies
|
|
1001
908
|
- @ai-sdk/provider@2.0.0-alpha.15
|
|
1002
909
|
- @ai-sdk/provider-utils@3.0.0-alpha.15
|
|
1003
910
|
- @ai-sdk/openai-compatible@1.0.0-alpha.15
|
|
@@ -1006,9 +913,7 @@
|
|
|
1006
913
|
|
|
1007
914
|
### Patch Changes
|
|
1008
915
|
|
|
1009
|
-
- Updated dependencies
|
|
1010
|
-
- Updated dependencies [63f9e9b]
|
|
1011
|
-
- Updated dependencies [2e13791]
|
|
916
|
+
- Updated dependencies
|
|
1012
917
|
- @ai-sdk/provider@2.0.0-alpha.14
|
|
1013
918
|
- @ai-sdk/openai-compatible@1.0.0-alpha.14
|
|
1014
919
|
- @ai-sdk/provider-utils@3.0.0-alpha.14
|
|
@@ -1063,8 +968,7 @@
|
|
|
1063
968
|
|
|
1064
969
|
### Patch Changes
|
|
1065
970
|
|
|
1066
|
-
- Updated dependencies
|
|
1067
|
-
- Updated dependencies [9222aeb]
|
|
971
|
+
- Updated dependencies
|
|
1068
972
|
- @ai-sdk/provider-utils@3.0.0-alpha.8
|
|
1069
973
|
- @ai-sdk/provider@2.0.0-alpha.8
|
|
1070
974
|
- @ai-sdk/openai-compatible@1.0.0-alpha.8
|
|
@@ -1178,8 +1082,7 @@
|
|
|
1178
1082
|
|
|
1179
1083
|
### Patch Changes
|
|
1180
1084
|
|
|
1181
|
-
- Updated dependencies
|
|
1182
|
-
- Updated dependencies [ea7a7c9]
|
|
1085
|
+
- Updated dependencies
|
|
1183
1086
|
- @ai-sdk/openai-compatible@1.0.0-canary.17
|
|
1184
1087
|
- @ai-sdk/provider-utils@3.0.0-canary.17
|
|
1185
1088
|
|
|
@@ -1195,10 +1098,7 @@
|
|
|
1195
1098
|
|
|
1196
1099
|
### Patch Changes
|
|
1197
1100
|
|
|
1198
|
-
- Updated dependencies
|
|
1199
|
-
- Updated dependencies [a8c8bd5]
|
|
1200
|
-
- Updated dependencies [7979f7f]
|
|
1201
|
-
- Updated dependencies [41fa418]
|
|
1101
|
+
- Updated dependencies
|
|
1202
1102
|
- @ai-sdk/provider-utils@3.0.0-canary.15
|
|
1203
1103
|
- @ai-sdk/provider@2.0.0-canary.14
|
|
1204
1104
|
- @ai-sdk/openai-compatible@1.0.0-canary.15
|
|
@@ -1207,8 +1107,7 @@
|
|
|
1207
1107
|
|
|
1208
1108
|
### Patch Changes
|
|
1209
1109
|
|
|
1210
|
-
- Updated dependencies
|
|
1211
|
-
- Updated dependencies [9bd5ab5]
|
|
1110
|
+
- Updated dependencies
|
|
1212
1111
|
- @ai-sdk/provider-utils@3.0.0-canary.14
|
|
1213
1112
|
- @ai-sdk/provider@2.0.0-canary.13
|
|
1214
1113
|
- @ai-sdk/openai-compatible@1.0.0-canary.14
|
|
@@ -1218,9 +1117,7 @@
|
|
|
1218
1117
|
### Patch Changes
|
|
1219
1118
|
|
|
1220
1119
|
- d9209ca: fix (image-model): `specificationVersion: v1` -> `v2`
|
|
1221
|
-
- Updated dependencies
|
|
1222
|
-
- Updated dependencies [d9209ca]
|
|
1223
|
-
- Updated dependencies [0ff02bb]
|
|
1120
|
+
- Updated dependencies
|
|
1224
1121
|
- @ai-sdk/provider@2.0.0-canary.12
|
|
1225
1122
|
- @ai-sdk/openai-compatible@1.0.0-canary.13
|
|
1226
1123
|
- @ai-sdk/provider-utils@3.0.0-canary.13
|
|
@@ -1229,9 +1126,7 @@
|
|
|
1229
1126
|
|
|
1230
1127
|
### Patch Changes
|
|
1231
1128
|
|
|
1232
|
-
- Updated dependencies
|
|
1233
|
-
- Updated dependencies [4617fab]
|
|
1234
|
-
- Updated dependencies [e030615]
|
|
1129
|
+
- Updated dependencies
|
|
1235
1130
|
- @ai-sdk/provider@2.0.0-canary.11
|
|
1236
1131
|
- @ai-sdk/openai-compatible@1.0.0-canary.12
|
|
1237
1132
|
- @ai-sdk/provider-utils@3.0.0-canary.12
|
|
@@ -1241,11 +1136,7 @@
|
|
|
1241
1136
|
### Patch Changes
|
|
1242
1137
|
|
|
1243
1138
|
- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2`
|
|
1244
|
-
- Updated dependencies
|
|
1245
|
-
- Updated dependencies [42e32b0]
|
|
1246
|
-
- Updated dependencies [66962ed]
|
|
1247
|
-
- Updated dependencies [9301f86]
|
|
1248
|
-
- Updated dependencies [a3f768e]
|
|
1139
|
+
- Updated dependencies
|
|
1249
1140
|
- @ai-sdk/openai-compatible@1.0.0-canary.11
|
|
1250
1141
|
- @ai-sdk/provider-utils@3.0.0-canary.11
|
|
1251
1142
|
- @ai-sdk/provider@2.0.0-canary.10
|
|
@@ -1254,8 +1145,7 @@
|
|
|
1254
1145
|
|
|
1255
1146
|
### Patch Changes
|
|
1256
1147
|
|
|
1257
|
-
- Updated dependencies
|
|
1258
|
-
- Updated dependencies [e86be6f]
|
|
1148
|
+
- Updated dependencies
|
|
1259
1149
|
- @ai-sdk/openai-compatible@1.0.0-canary.10
|
|
1260
1150
|
- @ai-sdk/provider@2.0.0-canary.9
|
|
1261
1151
|
- @ai-sdk/provider-utils@3.0.0-canary.10
|
|
@@ -1264,8 +1154,7 @@
|
|
|
1264
1154
|
|
|
1265
1155
|
### Patch Changes
|
|
1266
1156
|
|
|
1267
|
-
- Updated dependencies
|
|
1268
|
-
- Updated dependencies [7ea4132]
|
|
1157
|
+
- Updated dependencies
|
|
1269
1158
|
- @ai-sdk/provider@2.0.0-canary.8
|
|
1270
1159
|
- @ai-sdk/openai-compatible@1.0.0-canary.9
|
|
1271
1160
|
- @ai-sdk/provider-utils@3.0.0-canary.9
|
|
@@ -1274,11 +1163,7 @@
|
|
|
1274
1163
|
|
|
1275
1164
|
### Patch Changes
|
|
1276
1165
|
|
|
1277
|
-
- Updated dependencies
|
|
1278
|
-
- Updated dependencies [b6b43c7]
|
|
1279
|
-
- Updated dependencies [b9a6121]
|
|
1280
|
-
- Updated dependencies [8aa9e20]
|
|
1281
|
-
- Updated dependencies [3795467]
|
|
1166
|
+
- Updated dependencies
|
|
1282
1167
|
- @ai-sdk/provider-utils@3.0.0-canary.8
|
|
1283
1168
|
- @ai-sdk/provider@2.0.0-canary.7
|
|
1284
1169
|
- @ai-sdk/openai-compatible@1.0.0-canary.8
|
|
@@ -1289,19 +1174,7 @@
|
|
|
1289
1174
|
|
|
1290
1175
|
- fa49207: feat(providers/openai-compatible): convert to providerOptions
|
|
1291
1176
|
- 26735b5: chore(embedding-model): add v2 interface
|
|
1292
|
-
- Updated dependencies
|
|
1293
|
-
- Updated dependencies [26735b5]
|
|
1294
|
-
- Updated dependencies [443d8ec]
|
|
1295
|
-
- Updated dependencies [14c9410]
|
|
1296
|
-
- Updated dependencies [d9c98f4]
|
|
1297
|
-
- Updated dependencies [c4a2fec]
|
|
1298
|
-
- Updated dependencies [0054544]
|
|
1299
|
-
- Updated dependencies [9e9c809]
|
|
1300
|
-
- Updated dependencies [32831c6]
|
|
1301
|
-
- Updated dependencies [d0f9495]
|
|
1302
|
-
- Updated dependencies [fd65bc6]
|
|
1303
|
-
- Updated dependencies [393138b]
|
|
1304
|
-
- Updated dependencies [7182d14]
|
|
1177
|
+
- Updated dependencies
|
|
1305
1178
|
- @ai-sdk/openai-compatible@1.0.0-canary.7
|
|
1306
1179
|
- @ai-sdk/provider@2.0.0-canary.6
|
|
1307
1180
|
- @ai-sdk/provider-utils@3.0.0-canary.7
|
|
@@ -1310,12 +1183,7 @@
|
|
|
1310
1183
|
|
|
1311
1184
|
### Patch Changes
|
|
1312
1185
|
|
|
1313
|
-
- Updated dependencies
|
|
1314
|
-
- Updated dependencies [411e483]
|
|
1315
|
-
- Updated dependencies [79457bd]
|
|
1316
|
-
- Updated dependencies [ad80501]
|
|
1317
|
-
- Updated dependencies [1766ede]
|
|
1318
|
-
- Updated dependencies [f10304b]
|
|
1186
|
+
- Updated dependencies
|
|
1319
1187
|
- @ai-sdk/openai-compatible@1.0.0-canary.6
|
|
1320
1188
|
- @ai-sdk/provider@2.0.0-canary.5
|
|
1321
1189
|
- @ai-sdk/provider-utils@3.0.0-canary.6
|
|
@@ -1342,11 +1210,7 @@
|
|
|
1342
1210
|
|
|
1343
1211
|
### Patch Changes
|
|
1344
1212
|
|
|
1345
|
-
- Updated dependencies
|
|
1346
|
-
- Updated dependencies [abf9a79]
|
|
1347
|
-
- Updated dependencies [9f95b35]
|
|
1348
|
-
- Updated dependencies [0a87932]
|
|
1349
|
-
- Updated dependencies [6dc848c]
|
|
1213
|
+
- Updated dependencies
|
|
1350
1214
|
- @ai-sdk/provider-utils@3.0.0-canary.3
|
|
1351
1215
|
- @ai-sdk/provider@2.0.0-canary.2
|
|
1352
1216
|
- @ai-sdk/openai-compatible@1.0.0-canary.3
|
|
@@ -1355,8 +1219,7 @@
|
|
|
1355
1219
|
|
|
1356
1220
|
### Patch Changes
|
|
1357
1221
|
|
|
1358
|
-
- Updated dependencies
|
|
1359
|
-
- Updated dependencies [33f4a6a]
|
|
1222
|
+
- Updated dependencies
|
|
1360
1223
|
- @ai-sdk/provider@2.0.0-canary.1
|
|
1361
1224
|
- @ai-sdk/openai-compatible@1.0.0-canary.2
|
|
1362
1225
|
- @ai-sdk/provider-utils@3.0.0-canary.2
|
|
@@ -1365,9 +1228,7 @@
|
|
|
1365
1228
|
|
|
1366
1229
|
### Patch Changes
|
|
1367
1230
|
|
|
1368
|
-
- Updated dependencies
|
|
1369
|
-
- Updated dependencies [0c0c0b3]
|
|
1370
|
-
- Updated dependencies [63d791d]
|
|
1231
|
+
- Updated dependencies
|
|
1371
1232
|
- @ai-sdk/provider-utils@3.0.0-canary.1
|
|
1372
1233
|
- @ai-sdk/openai-compatible@1.0.0-canary.1
|
|
1373
1234
|
|
|
@@ -1573,8 +1434,7 @@
|
|
|
1573
1434
|
### Patch Changes
|
|
1574
1435
|
|
|
1575
1436
|
- 3a58a2e: feat (ai/core): throw NoImageGeneratedError from generateImage when no predictions are returned.
|
|
1576
|
-
- Updated dependencies
|
|
1577
|
-
- Updated dependencies [3a58a2e]
|
|
1437
|
+
- Updated dependencies
|
|
1578
1438
|
- @ai-sdk/openai-compatible@0.1.2
|
|
1579
1439
|
- @ai-sdk/provider-utils@2.1.2
|
|
1580
1440
|
- @ai-sdk/provider@1.0.6
|
|
@@ -1583,8 +1443,7 @@
|
|
|
1583
1443
|
|
|
1584
1444
|
### Patch Changes
|
|
1585
1445
|
|
|
1586
|
-
- Updated dependencies
|
|
1587
|
-
- Updated dependencies [0a699f1]
|
|
1446
|
+
- Updated dependencies
|
|
1588
1447
|
- @ai-sdk/provider-utils@2.1.1
|
|
1589
1448
|
- @ai-sdk/openai-compatible@0.1.1
|
|
1590
1449
|
- @ai-sdk/provider@1.0.5
|
|
@@ -1636,9 +1495,7 @@
|
|
|
1636
1495
|
|
|
1637
1496
|
- 90fb95a: chore (provider-utils): switch to unified test server
|
|
1638
1497
|
- e6dfef4: feat (provider/fireworks): Support add'l image models.
|
|
1639
|
-
- Updated dependencies
|
|
1640
|
-
- Updated dependencies [e6dfef4]
|
|
1641
|
-
- Updated dependencies [6636db6]
|
|
1498
|
+
- Updated dependencies
|
|
1642
1499
|
- @ai-sdk/provider-utils@2.0.7
|
|
1643
1500
|
- @ai-sdk/openai-compatible@0.0.15
|
|
1644
1501
|
|
|
@@ -1648,10 +1505,7 @@
|
|
|
1648
1505
|
|
|
1649
1506
|
- 19a2ce7: feat (provider/fireworks): Add image model support.
|
|
1650
1507
|
- 6337688: feat: change image generation errors to warnings
|
|
1651
|
-
- Updated dependencies
|
|
1652
|
-
- Updated dependencies [19a2ce7]
|
|
1653
|
-
- Updated dependencies [43b37f7]
|
|
1654
|
-
- Updated dependencies [6337688]
|
|
1508
|
+
- Updated dependencies
|
|
1655
1509
|
- @ai-sdk/provider@1.0.4
|
|
1656
1510
|
- @ai-sdk/provider-utils@2.0.6
|
|
1657
1511
|
- @ai-sdk/openai-compatible@0.0.14
|
|
@@ -1681,8 +1535,7 @@
|
|
|
1681
1535
|
### Patch Changes
|
|
1682
1536
|
|
|
1683
1537
|
- 5ed5e45: chore (config): Use ts-library.json tsconfig for no-UI libs.
|
|
1684
|
-
- Updated dependencies
|
|
1685
|
-
- Updated dependencies [307c247]
|
|
1538
|
+
- Updated dependencies
|
|
1686
1539
|
- @ai-sdk/openai-compatible@0.0.11
|
|
1687
1540
|
- @ai-sdk/provider-utils@2.0.5
|
|
1688
1541
|
- @ai-sdk/provider@1.0.3
|
package/dist/index.js
CHANGED
|
@@ -174,7 +174,7 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
|
174
174
|
var import_v4 = require("zod/v4");
|
|
175
175
|
|
|
176
176
|
// src/version.ts
|
|
177
|
-
var VERSION = true ? "2.0.
|
|
177
|
+
var VERSION = true ? "2.0.1" : "0.0.0-test";
|
|
178
178
|
|
|
179
179
|
// src/fireworks-provider.ts
|
|
180
180
|
var fireworksErrorSchema = import_v4.z.object({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/fireworks-image-model.ts","../src/fireworks-provider.ts","../src/version.ts"],"sourcesContent":["export type {\n FireworksEmbeddingModelId,\n FireworksEmbeddingProviderOptions,\n} from './fireworks-embedding-options';\nexport { FireworksImageModel } from './fireworks-image-model';\nexport type { FireworksImageModelId } from './fireworks-image-options';\nexport { fireworks, createFireworks } from './fireworks-provider';\nexport type {\n FireworksProvider,\n FireworksProviderSettings,\n FireworksErrorData,\n} from './fireworks-provider';\nexport { VERSION } from './version';\n","import { ImageModelV3, SharedV3Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createBinaryResponseHandler,\n createStatusCodeErrorResponseHandler,\n FetchFunction,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { FireworksImageModelId } from './fireworks-image-options';\n\ninterface FireworksImageModelBackendConfig {\n urlFormat: 'workflows' | 'workflows_edit' | 'image_generation';\n supportsSize?: boolean;\n supportsEditing?: boolean;\n}\n\nconst modelToBackendConfig: Partial<\n Record<FireworksImageModelId, FireworksImageModelBackendConfig>\n> = {\n 'accounts/fireworks/models/flux-1-dev-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-1-schnell-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-kontext-pro': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/flux-kontext-max': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/japanese-stable-diffusion-xl': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/SSD-1B': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n};\n\nfunction getUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n hasInputImage: boolean,\n): string {\n const config = modelToBackendConfig[modelId];\n\n switch (config?.urlFormat) {\n case 'image_generation':\n return `${baseUrl}/image_generation/${modelId}`;\n case 'workflows_edit':\n // Kontext models: use base URL for editing (no suffix)\n return `${baseUrl}/workflows/${modelId}`;\n case 'workflows':\n default:\n // Standard FLUX models: use text_to_image for generation,\n // but if input_image provided, some models may support editing\n if (hasInputImage && config?.supportsEditing) {\n return `${baseUrl}/workflows/${modelId}`;\n }\n return `${baseUrl}/workflows/${modelId}/text_to_image`;\n }\n}\n\ninterface FireworksImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class FireworksImageModel implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxImagesPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: FireworksImageModelId,\n private config: FireworksImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n\n const backendConfig = modelToBackendConfig[this.modelId];\n if (!backendConfig?.supportsSize && size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Use supportsSize as a proxy for whether the model does not support\n // aspectRatio. This invariant holds for the current set of models.\n if (backendConfig?.supportsSize && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'This model does not support the `aspectRatio` option.',\n });\n }\n\n // Handle files for image editing\n const hasInputImage = files != null && files.length > 0;\n let inputImage: string | undefined;\n\n if (hasInputImage) {\n inputImage = convertImageModelFileToDataUri(files[0]);\n\n if (files.length > 1) {\n warnings.push({\n type: 'other',\n message:\n 'Fireworks only supports a single input image. Additional images are ignored.',\n });\n }\n }\n\n // Warn about mask - Fireworks Kontext models don't support explicit masks\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details:\n 'Fireworks Kontext models do not support explicit masks. Use the prompt to describe the areas to edit.',\n });\n }\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId, hasInputImage),\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n aspect_ratio: aspectRatio,\n seed,\n samples: n,\n ...(inputImage && { input_image: inputImage }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(providerOptions.fireworks ?? {}),\n },\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: [response],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n ImageModelV3,\n LanguageModelV3,\n ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { FireworksChatModelId } from './fireworks-chat-options';\nimport { FireworksCompletionModelId } from './fireworks-completion-options';\nimport { FireworksEmbeddingModelId } from './fireworks-embedding-options';\nimport { FireworksImageModel } from './fireworks-image-model';\nimport { FireworksImageModelId } from './fireworks-image-options';\nimport { VERSION } from './version';\n\nexport type FireworksErrorData = z.infer<typeof fireworksErrorSchema>;\n\nconst fireworksErrorSchema = z.object({\n error: z.string(),\n});\n\nconst fireworksErrorStructure: ProviderErrorStructure<FireworksErrorData> = {\n errorSchema: fireworksErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface FireworksProviderSettings {\n /**\nFireworks API key. Default value is taken from the `FIREWORKS_API_KEY`\nenvironment variable.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface FireworksProvider extends ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: FireworksCompletionModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a text embedding model for text generation.\n*/\n embeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\nCreates a model for image generation.\n*/\n image(modelId: FireworksImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n*/\n imageModel(modelId: FireworksImageModelId): ImageModelV3;\n}\n\nconst defaultBaseURL = 'https://api.fireworks.ai/inference/v1';\n\nexport function createFireworks(\n options: FireworksProviderSettings = {},\n): FireworksProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'FIREWORKS_API_KEY',\n description: 'Fireworks API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/fireworks/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `fireworks.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: FireworksChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n errorStructure: fireworksErrorStructure,\n });\n };\n\n const createCompletionModel = (modelId: FireworksCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n ...getCommonModelConfig('completion'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createEmbeddingModel = (modelId: FireworksEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(modelId, {\n ...getCommonModelConfig('embedding'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createImageModel = (modelId: FireworksImageModelId) =>\n new FireworksImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL ?? defaultBaseURL,\n });\n\n const provider = (modelId: FireworksChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n return provider;\n}\n\nexport const fireworks = createFireworks();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,4BAOO;AASP,IAAM,uBAEF;AAAA,EACF,4CAA4C;AAAA,IAC1C,WAAW;AAAA,EACb;AAAA,EACA,gDAAgD;AAAA,IAC9C,WAAW;AAAA,EACb;AAAA,EACA,8CAA8C;AAAA,IAC5C,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB;AAAA,EACA,8CAA8C;AAAA,IAC5C,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB;AAAA,EACA,8DAA8D;AAAA,IAC5D,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,0DAA0D;AAAA,IACxD,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,4DAA4D;AAAA,IAC1D,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,2DAA2D;AAAA,IACzD,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,oCAAoC;AAAA,IAClC,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AACF;AAEA,SAAS,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AqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":["import_provider_utils"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/fireworks-image-model.ts","../src/fireworks-provider.ts","../src/version.ts"],"sourcesContent":["export type {\n FireworksEmbeddingModelId,\n FireworksEmbeddingProviderOptions,\n} from './fireworks-embedding-options';\nexport { FireworksImageModel } from './fireworks-image-model';\nexport type { FireworksImageModelId } from './fireworks-image-options';\nexport { fireworks, createFireworks } from './fireworks-provider';\nexport type {\n FireworksProvider,\n FireworksProviderSettings,\n FireworksErrorData,\n} from './fireworks-provider';\nexport { VERSION } from './version';\n","import { ImageModelV3, SharedV3Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createBinaryResponseHandler,\n createStatusCodeErrorResponseHandler,\n FetchFunction,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { FireworksImageModelId } from './fireworks-image-options';\n\ninterface FireworksImageModelBackendConfig {\n urlFormat: 'workflows' | 'workflows_edit' | 'image_generation';\n supportsSize?: boolean;\n supportsEditing?: boolean;\n}\n\nconst modelToBackendConfig: Partial<\n Record<FireworksImageModelId, FireworksImageModelBackendConfig>\n> = {\n 'accounts/fireworks/models/flux-1-dev-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-1-schnell-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-kontext-pro': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/flux-kontext-max': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/japanese-stable-diffusion-xl': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/SSD-1B': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n};\n\nfunction getUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n hasInputImage: boolean,\n): string {\n const config = modelToBackendConfig[modelId];\n\n switch (config?.urlFormat) {\n case 'image_generation':\n return `${baseUrl}/image_generation/${modelId}`;\n case 'workflows_edit':\n // Kontext models: use base URL for editing (no suffix)\n return `${baseUrl}/workflows/${modelId}`;\n case 'workflows':\n default:\n // Standard FLUX models: use text_to_image for generation,\n // but if input_image provided, some models may support editing\n if (hasInputImage && config?.supportsEditing) {\n return `${baseUrl}/workflows/${modelId}`;\n }\n return `${baseUrl}/workflows/${modelId}/text_to_image`;\n }\n}\n\ninterface FireworksImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class FireworksImageModel implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxImagesPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: FireworksImageModelId,\n private config: FireworksImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n\n const backendConfig = modelToBackendConfig[this.modelId];\n if (!backendConfig?.supportsSize && size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Use supportsSize as a proxy for whether the model does not support\n // aspectRatio. This invariant holds for the current set of models.\n if (backendConfig?.supportsSize && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'This model does not support the `aspectRatio` option.',\n });\n }\n\n // Handle files for image editing\n const hasInputImage = files != null && files.length > 0;\n let inputImage: string | undefined;\n\n if (hasInputImage) {\n inputImage = convertImageModelFileToDataUri(files[0]);\n\n if (files.length > 1) {\n warnings.push({\n type: 'other',\n message:\n 'Fireworks only supports a single input image. Additional images are ignored.',\n });\n }\n }\n\n // Warn about mask - Fireworks Kontext models don't support explicit masks\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details:\n 'Fireworks Kontext models do not support explicit masks. Use the prompt to describe the areas to edit.',\n });\n }\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId, hasInputImage),\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n aspect_ratio: aspectRatio,\n seed,\n samples: n,\n ...(inputImage && { input_image: inputImage }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(providerOptions.fireworks ?? {}),\n },\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: [response],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n ImageModelV3,\n LanguageModelV3,\n ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { FireworksChatModelId } from './fireworks-chat-options';\nimport { FireworksCompletionModelId } from './fireworks-completion-options';\nimport { FireworksEmbeddingModelId } from './fireworks-embedding-options';\nimport { FireworksImageModel } from './fireworks-image-model';\nimport { FireworksImageModelId } from './fireworks-image-options';\nimport { VERSION } from './version';\n\nexport type FireworksErrorData = z.infer<typeof fireworksErrorSchema>;\n\nconst fireworksErrorSchema = z.object({\n error: z.string(),\n});\n\nconst fireworksErrorStructure: ProviderErrorStructure<FireworksErrorData> = {\n errorSchema: fireworksErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface FireworksProviderSettings {\n /**\nFireworks API key. Default value is taken from the `FIREWORKS_API_KEY`\nenvironment variable.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface FireworksProvider extends ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: FireworksCompletionModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a text embedding model for text generation.\n*/\n embeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\nCreates a model for image generation.\n*/\n image(modelId: FireworksImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n*/\n imageModel(modelId: FireworksImageModelId): ImageModelV3;\n}\n\nconst defaultBaseURL = 'https://api.fireworks.ai/inference/v1';\n\nexport function createFireworks(\n options: FireworksProviderSettings = {},\n): FireworksProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'FIREWORKS_API_KEY',\n description: 'Fireworks API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/fireworks/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `fireworks.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: FireworksChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n errorStructure: fireworksErrorStructure,\n });\n };\n\n const createCompletionModel = (modelId: FireworksCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n ...getCommonModelConfig('completion'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createEmbeddingModel = (modelId: FireworksEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(modelId, {\n ...getCommonModelConfig('embedding'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createImageModel = (modelId: FireworksImageModelId) =>\n new FireworksImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL ?? defaultBaseURL,\n });\n\n const provider = (modelId: FireworksChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n return provider;\n}\n\nexport const fireworks = createFireworks();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\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,OAAO,GAAG,IAAI;AAAA,IACpC,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAAkC;AACzD,WAAO,IAAI,2DAAkC,SAAS;AAAA,MACpD,GAAG,qBAAqB,MAAM;AAAA,MAC9B,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AAEA,QAAM,wBAAwB,CAAC,YAC7B,IAAI,iEAAwC,SAAS;AAAA,IACnD,GAAG,qBAAqB,YAAY;AAAA,IACpC,gBAAgB;AAAA,EAClB,CAAC;AAEH,QAAM,uBAAuB,CAAC,YAC5B,IAAI,wDAA+B,SAAS;AAAA,IAC1C,GAAG,qBAAqB,WAAW;AAAA,IACnC,gBAAgB;AAAA,EAClB,CAAC;AAEH,QAAM,mBAAmB,CAAC,YACxB,IAAI,oBAAoB,SAAS;AAAA,IAC/B,GAAG,qBAAqB,OAAO;AAAA,IAC/B,SAAS,4BAAW;AAAA,EACtB,CAAC;AAEH,QAAM,WAAW,CAAC,YAAkC,gBAAgB,OAAO;AAE3E,WAAS,uBAAuB;AAChC,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":["import_provider_utils"]}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fireworks-image-model.ts","../src/fireworks-provider.ts","../src/version.ts"],"sourcesContent":["import { ImageModelV3, SharedV3Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createBinaryResponseHandler,\n createStatusCodeErrorResponseHandler,\n FetchFunction,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { FireworksImageModelId } from './fireworks-image-options';\n\ninterface FireworksImageModelBackendConfig {\n urlFormat: 'workflows' | 'workflows_edit' | 'image_generation';\n supportsSize?: boolean;\n supportsEditing?: boolean;\n}\n\nconst modelToBackendConfig: Partial<\n Record<FireworksImageModelId, FireworksImageModelBackendConfig>\n> = {\n 'accounts/fireworks/models/flux-1-dev-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-1-schnell-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-kontext-pro': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/flux-kontext-max': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/japanese-stable-diffusion-xl': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/SSD-1B': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n};\n\nfunction getUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n hasInputImage: boolean,\n): string {\n const config = modelToBackendConfig[modelId];\n\n switch (config?.urlFormat) {\n case 'image_generation':\n return `${baseUrl}/image_generation/${modelId}`;\n case 'workflows_edit':\n // Kontext models: use base URL for editing (no suffix)\n return `${baseUrl}/workflows/${modelId}`;\n case 'workflows':\n default:\n // Standard FLUX models: use text_to_image for generation,\n // but if input_image provided, some models may support editing\n if (hasInputImage && config?.supportsEditing) {\n return `${baseUrl}/workflows/${modelId}`;\n }\n return `${baseUrl}/workflows/${modelId}/text_to_image`;\n }\n}\n\ninterface FireworksImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class FireworksImageModel implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxImagesPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: FireworksImageModelId,\n private config: FireworksImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n\n const backendConfig = modelToBackendConfig[this.modelId];\n if (!backendConfig?.supportsSize && size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Use supportsSize as a proxy for whether the model does not support\n // aspectRatio. This invariant holds for the current set of models.\n if (backendConfig?.supportsSize && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'This model does not support the `aspectRatio` option.',\n });\n }\n\n // Handle files for image editing\n const hasInputImage = files != null && files.length > 0;\n let inputImage: string | undefined;\n\n if (hasInputImage) {\n inputImage = convertImageModelFileToDataUri(files[0]);\n\n if (files.length > 1) {\n warnings.push({\n type: 'other',\n message:\n 'Fireworks only supports a single input image. Additional images are ignored.',\n });\n }\n }\n\n // Warn about mask - Fireworks Kontext models don't support explicit masks\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details:\n 'Fireworks Kontext models do not support explicit masks. Use the prompt to describe the areas to edit.',\n });\n }\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId, hasInputImage),\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n aspect_ratio: aspectRatio,\n seed,\n samples: n,\n ...(inputImage && { input_image: inputImage }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(providerOptions.fireworks ?? {}),\n },\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: [response],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n ImageModelV3,\n LanguageModelV3,\n ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { FireworksChatModelId } from './fireworks-chat-options';\nimport { FireworksCompletionModelId } from './fireworks-completion-options';\nimport { FireworksEmbeddingModelId } from './fireworks-embedding-options';\nimport { FireworksImageModel } from './fireworks-image-model';\nimport { FireworksImageModelId } from './fireworks-image-options';\nimport { VERSION } from './version';\n\nexport type FireworksErrorData = z.infer<typeof fireworksErrorSchema>;\n\nconst fireworksErrorSchema = z.object({\n error: z.string(),\n});\n\nconst fireworksErrorStructure: ProviderErrorStructure<FireworksErrorData> = {\n errorSchema: fireworksErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface FireworksProviderSettings {\n /**\nFireworks API key. Default value is taken from the `FIREWORKS_API_KEY`\nenvironment variable.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface FireworksProvider extends ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: FireworksCompletionModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a text embedding model for text generation.\n*/\n embeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\nCreates a model for image generation.\n*/\n image(modelId: FireworksImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n*/\n imageModel(modelId: FireworksImageModelId): ImageModelV3;\n}\n\nconst defaultBaseURL = 'https://api.fireworks.ai/inference/v1';\n\nexport function createFireworks(\n options: FireworksProviderSettings = {},\n): FireworksProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'FIREWORKS_API_KEY',\n description: 'Fireworks API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/fireworks/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `fireworks.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: FireworksChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n errorStructure: fireworksErrorStructure,\n });\n };\n\n const createCompletionModel = (modelId: FireworksCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n ...getCommonModelConfig('completion'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createEmbeddingModel = (modelId: FireworksEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(modelId, {\n ...getCommonModelConfig('embedding'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createImageModel = (modelId: FireworksImageModelId) =>\n new FireworksImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL ?? defaultBaseURL,\n });\n\n const provider = (modelId: FireworksChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n return provider;\n}\n\nexport const fireworks = createFireworks();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AASP,IAAM,uBAEF;AAAA,EACF,4CAA4C;AAAA,IAC1C,WAAW;AAAA,EACb;AAAA,EACA,gDAAgD;AAAA,IAC9C,WAAW;AAAA,EACb;AAAA,EACA,8CAA8C;AAAA,IAC5C,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB;AAAA,EACA,8CAA8C;AAAA,IAC5C,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB;AAAA,EACA,8DAA8D;AAAA,IAC5D,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,0DAA0D;AAAA,IACxD,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,4DAA4D;AAAA,IAC1D,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,2DAA2D;AAAA,IACzD,WAAW;AAAA,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B,CAAC;AAEH,QAAM,WAAW,CAAC,YAAkC,gBAAgB,OAAO;AAE3E,WAAS,uBAAuB;AAChC,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/fireworks-image-model.ts","../src/fireworks-provider.ts","../src/version.ts"],"sourcesContent":["import { ImageModelV3, SharedV3Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createBinaryResponseHandler,\n createStatusCodeErrorResponseHandler,\n FetchFunction,\n postJsonToApi,\n} from '@ai-sdk/provider-utils';\nimport { FireworksImageModelId } from './fireworks-image-options';\n\ninterface FireworksImageModelBackendConfig {\n urlFormat: 'workflows' | 'workflows_edit' | 'image_generation';\n supportsSize?: boolean;\n supportsEditing?: boolean;\n}\n\nconst modelToBackendConfig: Partial<\n Record<FireworksImageModelId, FireworksImageModelBackendConfig>\n> = {\n 'accounts/fireworks/models/flux-1-dev-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-1-schnell-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-kontext-pro': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/flux-kontext-max': {\n urlFormat: 'workflows_edit',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/japanese-stable-diffusion-xl': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/SSD-1B': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n};\n\nfunction getUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n hasInputImage: boolean,\n): string {\n const config = modelToBackendConfig[modelId];\n\n switch (config?.urlFormat) {\n case 'image_generation':\n return `${baseUrl}/image_generation/${modelId}`;\n case 'workflows_edit':\n // Kontext models: use base URL for editing (no suffix)\n return `${baseUrl}/workflows/${modelId}`;\n case 'workflows':\n default:\n // Standard FLUX models: use text_to_image for generation,\n // but if input_image provided, some models may support editing\n if (hasInputImage && config?.supportsEditing) {\n return `${baseUrl}/workflows/${modelId}`;\n }\n return `${baseUrl}/workflows/${modelId}/text_to_image`;\n }\n}\n\ninterface FireworksImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class FireworksImageModel implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxImagesPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: FireworksImageModelId,\n private config: FireworksImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV3['doGenerate']>>\n > {\n const warnings: Array<SharedV3Warning> = [];\n\n const backendConfig = modelToBackendConfig[this.modelId];\n if (!backendConfig?.supportsSize && size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Use supportsSize as a proxy for whether the model does not support\n // aspectRatio. This invariant holds for the current set of models.\n if (backendConfig?.supportsSize && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'This model does not support the `aspectRatio` option.',\n });\n }\n\n // Handle files for image editing\n const hasInputImage = files != null && files.length > 0;\n let inputImage: string | undefined;\n\n if (hasInputImage) {\n inputImage = convertImageModelFileToDataUri(files[0]);\n\n if (files.length > 1) {\n warnings.push({\n type: 'other',\n message:\n 'Fireworks only supports a single input image. Additional images are ignored.',\n });\n }\n }\n\n // Warn about mask - Fireworks Kontext models don't support explicit masks\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details:\n 'Fireworks Kontext models do not support explicit masks. Use the prompt to describe the areas to edit.',\n });\n }\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { value: response, responseHeaders } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId, hasInputImage),\n headers: combineHeaders(this.config.headers(), headers),\n body: {\n prompt,\n aspect_ratio: aspectRatio,\n seed,\n samples: n,\n ...(inputImage && { input_image: inputImage }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...(providerOptions.fireworks ?? {}),\n },\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: [response],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n}\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n EmbeddingModelV3,\n ImageModelV3,\n LanguageModelV3,\n ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { FireworksChatModelId } from './fireworks-chat-options';\nimport { FireworksCompletionModelId } from './fireworks-completion-options';\nimport { FireworksEmbeddingModelId } from './fireworks-embedding-options';\nimport { FireworksImageModel } from './fireworks-image-model';\nimport { FireworksImageModelId } from './fireworks-image-options';\nimport { VERSION } from './version';\n\nexport type FireworksErrorData = z.infer<typeof fireworksErrorSchema>;\n\nconst fireworksErrorSchema = z.object({\n error: z.string(),\n});\n\nconst fireworksErrorStructure: ProviderErrorStructure<FireworksErrorData> = {\n errorSchema: fireworksErrorSchema,\n errorToMessage: data => data.error,\n};\n\nexport interface FireworksProviderSettings {\n /**\nFireworks API key. Default value is taken from the `FIREWORKS_API_KEY`\nenvironment variable.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface FireworksProvider extends ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n chatModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a completion model for text generation.\n*/\n completionModel(modelId: FireworksCompletionModelId): LanguageModelV3;\n\n /**\nCreates a chat model for text generation.\n*/\n languageModel(modelId: FireworksChatModelId): LanguageModelV3;\n\n /**\nCreates a text embedding model for text generation.\n*/\n embeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV3;\n\n /**\nCreates a model for image generation.\n*/\n image(modelId: FireworksImageModelId): ImageModelV3;\n\n /**\nCreates a model for image generation.\n*/\n imageModel(modelId: FireworksImageModelId): ImageModelV3;\n}\n\nconst defaultBaseURL = 'https://api.fireworks.ai/inference/v1';\n\nexport function createFireworks(\n options: FireworksProviderSettings = {},\n): FireworksProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'FIREWORKS_API_KEY',\n description: 'Fireworks API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/fireworks/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `fireworks.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: FireworksChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n errorStructure: fireworksErrorStructure,\n });\n };\n\n const createCompletionModel = (modelId: FireworksCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n ...getCommonModelConfig('completion'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createEmbeddingModel = (modelId: FireworksEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(modelId, {\n ...getCommonModelConfig('embedding'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createImageModel = (modelId: FireworksImageModelId) =>\n new FireworksImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL ?? defaultBaseURL,\n });\n\n const provider = (modelId: FireworksChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v3' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n return provider;\n}\n\nexport const fireworks = createFireworks();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AACA;AAAA,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AAAA,IACT,OAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,kBAAkB,CAAC,YAAkC;AACzD,WAAO,IAAI,kCAAkC,SAAS;AAAA,MACpD,GAAG,qBAAqB,MAAM;AAAA,MAC9B,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AAEA,QAAM,wBAAwB,CAAC,YAC7B,IAAI,wCAAwC,SAAS;AAAA,IACnD,GAAG,qBAAqB,YAAY;AAAA,IACpC,gBAAgB;AAAA,EAClB,CAAC;AAEH,QAAM,uBAAuB,CAAC,YAC5B,IAAI,+BAA+B,SAAS;AAAA,IAC1C,GAAG,qBAAqB,WAAW;AAAA,IACnC,gBAAgB;AAAA,EAClB,CAAC;AAEH,QAAM,mBAAmB,CAAC,YACxB,IAAI,oBAAoB,SAAS;AAAA,IAC/B,GAAG,qBAAqB,OAAO;AAAA,IAC/B,SAAS,4BAAW;AAAA,EACtB,CAAC;AAEH,QAAM,WAAW,CAAC,YAAkC,gBAAgB,OAAO;AAE3E,WAAS,uBAAuB;AAChC,WAAS,kBAAkB;AAC3B,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,SAAO;AACT;AAEO,IAAM,YAAY,gBAAgB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/fireworks",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
24
|
-
"@ai-sdk/provider": "3.0.0
|
|
25
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
23
|
+
"@ai-sdk/openai-compatible": "2.0.1",
|
|
24
|
+
"@ai-sdk/provider": "3.0.0",
|
|
25
|
+
"@ai-sdk/provider-utils": "4.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "20.17.24",
|
|
29
29
|
"tsup": "^8",
|
|
30
30
|
"typescript": "5.8.3",
|
|
31
31
|
"zod": "3.25.76",
|
|
32
|
-
"@ai-sdk/test-server": "1.0.0
|
|
32
|
+
"@ai-sdk/test-server": "1.0.0",
|
|
33
33
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|