@ai-sdk/fireworks 3.0.0-beta.9 → 3.0.0-canary.37
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 +264 -0
- package/README.md +2 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +75 -76
- package/dist/index.js.map +1 -1
- package/package.json +12 -10
- package/src/fireworks-image-model.ts +22 -5
- package/src/fireworks-provider.ts +7 -7
- package/dist/index.d.mts +0 -131
- package/dist/index.mjs +0 -391
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,269 @@
|
|
|
1
1
|
# @ai-sdk/fireworks
|
|
2
2
|
|
|
3
|
+
## 3.0.0-canary.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c4c275: trigger initial canary release
|
|
8
|
+
- Updated dependencies [0c4c275]
|
|
9
|
+
- @ai-sdk/openai-compatible@3.0.0-canary.37
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.0-canary.31
|
|
11
|
+
- @ai-sdk/provider@4.0.0-canary.15
|
|
12
|
+
|
|
13
|
+
## 3.0.0-beta.36
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [e59c955]
|
|
18
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.36
|
|
19
|
+
|
|
20
|
+
## 3.0.0-beta.35
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [08d2129]
|
|
25
|
+
- Updated dependencies [04e9009]
|
|
26
|
+
- @ai-sdk/provider-utils@5.0.0-beta.30
|
|
27
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.35
|
|
28
|
+
|
|
29
|
+
## 3.0.0-beta.34
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
34
|
+
- Updated dependencies [9bd6512]
|
|
35
|
+
- Updated dependencies [258c093]
|
|
36
|
+
- Updated dependencies [b6783da]
|
|
37
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.34
|
|
38
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
39
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
40
|
+
|
|
41
|
+
## 3.0.0-beta.33
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
46
|
+
- Updated dependencies [9f0e36c]
|
|
47
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.33
|
|
48
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
49
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
50
|
+
|
|
51
|
+
## 3.0.0-beta.32
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [ab81968]
|
|
56
|
+
- Updated dependencies [785fe16]
|
|
57
|
+
- Updated dependencies [67df0a0]
|
|
58
|
+
- Updated dependencies [befb78c]
|
|
59
|
+
- Updated dependencies [0458559]
|
|
60
|
+
- Updated dependencies [58a2ad7]
|
|
61
|
+
- Updated dependencies [5852c0a]
|
|
62
|
+
- Updated dependencies [fc92055]
|
|
63
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.32
|
|
64
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
65
|
+
|
|
66
|
+
## 3.0.0-beta.31
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Updated dependencies [2e98477]
|
|
71
|
+
- Updated dependencies [bfb756d]
|
|
72
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
73
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.31
|
|
74
|
+
|
|
75
|
+
## 3.0.0-beta.30
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [eea8d98]
|
|
80
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
81
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.30
|
|
82
|
+
|
|
83
|
+
## 3.0.0-beta.29
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [f807e45]
|
|
88
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
89
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.29
|
|
90
|
+
|
|
91
|
+
## 3.0.0-beta.28
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [350ea38]
|
|
96
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
97
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.28
|
|
98
|
+
|
|
99
|
+
## 3.0.0-beta.27
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- Updated dependencies [083947b]
|
|
104
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
105
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.27
|
|
106
|
+
|
|
107
|
+
## 3.0.0-beta.26
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- Updated dependencies [add1126]
|
|
112
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
113
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.26
|
|
114
|
+
|
|
115
|
+
## 3.0.0-beta.25
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
120
|
+
|
|
121
|
+
**`@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.
|
|
122
|
+
|
|
123
|
+
**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.
|
|
124
|
+
|
|
125
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [b3976a2]
|
|
128
|
+
- Updated dependencies [ff5eba1]
|
|
129
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
130
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.25
|
|
131
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
132
|
+
|
|
133
|
+
## 3.0.0-beta.24
|
|
134
|
+
|
|
135
|
+
### Major Changes
|
|
136
|
+
|
|
137
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [ef992f8]
|
|
142
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.24
|
|
143
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
144
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
145
|
+
|
|
146
|
+
## 3.0.0-beta.23
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
151
|
+
- Updated dependencies [90e2d8a]
|
|
152
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.23
|
|
153
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
154
|
+
|
|
155
|
+
## 3.0.0-beta.22
|
|
156
|
+
|
|
157
|
+
### Patch Changes
|
|
158
|
+
|
|
159
|
+
- Updated dependencies [3ae1786]
|
|
160
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
161
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.22
|
|
162
|
+
|
|
163
|
+
## 3.0.0-beta.21
|
|
164
|
+
|
|
165
|
+
### Patch Changes
|
|
166
|
+
|
|
167
|
+
- Updated dependencies [176466a]
|
|
168
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
169
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.21
|
|
170
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
171
|
+
|
|
172
|
+
## 3.0.0-beta.20
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- Updated dependencies [e311194]
|
|
177
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
178
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.20
|
|
179
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
180
|
+
|
|
181
|
+
## 3.0.0-beta.19
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- Updated dependencies [34bd95d]
|
|
186
|
+
- Updated dependencies [008271d]
|
|
187
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
188
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
189
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
190
|
+
|
|
191
|
+
## 3.0.0-beta.18
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- Updated dependencies [b0c2869]
|
|
196
|
+
- Updated dependencies [7e26e81]
|
|
197
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
198
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
199
|
+
|
|
200
|
+
## 3.0.0-beta.17
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- Updated dependencies [816ff67]
|
|
205
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
206
|
+
|
|
207
|
+
## 3.0.0-beta.16
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- Updated dependencies [46d1149]
|
|
212
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
213
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
214
|
+
|
|
215
|
+
## 3.0.0-beta.15
|
|
216
|
+
|
|
217
|
+
### Patch Changes
|
|
218
|
+
|
|
219
|
+
- Updated dependencies [6fd51c0]
|
|
220
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
221
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
222
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
223
|
+
|
|
224
|
+
## 3.0.0-beta.14
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- Updated dependencies [c29a26f]
|
|
229
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
230
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
231
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
232
|
+
|
|
233
|
+
## 3.0.0-beta.13
|
|
234
|
+
|
|
235
|
+
### Patch Changes
|
|
236
|
+
|
|
237
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
238
|
+
- Updated dependencies [38fc777]
|
|
239
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
240
|
+
|
|
241
|
+
## 3.0.0-beta.12
|
|
242
|
+
|
|
243
|
+
### Patch Changes
|
|
244
|
+
|
|
245
|
+
- Updated dependencies [2e17091]
|
|
246
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
247
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
248
|
+
|
|
249
|
+
## 3.0.0-beta.11
|
|
250
|
+
|
|
251
|
+
### Patch Changes
|
|
252
|
+
|
|
253
|
+
- Updated dependencies [986c6fd]
|
|
254
|
+
- Updated dependencies [493295c]
|
|
255
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
256
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
257
|
+
|
|
258
|
+
## 3.0.0-beta.10
|
|
259
|
+
|
|
260
|
+
### Patch Changes
|
|
261
|
+
|
|
262
|
+
- Updated dependencies [1f509d4]
|
|
263
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
264
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
265
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
266
|
+
|
|
3
267
|
## 3.0.0-beta.9
|
|
4
268
|
|
|
5
269
|
### Patch Changes
|
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-
|
|
308
|
+
var VERSION = true ? "3.0.0-canary.37" : "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,7 +337,7 @@ 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) => {
|
|
@@ -370,11 +370,11 @@ function createFireworks(options = {}) {
|
|
|
370
370
|
}
|
|
371
371
|
});
|
|
372
372
|
};
|
|
373
|
-
const createCompletionModel = (modelId) => new
|
|
373
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
|
|
374
374
|
...getCommonModelConfig("completion"),
|
|
375
375
|
errorStructure: fireworksErrorStructure
|
|
376
376
|
});
|
|
377
|
-
const createEmbeddingModel = (modelId) => new
|
|
377
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
|
|
378
378
|
...getCommonModelConfig("embedding"),
|
|
379
379
|
errorStructure: fireworksErrorStructure
|
|
380
380
|
});
|
|
@@ -394,11 +394,10 @@ function createFireworks(options = {}) {
|
|
|
394
394
|
return provider;
|
|
395
395
|
}
|
|
396
396
|
var fireworks = createFireworks();
|
|
397
|
-
|
|
398
|
-
0 && (module.exports = {
|
|
397
|
+
export {
|
|
399
398
|
FireworksImageModel,
|
|
400
399
|
VERSION,
|
|
401
400
|
createFireworks,
|
|
402
401
|
fireworks
|
|
403
|
-
}
|
|
402
|
+
};
|
|
404
403
|
//# sourceMappingURL=index.js.map
|