@ai-sdk/fireworks 3.0.0-beta.3 → 3.0.0-beta.30
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 +252 -8
- package/README.md +2 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +85 -77
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/fireworks-image-model.ts +19 -2
- package/src/fireworks-provider.ts +15 -1
- package/dist/index.d.mts +0 -131
- package/dist/index.mjs +0 -382
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,249 @@
|
|
|
1
1
|
# @ai-sdk/fireworks
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [eea8d98]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
9
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.30
|
|
10
|
+
|
|
11
|
+
## 3.0.0-beta.29
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [f807e45]
|
|
16
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
17
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.29
|
|
18
|
+
|
|
19
|
+
## 3.0.0-beta.28
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [350ea38]
|
|
24
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
25
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.28
|
|
26
|
+
|
|
27
|
+
## 3.0.0-beta.27
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [083947b]
|
|
32
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
33
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.27
|
|
34
|
+
|
|
35
|
+
## 3.0.0-beta.26
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [add1126]
|
|
40
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
41
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.26
|
|
42
|
+
|
|
43
|
+
## 3.0.0-beta.25
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
48
|
+
|
|
49
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
50
|
+
|
|
51
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
52
|
+
|
|
53
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [b3976a2]
|
|
56
|
+
- Updated dependencies [ff5eba1]
|
|
57
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
58
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.25
|
|
59
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
60
|
+
|
|
61
|
+
## 3.0.0-beta.24
|
|
62
|
+
|
|
63
|
+
### Major Changes
|
|
64
|
+
|
|
65
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [ef992f8]
|
|
70
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.24
|
|
71
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
72
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
73
|
+
|
|
74
|
+
## 3.0.0-beta.23
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
79
|
+
- Updated dependencies [90e2d8a]
|
|
80
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.23
|
|
81
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
82
|
+
|
|
83
|
+
## 3.0.0-beta.22
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [3ae1786]
|
|
88
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
89
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.22
|
|
90
|
+
|
|
91
|
+
## 3.0.0-beta.21
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [176466a]
|
|
96
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
97
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.21
|
|
98
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
99
|
+
|
|
100
|
+
## 3.0.0-beta.20
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Updated dependencies [e311194]
|
|
105
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
106
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.20
|
|
107
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
108
|
+
|
|
109
|
+
## 3.0.0-beta.19
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- Updated dependencies [34bd95d]
|
|
114
|
+
- Updated dependencies [008271d]
|
|
115
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
116
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
117
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
118
|
+
|
|
119
|
+
## 3.0.0-beta.18
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [b0c2869]
|
|
124
|
+
- Updated dependencies [7e26e81]
|
|
125
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
126
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
127
|
+
|
|
128
|
+
## 3.0.0-beta.17
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Updated dependencies [816ff67]
|
|
133
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
134
|
+
|
|
135
|
+
## 3.0.0-beta.16
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [46d1149]
|
|
140
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
141
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
142
|
+
|
|
143
|
+
## 3.0.0-beta.15
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- Updated dependencies [6fd51c0]
|
|
148
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
149
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
150
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
151
|
+
|
|
152
|
+
## 3.0.0-beta.14
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- Updated dependencies [c29a26f]
|
|
157
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
158
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
159
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
160
|
+
|
|
161
|
+
## 3.0.0-beta.13
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
166
|
+
- Updated dependencies [38fc777]
|
|
167
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
168
|
+
|
|
169
|
+
## 3.0.0-beta.12
|
|
170
|
+
|
|
171
|
+
### Patch Changes
|
|
172
|
+
|
|
173
|
+
- Updated dependencies [2e17091]
|
|
174
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
175
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
176
|
+
|
|
177
|
+
## 3.0.0-beta.11
|
|
178
|
+
|
|
179
|
+
### Patch Changes
|
|
180
|
+
|
|
181
|
+
- Updated dependencies [986c6fd]
|
|
182
|
+
- Updated dependencies [493295c]
|
|
183
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
184
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
185
|
+
|
|
186
|
+
## 3.0.0-beta.10
|
|
187
|
+
|
|
188
|
+
### Patch Changes
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [1f509d4]
|
|
191
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
192
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
193
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
194
|
+
|
|
195
|
+
## 3.0.0-beta.9
|
|
196
|
+
|
|
197
|
+
### Patch Changes
|
|
198
|
+
|
|
199
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
200
|
+
- Updated dependencies [74d520f]
|
|
201
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
202
|
+
|
|
203
|
+
## 3.0.0-beta.8
|
|
204
|
+
|
|
205
|
+
### Patch Changes
|
|
206
|
+
|
|
207
|
+
- Updated dependencies [3887c70]
|
|
208
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
209
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
210
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.8
|
|
211
|
+
|
|
212
|
+
## 3.0.0-beta.7
|
|
213
|
+
|
|
214
|
+
### Patch Changes
|
|
215
|
+
|
|
216
|
+
- Updated dependencies [776b617]
|
|
217
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
218
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
219
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.7
|
|
220
|
+
|
|
221
|
+
## 3.0.0-beta.6
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- Updated dependencies [61753c3]
|
|
226
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
227
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.6
|
|
228
|
+
|
|
229
|
+
## 3.0.0-beta.5
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- Updated dependencies [f7d4f01]
|
|
234
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
235
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
236
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.5
|
|
237
|
+
|
|
238
|
+
## 3.0.0-beta.4
|
|
239
|
+
|
|
240
|
+
### Patch Changes
|
|
241
|
+
|
|
242
|
+
- Updated dependencies [5c2a5a2]
|
|
243
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
244
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.4
|
|
245
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
246
|
+
|
|
3
247
|
## 3.0.0-beta.3
|
|
4
248
|
|
|
5
249
|
### Patch Changes
|
|
@@ -362,13 +606,13 @@
|
|
|
362
606
|
Before
|
|
363
607
|
|
|
364
608
|
```ts
|
|
365
|
-
model.textEmbeddingModel(
|
|
609
|
+
model.textEmbeddingModel("my-model-id");
|
|
366
610
|
```
|
|
367
611
|
|
|
368
612
|
After
|
|
369
613
|
|
|
370
614
|
```ts
|
|
371
|
-
model.embeddingModel(
|
|
615
|
+
model.embeddingModel("my-model-id");
|
|
372
616
|
```
|
|
373
617
|
|
|
374
618
|
- 95f65c2: chore: use import \* from zod/v4
|
|
@@ -596,13 +840,13 @@
|
|
|
596
840
|
Before
|
|
597
841
|
|
|
598
842
|
```ts
|
|
599
|
-
model.textEmbeddingModel(
|
|
843
|
+
model.textEmbeddingModel("my-model-id");
|
|
600
844
|
```
|
|
601
845
|
|
|
602
846
|
After
|
|
603
847
|
|
|
604
848
|
```ts
|
|
605
|
-
model.embeddingModel(
|
|
849
|
+
model.embeddingModel("my-model-id");
|
|
606
850
|
```
|
|
607
851
|
|
|
608
852
|
- Updated dependencies [8d9e8ad]
|
|
@@ -1090,7 +1334,7 @@
|
|
|
1090
1334
|
|
|
1091
1335
|
```js
|
|
1092
1336
|
await generateImage({
|
|
1093
|
-
model: luma.image(
|
|
1337
|
+
model: luma.image("photon-flash-1", {
|
|
1094
1338
|
maxImagesPerCall: 5,
|
|
1095
1339
|
pollIntervalMillis: 500,
|
|
1096
1340
|
}),
|
|
@@ -1103,7 +1347,7 @@
|
|
|
1103
1347
|
|
|
1104
1348
|
```js
|
|
1105
1349
|
await generateImage({
|
|
1106
|
-
model: luma.image(
|
|
1350
|
+
model: luma.image("photon-flash-1"),
|
|
1107
1351
|
prompt,
|
|
1108
1352
|
n: 10,
|
|
1109
1353
|
maxImagesPerCall: 5,
|
|
@@ -1391,7 +1635,7 @@
|
|
|
1391
1635
|
|
|
1392
1636
|
```js
|
|
1393
1637
|
await generateImage({
|
|
1394
|
-
model: luma.image(
|
|
1638
|
+
model: luma.image("photon-flash-1", {
|
|
1395
1639
|
maxImagesPerCall: 5,
|
|
1396
1640
|
pollIntervalMillis: 500,
|
|
1397
1641
|
}),
|
|
@@ -1404,7 +1648,7 @@
|
|
|
1404
1648
|
|
|
1405
1649
|
```js
|
|
1406
1650
|
await generateImage({
|
|
1407
|
-
model: luma.image(
|
|
1651
|
+
model: luma.image("photon-flash-1"),
|
|
1408
1652
|
prompt,
|
|
1409
1653
|
n: 10,
|
|
1410
1654
|
maxImagesPerCall: 5,
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The **[Fireworks provider](https://ai-sdk.dev/providers/ai-sdk-providers/fireworks)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model and image model support for the [Fireworks](https://fireworks.ai) platform.
|
|
4
4
|
|
|
5
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Fireworks (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
6
|
+
|
|
5
7
|
## Setup
|
|
6
8
|
|
|
7
9
|
The Fireworks provider is available in the `@ai-sdk/fireworks` module. You can install it with
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
3
|
import { ImageModelV4, ProviderV4, LanguageModelV4, EmbeddingModelV4 } from '@ai-sdk/provider';
|
|
3
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
5
|
|
|
5
6
|
type FireworksChatModelId = 'accounts/fireworks/models/deepseek-v3' | 'accounts/fireworks/models/llama-v3p3-70b-instruct' | 'accounts/fireworks/models/llama-v3p2-3b-instruct' | 'accounts/fireworks/models/llama-v3p1-405b-instruct' | 'accounts/fireworks/models/llama-v3p1-8b-instruct' | 'accounts/fireworks/models/mixtral-8x7b-instruct' | 'accounts/fireworks/models/mixtral-8x22b-instruct' | 'accounts/fireworks/models/mixtral-8x7b-instruct-hf' | 'accounts/fireworks/models/qwen2p5-coder-32b-instruct' | 'accounts/fireworks/models/qwen2p5-72b-instruct' | 'accounts/fireworks/models/qwen-qwq-32b-preview' | 'accounts/fireworks/models/qwen2-vl-72b-instruct' | 'accounts/fireworks/models/llama-v3p2-11b-vision-instruct' | 'accounts/fireworks/models/qwq-32b' | 'accounts/fireworks/models/yi-large' | 'accounts/fireworks/models/kimi-k2-instruct' | 'accounts/fireworks/models/kimi-k2-thinking' | 'accounts/fireworks/models/kimi-k2p5' | 'accounts/fireworks/models/minimax-m2' | (string & {});
|
|
6
7
|
declare const fireworksLanguageModelOptions: z.ZodObject<{
|
|
@@ -28,7 +29,7 @@ type FireworksImageModelId = 'accounts/fireworks/models/flux-1-dev-fp8' | 'accou
|
|
|
28
29
|
interface FireworksImageModelConfig {
|
|
29
30
|
provider: string;
|
|
30
31
|
baseURL: string;
|
|
31
|
-
headers
|
|
32
|
+
headers?: () => Record<string, string>;
|
|
32
33
|
fetch?: FetchFunction;
|
|
33
34
|
/**
|
|
34
35
|
* Poll interval in milliseconds between status checks for async models.
|
|
@@ -50,6 +51,14 @@ declare class FireworksImageModel implements ImageModelV4 {
|
|
|
50
51
|
readonly specificationVersion = "v4";
|
|
51
52
|
readonly maxImagesPerCall = 1;
|
|
52
53
|
get provider(): string;
|
|
54
|
+
static [WORKFLOW_SERIALIZE](model: FireworksImageModel): {
|
|
55
|
+
modelId: string;
|
|
56
|
+
config: _ai_sdk_provider.JSONObject;
|
|
57
|
+
};
|
|
58
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
59
|
+
modelId: FireworksImageModelId;
|
|
60
|
+
config: FireworksImageModelConfig;
|
|
61
|
+
}): FireworksImageModel;
|
|
53
62
|
constructor(modelId: FireworksImageModelId, config: FireworksImageModelConfig);
|
|
54
63
|
doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, files, mask, }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
|
|
55
64
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
FireworksImageModel: () => FireworksImageModel,
|
|
24
|
-
VERSION: () => VERSION,
|
|
25
|
-
createFireworks: () => createFireworks,
|
|
26
|
-
fireworks: () => fireworks
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
1
|
// src/fireworks-image-model.ts
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
combineHeaders,
|
|
4
|
+
convertImageModelFileToDataUri,
|
|
5
|
+
createBinaryResponseHandler,
|
|
6
|
+
createJsonResponseHandler,
|
|
7
|
+
createStatusCodeErrorResponseHandler,
|
|
8
|
+
delay,
|
|
9
|
+
getFromApi,
|
|
10
|
+
postJsonToApi,
|
|
11
|
+
serializeModelOptions,
|
|
12
|
+
WORKFLOW_SERIALIZE,
|
|
13
|
+
WORKFLOW_DESERIALIZE
|
|
14
|
+
} from "@ai-sdk/provider-utils";
|
|
32
15
|
|
|
33
16
|
// src/fireworks-image-api.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var asyncSubmitResponseSchema =
|
|
37
|
-
() =>
|
|
38
|
-
|
|
39
|
-
request_id:
|
|
17
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
18
|
+
import { z } from "zod/v4";
|
|
19
|
+
var asyncSubmitResponseSchema = lazySchema(
|
|
20
|
+
() => zodSchema(
|
|
21
|
+
z.object({
|
|
22
|
+
request_id: z.string()
|
|
40
23
|
})
|
|
41
24
|
)
|
|
42
25
|
);
|
|
43
|
-
var asyncPollResponseSchema =
|
|
44
|
-
() =>
|
|
45
|
-
|
|
46
|
-
id:
|
|
47
|
-
status:
|
|
48
|
-
result:
|
|
49
|
-
sample:
|
|
26
|
+
var asyncPollResponseSchema = lazySchema(
|
|
27
|
+
() => zodSchema(
|
|
28
|
+
z.object({
|
|
29
|
+
id: z.string(),
|
|
30
|
+
status: z.string(),
|
|
31
|
+
result: z.object({
|
|
32
|
+
sample: z.string().optional()
|
|
50
33
|
}).nullable()
|
|
51
34
|
})
|
|
52
35
|
)
|
|
@@ -106,7 +89,7 @@ function getUrlForModel(baseUrl, modelId) {
|
|
|
106
89
|
function getPollUrlForModel(baseUrl, modelId) {
|
|
107
90
|
return `${baseUrl}/workflows/${modelId}/get_result`;
|
|
108
91
|
}
|
|
109
|
-
var FireworksImageModel = class {
|
|
92
|
+
var FireworksImageModel = class _FireworksImageModel {
|
|
110
93
|
constructor(modelId, config) {
|
|
111
94
|
this.modelId = modelId;
|
|
112
95
|
this.config = config;
|
|
@@ -116,6 +99,15 @@ var FireworksImageModel = class {
|
|
|
116
99
|
get provider() {
|
|
117
100
|
return this.config.provider;
|
|
118
101
|
}
|
|
102
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
103
|
+
return serializeModelOptions({
|
|
104
|
+
modelId: model.modelId,
|
|
105
|
+
config: model.config
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
109
|
+
return new _FireworksImageModel(options.modelId, options.config);
|
|
110
|
+
}
|
|
119
111
|
async doGenerate({
|
|
120
112
|
prompt,
|
|
121
113
|
n,
|
|
@@ -128,7 +120,7 @@ var FireworksImageModel = class {
|
|
|
128
120
|
files,
|
|
129
121
|
mask
|
|
130
122
|
}) {
|
|
131
|
-
var _a, _b, _c, _d;
|
|
123
|
+
var _a, _b, _c, _d, _e, _f;
|
|
132
124
|
const warnings = [];
|
|
133
125
|
const backendConfig = modelToBackendConfig[this.modelId];
|
|
134
126
|
if (!(backendConfig == null ? void 0 : backendConfig.supportsSize) && size != null) {
|
|
@@ -148,7 +140,7 @@ var FireworksImageModel = class {
|
|
|
148
140
|
const hasInputImage = files != null && files.length > 0;
|
|
149
141
|
let inputImage;
|
|
150
142
|
if (hasInputImage) {
|
|
151
|
-
inputImage =
|
|
143
|
+
inputImage = convertImageModelFileToDataUri(files[0]);
|
|
152
144
|
if (files.length > 1) {
|
|
153
145
|
warnings.push({
|
|
154
146
|
type: "other",
|
|
@@ -165,7 +157,7 @@ var FireworksImageModel = class {
|
|
|
165
157
|
}
|
|
166
158
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
167
159
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
168
|
-
const combinedHeaders = (
|
|
160
|
+
const combinedHeaders = combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers);
|
|
169
161
|
const body = {
|
|
170
162
|
prompt,
|
|
171
163
|
aspect_ratio: aspectRatio,
|
|
@@ -173,7 +165,7 @@ var FireworksImageModel = class {
|
|
|
173
165
|
samples: n,
|
|
174
166
|
...inputImage && { input_image: inputImage },
|
|
175
167
|
...splitSize && { width: splitSize[0], height: splitSize[1] },
|
|
176
|
-
...(
|
|
168
|
+
...(_f = providerOptions.fireworks) != null ? _f : {}
|
|
177
169
|
};
|
|
178
170
|
if ((backendConfig == null ? void 0 : backendConfig.urlFormat) === "workflows_async") {
|
|
179
171
|
return this.doGenerateAsync({
|
|
@@ -184,12 +176,12 @@ var FireworksImageModel = class {
|
|
|
184
176
|
currentDate
|
|
185
177
|
});
|
|
186
178
|
}
|
|
187
|
-
const { value: response, responseHeaders } = await
|
|
179
|
+
const { value: response, responseHeaders } = await postJsonToApi({
|
|
188
180
|
url: getUrlForModel(this.config.baseURL, this.modelId),
|
|
189
181
|
headers: combinedHeaders,
|
|
190
182
|
body,
|
|
191
|
-
failedResponseHandler:
|
|
192
|
-
successfulResponseHandler:
|
|
183
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
184
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
193
185
|
abortSignal,
|
|
194
186
|
fetch: this.config.fetch
|
|
195
187
|
});
|
|
@@ -214,12 +206,12 @@ var FireworksImageModel = class {
|
|
|
214
206
|
warnings,
|
|
215
207
|
currentDate
|
|
216
208
|
}) {
|
|
217
|
-
const { value: submitResponse } = await
|
|
209
|
+
const { value: submitResponse } = await postJsonToApi({
|
|
218
210
|
url: getUrlForModel(this.config.baseURL, this.modelId),
|
|
219
211
|
headers,
|
|
220
212
|
body,
|
|
221
|
-
failedResponseHandler:
|
|
222
|
-
successfulResponseHandler:
|
|
213
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
214
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
223
215
|
asyncSubmitResponseSchema
|
|
224
216
|
),
|
|
225
217
|
abortSignal,
|
|
@@ -231,12 +223,12 @@ var FireworksImageModel = class {
|
|
|
231
223
|
headers,
|
|
232
224
|
abortSignal
|
|
233
225
|
});
|
|
234
|
-
const { value: imageBytes, responseHeaders } = await
|
|
226
|
+
const { value: imageBytes, responseHeaders } = await getFromApi({
|
|
235
227
|
url: imageUrl,
|
|
236
228
|
headers,
|
|
237
229
|
abortSignal,
|
|
238
|
-
failedResponseHandler:
|
|
239
|
-
successfulResponseHandler:
|
|
230
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
231
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
240
232
|
fetch: this.config.fetch
|
|
241
233
|
});
|
|
242
234
|
return {
|
|
@@ -265,12 +257,12 @@ var FireworksImageModel = class {
|
|
|
265
257
|
);
|
|
266
258
|
const pollUrl = getPollUrlForModel(this.config.baseURL, this.modelId);
|
|
267
259
|
for (let i = 0; i < maxPollAttempts; i++) {
|
|
268
|
-
const { value: pollResponse } = await
|
|
260
|
+
const { value: pollResponse } = await postJsonToApi({
|
|
269
261
|
url: pollUrl,
|
|
270
262
|
headers,
|
|
271
263
|
body: { id: requestId },
|
|
272
|
-
failedResponseHandler:
|
|
273
|
-
successfulResponseHandler:
|
|
264
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
265
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
274
266
|
asyncPollResponseSchema
|
|
275
267
|
),
|
|
276
268
|
abortSignal,
|
|
@@ -291,7 +283,7 @@ var FireworksImageModel = class {
|
|
|
291
283
|
`Fireworks image generation failed with status: ${status}`
|
|
292
284
|
);
|
|
293
285
|
}
|
|
294
|
-
await
|
|
286
|
+
await delay(pollIntervalMillis);
|
|
295
287
|
}
|
|
296
288
|
throw new Error(
|
|
297
289
|
`Fireworks image generation timed out after ${pollTimeoutMillis}ms`
|
|
@@ -300,16 +292,24 @@ var FireworksImageModel = class {
|
|
|
300
292
|
};
|
|
301
293
|
|
|
302
294
|
// src/fireworks-provider.ts
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
295
|
+
import {
|
|
296
|
+
OpenAICompatibleChatLanguageModel,
|
|
297
|
+
OpenAICompatibleCompletionLanguageModel,
|
|
298
|
+
OpenAICompatibleEmbeddingModel
|
|
299
|
+
} from "@ai-sdk/openai-compatible";
|
|
300
|
+
import {
|
|
301
|
+
loadApiKey,
|
|
302
|
+
withoutTrailingSlash,
|
|
303
|
+
withUserAgentSuffix
|
|
304
|
+
} from "@ai-sdk/provider-utils";
|
|
305
|
+
import { z as z2 } from "zod/v4";
|
|
306
306
|
|
|
307
307
|
// src/version.ts
|
|
308
|
-
var VERSION = true ? "3.0.0-beta.
|
|
308
|
+
var VERSION = true ? "3.0.0-beta.30" : "0.0.0-test";
|
|
309
309
|
|
|
310
310
|
// src/fireworks-provider.ts
|
|
311
|
-
var fireworksErrorSchema =
|
|
312
|
-
error:
|
|
311
|
+
var fireworksErrorSchema = z2.object({
|
|
312
|
+
error: z2.string()
|
|
313
313
|
});
|
|
314
314
|
var fireworksErrorStructure = {
|
|
315
315
|
errorSchema: fireworksErrorSchema,
|
|
@@ -318,10 +318,10 @@ var fireworksErrorStructure = {
|
|
|
318
318
|
var defaultBaseURL = "https://api.fireworks.ai/inference/v1";
|
|
319
319
|
function createFireworks(options = {}) {
|
|
320
320
|
var _a;
|
|
321
|
-
const baseURL =
|
|
322
|
-
const getHeaders = () =>
|
|
321
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
322
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
323
323
|
{
|
|
324
|
-
Authorization: `Bearer ${
|
|
324
|
+
Authorization: `Bearer ${loadApiKey({
|
|
325
325
|
apiKey: options.apiKey,
|
|
326
326
|
environmentVariableName: "FIREWORKS_API_KEY",
|
|
327
327
|
description: "Fireworks API key"
|
|
@@ -337,15 +337,24 @@ function createFireworks(options = {}) {
|
|
|
337
337
|
fetch: options.fetch
|
|
338
338
|
});
|
|
339
339
|
const createChatModel = (modelId) => {
|
|
340
|
-
return new
|
|
340
|
+
return new OpenAICompatibleChatLanguageModel(modelId, {
|
|
341
341
|
...getCommonModelConfig("chat"),
|
|
342
342
|
errorStructure: fireworksErrorStructure,
|
|
343
343
|
transformRequestBody: (args) => {
|
|
344
344
|
const thinking = args.thinking;
|
|
345
345
|
const reasoningHistory = args.reasoningHistory;
|
|
346
|
-
const {
|
|
346
|
+
const {
|
|
347
|
+
thinking: _,
|
|
348
|
+
reasoningHistory: __,
|
|
349
|
+
reasoning_effort,
|
|
350
|
+
...rest
|
|
351
|
+
} = args;
|
|
347
352
|
return {
|
|
348
353
|
...rest,
|
|
354
|
+
...reasoning_effort != null && {
|
|
355
|
+
// Workaround since OpenAI spec allows for 5 reasoning levels, but Fireworks only supports 3 of them.
|
|
356
|
+
reasoning_effort: reasoning_effort === "minimal" ? "low" : reasoning_effort === "xhigh" ? "high" : reasoning_effort
|
|
357
|
+
},
|
|
349
358
|
...thinking && {
|
|
350
359
|
thinking: {
|
|
351
360
|
type: thinking.type,
|
|
@@ -361,11 +370,11 @@ function createFireworks(options = {}) {
|
|
|
361
370
|
}
|
|
362
371
|
});
|
|
363
372
|
};
|
|
364
|
-
const createCompletionModel = (modelId) => new
|
|
373
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
|
|
365
374
|
...getCommonModelConfig("completion"),
|
|
366
375
|
errorStructure: fireworksErrorStructure
|
|
367
376
|
});
|
|
368
|
-
const createEmbeddingModel = (modelId) => new
|
|
377
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
|
|
369
378
|
...getCommonModelConfig("embedding"),
|
|
370
379
|
errorStructure: fireworksErrorStructure
|
|
371
380
|
});
|
|
@@ -385,11 +394,10 @@ function createFireworks(options = {}) {
|
|
|
385
394
|
return provider;
|
|
386
395
|
}
|
|
387
396
|
var fireworks = createFireworks();
|
|
388
|
-
|
|
389
|
-
0 && (module.exports = {
|
|
397
|
+
export {
|
|
390
398
|
FireworksImageModel,
|
|
391
399
|
VERSION,
|
|
392
400
|
createFireworks,
|
|
393
401
|
fireworks
|
|
394
|
-
}
|
|
402
|
+
};
|
|
395
403
|
//# sourceMappingURL=index.js.map
|