@apicity/fireworks 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +1694 -0
- package/dist/src/example.d.ts +8 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +143 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/fireworks.d.ts +3 -0
- package/dist/src/fireworks.d.ts.map +1 -0
- package/dist/src/fireworks.js +1732 -0
- package/dist/src/fireworks.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/middleware.d.ts +34 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +219 -0
- package/dist/src/middleware.js.map +1 -0
- package/dist/src/sse.d.ts +6 -0
- package/dist/src/sse.d.ts.map +1 -0
- package/dist/src/sse.js +55 -0
- package/dist/src/sse.js.map +1 -0
- package/dist/src/types.d.ts +1942 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/zod.d.ts +3259 -0
- package/dist/src/zod.d.ts.map +1 -0
- package/dist/src/zod.js +754 -0
- package/dist/src/zod.js.map +1 -0
- package/package.json +60 -0
package/dist/src/zod.js
ADDED
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Sub-schemas (composable building blocks)
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export const FireworksMessageSchema = z.object({
|
|
6
|
+
role: z.enum(["user", "assistant", "system"]),
|
|
7
|
+
content: z.string(),
|
|
8
|
+
tool_calls: z
|
|
9
|
+
.array(z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
type: z.literal("function"),
|
|
12
|
+
function: z.object({
|
|
13
|
+
name: z.string(),
|
|
14
|
+
arguments: z.string(),
|
|
15
|
+
}),
|
|
16
|
+
}))
|
|
17
|
+
.optional(),
|
|
18
|
+
tool_call_id: z.string().optional(),
|
|
19
|
+
name: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
export const FireworksToolFunctionSchema = z.object({
|
|
22
|
+
name: z.string(),
|
|
23
|
+
description: z.string().optional(),
|
|
24
|
+
parameters: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
});
|
|
26
|
+
export const FireworksToolSchema = z.object({
|
|
27
|
+
type: z.literal("function"),
|
|
28
|
+
function: FireworksToolFunctionSchema,
|
|
29
|
+
});
|
|
30
|
+
export const FireworksResponseFormatSchema = z.object({
|
|
31
|
+
type: z.enum(["text", "json_object", "json_schema", "grammar"]),
|
|
32
|
+
json_schema: z.record(z.string(), z.unknown()).optional(),
|
|
33
|
+
grammar: z.record(z.string(), z.unknown()).optional(),
|
|
34
|
+
});
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Chat completions
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
export const FireworksChatRequestSchema = z.object({
|
|
39
|
+
model: z.string(),
|
|
40
|
+
messages: z.array(FireworksMessageSchema),
|
|
41
|
+
temperature: z.number().optional(),
|
|
42
|
+
top_p: z.number().optional(),
|
|
43
|
+
top_k: z.number().optional(),
|
|
44
|
+
max_tokens: z.number().optional(),
|
|
45
|
+
max_completion_tokens: z.number().optional(),
|
|
46
|
+
n: z.number().optional(),
|
|
47
|
+
stop: z.union([z.string(), z.array(z.string())]).optional(),
|
|
48
|
+
stream: z.boolean().optional(),
|
|
49
|
+
tools: z.array(FireworksToolSchema).optional(),
|
|
50
|
+
tool_choice: z
|
|
51
|
+
.union([
|
|
52
|
+
z.enum(["auto", "none", "required"]),
|
|
53
|
+
z.object({
|
|
54
|
+
type: z.literal("function"),
|
|
55
|
+
function: z.object({ name: z.string() }),
|
|
56
|
+
}),
|
|
57
|
+
])
|
|
58
|
+
.optional(),
|
|
59
|
+
response_format: FireworksResponseFormatSchema.optional(),
|
|
60
|
+
frequency_penalty: z.number().optional(),
|
|
61
|
+
presence_penalty: z.number().optional(),
|
|
62
|
+
logprobs: z.boolean().optional(),
|
|
63
|
+
top_logprobs: z.number().optional(),
|
|
64
|
+
reasoning_effort: z.enum(["low", "medium", "high", "none"]).optional(),
|
|
65
|
+
user: z.string().optional(),
|
|
66
|
+
});
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Completions
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
export const FireworksCompletionRequestSchema = z.object({
|
|
71
|
+
model: z.string(),
|
|
72
|
+
prompt: z.union([
|
|
73
|
+
z.string(),
|
|
74
|
+
z.array(z.string()),
|
|
75
|
+
z.array(z.number()),
|
|
76
|
+
z.array(z.array(z.number())),
|
|
77
|
+
]),
|
|
78
|
+
max_tokens: z.number().optional(),
|
|
79
|
+
max_completion_tokens: z.number().optional(),
|
|
80
|
+
temperature: z.number().optional(),
|
|
81
|
+
top_p: z.number().optional(),
|
|
82
|
+
top_k: z.number().optional(),
|
|
83
|
+
n: z.number().optional(),
|
|
84
|
+
stop: z.union([z.string(), z.array(z.string())]).optional(),
|
|
85
|
+
stream: z.boolean().optional(),
|
|
86
|
+
echo: z.boolean().optional(),
|
|
87
|
+
echo_last: z.number().optional(),
|
|
88
|
+
frequency_penalty: z.number().optional(),
|
|
89
|
+
presence_penalty: z.number().optional(),
|
|
90
|
+
repetition_penalty: z.number().optional(),
|
|
91
|
+
logprobs: z.union([z.boolean(), z.number()]).optional(),
|
|
92
|
+
top_logprobs: z.number().optional(),
|
|
93
|
+
response_format: FireworksResponseFormatSchema.optional(),
|
|
94
|
+
reasoning_effort: z.enum(["low", "medium", "high", "none"]).optional(),
|
|
95
|
+
seed: z.number().optional(),
|
|
96
|
+
user: z.string().optional(),
|
|
97
|
+
});
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Embeddings
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
export const FireworksEmbeddingRequestSchema = z.object({
|
|
102
|
+
model: z.string(),
|
|
103
|
+
input: z.union([
|
|
104
|
+
z.string(),
|
|
105
|
+
z.array(z.string()),
|
|
106
|
+
z.array(z.number()),
|
|
107
|
+
z.array(z.array(z.number())),
|
|
108
|
+
]),
|
|
109
|
+
dimensions: z.number().optional(),
|
|
110
|
+
prompt_template: z.string().optional(),
|
|
111
|
+
return_logits: z.array(z.number()).optional(),
|
|
112
|
+
normalize: z.boolean().optional(),
|
|
113
|
+
});
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Rerank
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
export const FireworksRerankRequestSchema = z.object({
|
|
118
|
+
model: z.string(),
|
|
119
|
+
query: z.string(),
|
|
120
|
+
documents: z.array(z.string()),
|
|
121
|
+
top_n: z.number().optional(),
|
|
122
|
+
return_documents: z.boolean().optional(),
|
|
123
|
+
});
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// Anthropic Messages (via Fireworks)
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
export const AnthropicInputContentBlockSchema = z.union([
|
|
128
|
+
z.object({ type: z.literal("text"), text: z.string() }),
|
|
129
|
+
z.object({
|
|
130
|
+
type: z.literal("image"),
|
|
131
|
+
source: z.union([
|
|
132
|
+
z.object({
|
|
133
|
+
type: z.literal("base64"),
|
|
134
|
+
media_type: z.enum([
|
|
135
|
+
"image/jpeg",
|
|
136
|
+
"image/png",
|
|
137
|
+
"image/gif",
|
|
138
|
+
"image/webp",
|
|
139
|
+
]),
|
|
140
|
+
data: z.string(),
|
|
141
|
+
}),
|
|
142
|
+
z.object({ type: z.literal("url"), url: z.string() }),
|
|
143
|
+
]),
|
|
144
|
+
}),
|
|
145
|
+
z.object({
|
|
146
|
+
type: z.literal("thinking"),
|
|
147
|
+
thinking: z.string(),
|
|
148
|
+
signature: z.string(),
|
|
149
|
+
}),
|
|
150
|
+
z.object({
|
|
151
|
+
type: z.literal("redacted_thinking"),
|
|
152
|
+
data: z.string(),
|
|
153
|
+
}),
|
|
154
|
+
z.object({
|
|
155
|
+
type: z.literal("tool_use"),
|
|
156
|
+
id: z.string(),
|
|
157
|
+
name: z.string(),
|
|
158
|
+
input: z.record(z.string(), z.unknown()),
|
|
159
|
+
}),
|
|
160
|
+
z.object({
|
|
161
|
+
type: z.literal("tool_result"),
|
|
162
|
+
tool_use_id: z.string(),
|
|
163
|
+
content: z
|
|
164
|
+
.union([z.string(), z.array(z.record(z.string(), z.unknown()))])
|
|
165
|
+
.optional(),
|
|
166
|
+
is_error: z.boolean().optional(),
|
|
167
|
+
}),
|
|
168
|
+
]);
|
|
169
|
+
export const AnthropicInputMessageSchema = z.object({
|
|
170
|
+
role: z.enum(["user", "assistant"]),
|
|
171
|
+
content: z.union([z.string(), z.array(AnthropicInputContentBlockSchema)]),
|
|
172
|
+
});
|
|
173
|
+
export const AnthropicToolDefinitionSchema = z.object({
|
|
174
|
+
name: z.string(),
|
|
175
|
+
description: z.string().optional(),
|
|
176
|
+
input_schema: z.record(z.string(), z.unknown()),
|
|
177
|
+
strict: z.boolean().optional(),
|
|
178
|
+
});
|
|
179
|
+
export const AnthropicThinkingConfigSchema = z.object({
|
|
180
|
+
type: z.enum(["enabled", "disabled"]),
|
|
181
|
+
budget_tokens: z.number().optional(),
|
|
182
|
+
});
|
|
183
|
+
export const AnthropicMessagesRequestSchema = z.object({
|
|
184
|
+
model: z.string(),
|
|
185
|
+
messages: z.array(AnthropicInputMessageSchema),
|
|
186
|
+
max_tokens: z.number().optional(),
|
|
187
|
+
system: z
|
|
188
|
+
.union([
|
|
189
|
+
z.string(),
|
|
190
|
+
z.array(z.object({ type: z.literal("text"), text: z.string() })),
|
|
191
|
+
])
|
|
192
|
+
.optional(),
|
|
193
|
+
temperature: z.number().optional(),
|
|
194
|
+
top_p: z.number().optional(),
|
|
195
|
+
top_k: z.number().optional(),
|
|
196
|
+
stop_sequences: z.array(z.string()).optional(),
|
|
197
|
+
stream: z.boolean().optional(),
|
|
198
|
+
metadata: z.object({ user_id: z.string().optional() }).optional(),
|
|
199
|
+
thinking: AnthropicThinkingConfigSchema.optional(),
|
|
200
|
+
tools: z.array(AnthropicToolDefinitionSchema).optional(),
|
|
201
|
+
tool_choice: z
|
|
202
|
+
.union([
|
|
203
|
+
z.object({
|
|
204
|
+
type: z.literal("auto"),
|
|
205
|
+
disable_parallel_tool_use: z.boolean().optional(),
|
|
206
|
+
}),
|
|
207
|
+
z.object({
|
|
208
|
+
type: z.literal("any"),
|
|
209
|
+
disable_parallel_tool_use: z.boolean().optional(),
|
|
210
|
+
}),
|
|
211
|
+
z.object({ type: z.literal("none") }),
|
|
212
|
+
z.object({
|
|
213
|
+
type: z.literal("tool"),
|
|
214
|
+
name: z.string(),
|
|
215
|
+
disable_parallel_tool_use: z.boolean().optional(),
|
|
216
|
+
}),
|
|
217
|
+
])
|
|
218
|
+
.optional(),
|
|
219
|
+
raw_output: z.boolean().optional(),
|
|
220
|
+
});
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
// Audio
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
export const FireworksTranscriptionRequestSchema = z.object({
|
|
225
|
+
file: z.union([z.instanceof(Blob), z.string()]),
|
|
226
|
+
model: z.string().optional(),
|
|
227
|
+
vad_model: z.enum(["silero", "whisperx-pyannet"]).optional(),
|
|
228
|
+
alignment_model: z.enum(["mms_fa", "tdnn_ffn"]).optional(),
|
|
229
|
+
language: z.string().optional(),
|
|
230
|
+
prompt: z.string().optional(),
|
|
231
|
+
temperature: z.union([z.number(), z.array(z.number())]).optional(),
|
|
232
|
+
response_format: z
|
|
233
|
+
.enum(["json", "text", "srt", "verbose_json", "vtt"])
|
|
234
|
+
.optional(),
|
|
235
|
+
timestamp_granularities: z
|
|
236
|
+
.union([z.string(), z.array(z.string())])
|
|
237
|
+
.optional(),
|
|
238
|
+
diarize: z.enum(["true", "false"]).optional(),
|
|
239
|
+
min_speakers: z.number().optional(),
|
|
240
|
+
max_speakers: z.number().optional(),
|
|
241
|
+
preprocessing: z
|
|
242
|
+
.enum(["none", "dynamic", "soft_dynamic", "bass_dynamic"])
|
|
243
|
+
.optional(),
|
|
244
|
+
});
|
|
245
|
+
export const FireworksTranslationRequestSchema = z.object({
|
|
246
|
+
file: z.union([z.instanceof(Blob), z.string()]),
|
|
247
|
+
model: z.string().optional(),
|
|
248
|
+
vad_model: z.enum(["silero", "whisperx-pyannet"]).optional(),
|
|
249
|
+
alignment_model: z.enum(["mms_fa", "tdnn_ffn"]).optional(),
|
|
250
|
+
language: z.string().optional(),
|
|
251
|
+
prompt: z.string().optional(),
|
|
252
|
+
temperature: z.union([z.number(), z.array(z.number())]).optional(),
|
|
253
|
+
response_format: z
|
|
254
|
+
.enum(["json", "text", "srt", "verbose_json", "vtt"])
|
|
255
|
+
.optional(),
|
|
256
|
+
timestamp_granularities: z
|
|
257
|
+
.union([z.string(), z.array(z.string())])
|
|
258
|
+
.optional(),
|
|
259
|
+
preprocessing: z
|
|
260
|
+
.enum(["none", "dynamic", "soft_dynamic", "bass_dynamic"])
|
|
261
|
+
.optional(),
|
|
262
|
+
});
|
|
263
|
+
export const FireworksStreamingTranscriptionOptionsSchema = z.object({
|
|
264
|
+
language: z.string().optional(),
|
|
265
|
+
prompt: z.string().optional(),
|
|
266
|
+
temperature: z.number().optional(),
|
|
267
|
+
response_format: z.literal("verbose_json").optional(),
|
|
268
|
+
timestamp_granularities: z.array(z.string()).optional(),
|
|
269
|
+
baseURL: z.string().optional(),
|
|
270
|
+
});
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// Audio batch
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
export const FireworksAudioBatchTranscriptionRequestSchema = z.object({
|
|
275
|
+
file: z.union([z.instanceof(Blob), z.string()]),
|
|
276
|
+
endpoint_id: z.string(),
|
|
277
|
+
model: z.string().optional(),
|
|
278
|
+
vad_model: z.enum(["silero", "whisperx-pyannet"]).optional(),
|
|
279
|
+
alignment_model: z.enum(["mms_fa", "tdnn_ffn"]).optional(),
|
|
280
|
+
language: z.string().optional(),
|
|
281
|
+
prompt: z.string().optional(),
|
|
282
|
+
temperature: z.union([z.number(), z.array(z.number())]).optional(),
|
|
283
|
+
response_format: z
|
|
284
|
+
.enum(["json", "text", "srt", "verbose_json", "vtt"])
|
|
285
|
+
.optional(),
|
|
286
|
+
timestamp_granularities: z
|
|
287
|
+
.union([z.string(), z.array(z.string())])
|
|
288
|
+
.optional(),
|
|
289
|
+
diarize: z.enum(["true", "false"]).optional(),
|
|
290
|
+
min_speakers: z.number().optional(),
|
|
291
|
+
max_speakers: z.number().optional(),
|
|
292
|
+
preprocessing: z
|
|
293
|
+
.enum(["none", "dynamic", "soft_dynamic", "bass_dynamic"])
|
|
294
|
+
.optional(),
|
|
295
|
+
});
|
|
296
|
+
export const FireworksAudioBatchTranslationRequestSchema = z.object({
|
|
297
|
+
file: z.union([z.instanceof(Blob), z.string()]),
|
|
298
|
+
endpoint_id: z.string(),
|
|
299
|
+
model: z.string().optional(),
|
|
300
|
+
vad_model: z.enum(["silero", "whisperx-pyannet"]).optional(),
|
|
301
|
+
alignment_model: z.enum(["mms_fa", "tdnn_ffn"]).optional(),
|
|
302
|
+
language: z.string().optional(),
|
|
303
|
+
prompt: z.string().optional(),
|
|
304
|
+
temperature: z.union([z.number(), z.array(z.number())]).optional(),
|
|
305
|
+
response_format: z
|
|
306
|
+
.enum(["json", "text", "srt", "verbose_json", "vtt"])
|
|
307
|
+
.optional(),
|
|
308
|
+
timestamp_granularities: z
|
|
309
|
+
.union([z.string(), z.array(z.string())])
|
|
310
|
+
.optional(),
|
|
311
|
+
preprocessing: z
|
|
312
|
+
.enum(["none", "dynamic", "soft_dynamic", "bass_dynamic"])
|
|
313
|
+
.optional(),
|
|
314
|
+
});
|
|
315
|
+
// ---------------------------------------------------------------------------
|
|
316
|
+
// Workflows (text-to-image, kontext, getResult)
|
|
317
|
+
// ---------------------------------------------------------------------------
|
|
318
|
+
export const FireworksTextToImageRequestSchema = z.object({
|
|
319
|
+
prompt: z.string(),
|
|
320
|
+
aspect_ratio: z
|
|
321
|
+
.enum([
|
|
322
|
+
"1:1",
|
|
323
|
+
"21:9",
|
|
324
|
+
"16:9",
|
|
325
|
+
"3:2",
|
|
326
|
+
"5:4",
|
|
327
|
+
"4:5",
|
|
328
|
+
"2:3",
|
|
329
|
+
"9:16",
|
|
330
|
+
"9:21",
|
|
331
|
+
"4:3",
|
|
332
|
+
"3:4",
|
|
333
|
+
])
|
|
334
|
+
.optional(),
|
|
335
|
+
guidance_scale: z.number().optional(),
|
|
336
|
+
num_inference_steps: z.number().optional(),
|
|
337
|
+
seed: z.number().optional(),
|
|
338
|
+
});
|
|
339
|
+
export const FireworksKontextRequestSchema = z.object({
|
|
340
|
+
prompt: z.string(),
|
|
341
|
+
input_image: z.string().nullable().optional(),
|
|
342
|
+
seed: z.number().nullable().optional(),
|
|
343
|
+
aspect_ratio: z.string().nullable().optional(),
|
|
344
|
+
output_format: z.enum(["png", "jpeg"]).optional(),
|
|
345
|
+
webhook_url: z.string().nullable().optional(),
|
|
346
|
+
webhook_secret: z.string().nullable().optional(),
|
|
347
|
+
prompt_upsampling: z.boolean().optional(),
|
|
348
|
+
safety_tolerance: z.number().optional(),
|
|
349
|
+
});
|
|
350
|
+
export const FireworksGetResultRequestSchema = z.object({
|
|
351
|
+
id: z.string(),
|
|
352
|
+
});
|
|
353
|
+
// ---------------------------------------------------------------------------
|
|
354
|
+
// Models CRUD
|
|
355
|
+
// ---------------------------------------------------------------------------
|
|
356
|
+
export const FireworksCreateModelRequestSchema = z.object({
|
|
357
|
+
modelId: z.string(),
|
|
358
|
+
model: z.record(z.string(), z.unknown()),
|
|
359
|
+
cluster: z.string().optional(),
|
|
360
|
+
});
|
|
361
|
+
export const FireworksUpdateModelRequestSchema = z.object({
|
|
362
|
+
displayName: z.string().optional(),
|
|
363
|
+
description: z.string().optional(),
|
|
364
|
+
kind: z.string().optional(),
|
|
365
|
+
public: z.boolean().optional(),
|
|
366
|
+
contextLength: z.number().optional(),
|
|
367
|
+
supportsImageInput: z.boolean().optional(),
|
|
368
|
+
supportsTools: z.boolean().optional(),
|
|
369
|
+
});
|
|
370
|
+
export const FireworksPrepareModelRequestSchema = z.object({
|
|
371
|
+
precision: z.string(),
|
|
372
|
+
readMask: z.string().optional(),
|
|
373
|
+
});
|
|
374
|
+
export const FireworksGetUploadEndpointRequestSchema = z.object({
|
|
375
|
+
filenameToSize: z.record(z.string(), z.number()),
|
|
376
|
+
enableResumableUpload: z.boolean().optional(),
|
|
377
|
+
readMask: z.string().optional(),
|
|
378
|
+
});
|
|
379
|
+
export const FireworksValidateUploadRequestSchema = z.object({
|
|
380
|
+
skipHfConfigValidation: z.boolean().optional(),
|
|
381
|
+
trustRemoteCode: z.boolean().optional(),
|
|
382
|
+
configOnly: z.boolean().optional(),
|
|
383
|
+
});
|
|
384
|
+
// ---------------------------------------------------------------------------
|
|
385
|
+
// Batch inference
|
|
386
|
+
// ---------------------------------------------------------------------------
|
|
387
|
+
export const FireworksBatchInferenceParametersSchema = z.object({
|
|
388
|
+
maxTokens: z.number().optional(),
|
|
389
|
+
temperature: z.number().optional(),
|
|
390
|
+
topP: z.number().optional(),
|
|
391
|
+
n: z.number().optional(),
|
|
392
|
+
topK: z.number().optional(),
|
|
393
|
+
extraBody: z.string().optional(),
|
|
394
|
+
});
|
|
395
|
+
export const FireworksBatchJobCreateRequestSchema = z.object({
|
|
396
|
+
model: z.string(),
|
|
397
|
+
inputDatasetId: z.string(),
|
|
398
|
+
displayName: z.string().optional(),
|
|
399
|
+
outputDatasetId: z.string().optional(),
|
|
400
|
+
inferenceParameters: FireworksBatchInferenceParametersSchema.optional(),
|
|
401
|
+
precision: z.string().optional(),
|
|
402
|
+
continuedFromJobName: z.string().optional(),
|
|
403
|
+
});
|
|
404
|
+
// ---------------------------------------------------------------------------
|
|
405
|
+
// Training shared sub-schemas
|
|
406
|
+
// ---------------------------------------------------------------------------
|
|
407
|
+
export const FireworksBaseTrainingConfigSchema = z.object({
|
|
408
|
+
baseModel: z.string().optional(),
|
|
409
|
+
warmStartFrom: z.string().optional(),
|
|
410
|
+
outputModel: z.string().optional(),
|
|
411
|
+
learningRate: z.number().optional(),
|
|
412
|
+
epochs: z.number().optional(),
|
|
413
|
+
batchSize: z.number().optional(),
|
|
414
|
+
batchSizeSamples: z.number().optional(),
|
|
415
|
+
gradientAccumulationSteps: z.number().optional(),
|
|
416
|
+
learningRateWarmupSteps: z.number().optional(),
|
|
417
|
+
maxContextLength: z.number().optional(),
|
|
418
|
+
loraRank: z.number().optional(),
|
|
419
|
+
optimizerWeightDecay: z.number().optional(),
|
|
420
|
+
jinjaTemplate: z.string().optional(),
|
|
421
|
+
region: z.string().optional(),
|
|
422
|
+
});
|
|
423
|
+
export const FireworksRLLossConfigSchema = z.object({
|
|
424
|
+
method: z
|
|
425
|
+
.enum(["METHOD_UNSPECIFIED", "GRPO", "DAPO", "DPO", "ORPO", "GSPO_TOKEN"])
|
|
426
|
+
.optional(),
|
|
427
|
+
klBeta: z.number().optional(),
|
|
428
|
+
});
|
|
429
|
+
export const FireworksWandbConfigSchema = z.object({
|
|
430
|
+
enabled: z.boolean().optional(),
|
|
431
|
+
apiKey: z.string().optional(),
|
|
432
|
+
project: z.string().optional(),
|
|
433
|
+
entity: z.string().optional(),
|
|
434
|
+
runId: z.string().optional(),
|
|
435
|
+
url: z.string().optional(),
|
|
436
|
+
});
|
|
437
|
+
export const FireworksAwsS3ConfigSchema = z.object({
|
|
438
|
+
credentialsSecret: z.string().optional(),
|
|
439
|
+
iamRoleArn: z.string().optional(),
|
|
440
|
+
});
|
|
441
|
+
export const FireworksAzureBlobStorageConfigSchema = z.object({
|
|
442
|
+
credentialsSecret: z.string().optional(),
|
|
443
|
+
managedIdentityClientId: z.string().optional(),
|
|
444
|
+
tenantId: z.string().optional(),
|
|
445
|
+
});
|
|
446
|
+
export const FireworksRFTInferenceParamsSchema = z.object({
|
|
447
|
+
maxTokens: z.number().optional(),
|
|
448
|
+
temperature: z.number().optional(),
|
|
449
|
+
topP: z.number().optional(),
|
|
450
|
+
topK: z.number().optional(),
|
|
451
|
+
});
|
|
452
|
+
// ---------------------------------------------------------------------------
|
|
453
|
+
// SFT (Supervised Fine-Tuning)
|
|
454
|
+
// ---------------------------------------------------------------------------
|
|
455
|
+
export const FireworksSFTCreateRequestSchema = z.object({
|
|
456
|
+
accountId: z.string(),
|
|
457
|
+
dataset: z.string(),
|
|
458
|
+
displayName: z.string().optional(),
|
|
459
|
+
baseModel: z.string().optional(),
|
|
460
|
+
warmStartFrom: z.string().optional(),
|
|
461
|
+
outputModel: z.string().optional(),
|
|
462
|
+
jinjaTemplate: z.string().optional(),
|
|
463
|
+
epochs: z.number().optional(),
|
|
464
|
+
learningRate: z.number().optional(),
|
|
465
|
+
maxContextLength: z.number().optional(),
|
|
466
|
+
loraRank: z.number().optional(),
|
|
467
|
+
earlyStop: z.boolean().optional(),
|
|
468
|
+
evaluationDataset: z.string().optional(),
|
|
469
|
+
isTurbo: z.boolean().optional(),
|
|
470
|
+
evalAutoCarveout: z.boolean().optional(),
|
|
471
|
+
region: z.string().optional(),
|
|
472
|
+
nodes: z.number().optional(),
|
|
473
|
+
batchSize: z.number().optional(),
|
|
474
|
+
batchSizeSamples: z.number().optional(),
|
|
475
|
+
gradientAccumulationSteps: z.number().optional(),
|
|
476
|
+
learningRateWarmupSteps: z.number().optional(),
|
|
477
|
+
mtpEnabled: z.boolean().optional(),
|
|
478
|
+
mtpNumDraftTokens: z.number().optional(),
|
|
479
|
+
mtpFreezeBaseModel: z.boolean().optional(),
|
|
480
|
+
optimizerWeightDecay: z.number().optional(),
|
|
481
|
+
usePurpose: z.string().optional(),
|
|
482
|
+
awsS3Config: FireworksAwsS3ConfigSchema.optional(),
|
|
483
|
+
azureBlobStorageConfig: FireworksAzureBlobStorageConfigSchema.optional(),
|
|
484
|
+
wandbConfig: FireworksWandbConfigSchema.optional(),
|
|
485
|
+
supervisedFineTuningJobId: z.string().optional(),
|
|
486
|
+
});
|
|
487
|
+
// ---------------------------------------------------------------------------
|
|
488
|
+
// DPO Fine-Tuning
|
|
489
|
+
// ---------------------------------------------------------------------------
|
|
490
|
+
export const FireworksDpoJobCreateRequestSchema = z.object({
|
|
491
|
+
dataset: z.string(),
|
|
492
|
+
displayName: z.string().optional(),
|
|
493
|
+
trainingConfig: FireworksBaseTrainingConfigSchema.optional(),
|
|
494
|
+
lossConfig: FireworksRLLossConfigSchema.optional(),
|
|
495
|
+
wandbConfig: FireworksWandbConfigSchema.optional(),
|
|
496
|
+
awsS3Config: FireworksAwsS3ConfigSchema.optional(),
|
|
497
|
+
azureBlobStorageConfig: FireworksAzureBlobStorageConfigSchema.optional(),
|
|
498
|
+
});
|
|
499
|
+
// ---------------------------------------------------------------------------
|
|
500
|
+
// RFT (Reinforcement Fine-Tuning)
|
|
501
|
+
// ---------------------------------------------------------------------------
|
|
502
|
+
export const FireworksRFTCreateRequestSchema = z.object({
|
|
503
|
+
dataset: z.string(),
|
|
504
|
+
evaluator: z.string(),
|
|
505
|
+
displayName: z.string().optional(),
|
|
506
|
+
trainingConfig: FireworksBaseTrainingConfigSchema.optional(),
|
|
507
|
+
inferenceParams: FireworksRFTInferenceParamsSchema.optional(),
|
|
508
|
+
lossConfig: FireworksRLLossConfigSchema.optional(),
|
|
509
|
+
wandbConfig: FireworksWandbConfigSchema.optional(),
|
|
510
|
+
awsS3Config: FireworksAwsS3ConfigSchema.optional(),
|
|
511
|
+
azureBlobStorageConfig: FireworksAzureBlobStorageConfigSchema.optional(),
|
|
512
|
+
reinforcementFineTuningJobId: z.string().optional(),
|
|
513
|
+
});
|
|
514
|
+
// ---------------------------------------------------------------------------
|
|
515
|
+
// RLOR Trainer Jobs
|
|
516
|
+
// ---------------------------------------------------------------------------
|
|
517
|
+
export const FireworksRlorRewardWeightSchema = z.object({
|
|
518
|
+
name: z.string().optional(),
|
|
519
|
+
weight: z.number().optional(),
|
|
520
|
+
});
|
|
521
|
+
export const FireworksRlorTrainerJobCreateRequestSchema = z.object({
|
|
522
|
+
dataset: z.string(),
|
|
523
|
+
evaluator: z.string(),
|
|
524
|
+
displayName: z.string().optional(),
|
|
525
|
+
trainingConfig: FireworksBaseTrainingConfigSchema.optional(),
|
|
526
|
+
inferenceParams: FireworksRFTInferenceParamsSchema.optional(),
|
|
527
|
+
lossConfig: FireworksRLLossConfigSchema.optional(),
|
|
528
|
+
rewardWeights: z.array(FireworksRlorRewardWeightSchema).optional(),
|
|
529
|
+
wandbConfig: FireworksWandbConfigSchema.optional(),
|
|
530
|
+
awsS3Config: FireworksAwsS3ConfigSchema.optional(),
|
|
531
|
+
azureBlobStorageConfig: FireworksAzureBlobStorageConfigSchema.optional(),
|
|
532
|
+
});
|
|
533
|
+
export const FireworksRlorTrainerJobExecuteStepRequestSchema = z.object({
|
|
534
|
+
dataset: z.string(),
|
|
535
|
+
outputModel: z.string(),
|
|
536
|
+
});
|
|
537
|
+
// ---------------------------------------------------------------------------
|
|
538
|
+
// Deployments
|
|
539
|
+
// ---------------------------------------------------------------------------
|
|
540
|
+
const acceleratorTypeEnum = z.enum([
|
|
541
|
+
"ACCELERATOR_TYPE_UNSPECIFIED",
|
|
542
|
+
"NVIDIA_A100_80GB",
|
|
543
|
+
"NVIDIA_H100_80GB",
|
|
544
|
+
"AMD_MI300X_192GB",
|
|
545
|
+
"NVIDIA_A10G_24GB",
|
|
546
|
+
"NVIDIA_A100_40GB",
|
|
547
|
+
"NVIDIA_L4_24GB",
|
|
548
|
+
"NVIDIA_H200_141GB",
|
|
549
|
+
"NVIDIA_B200_180GB",
|
|
550
|
+
"AMD_MI325X_256GB",
|
|
551
|
+
"AMD_MI350X_288GB",
|
|
552
|
+
]);
|
|
553
|
+
const precisionEnum = z.enum([
|
|
554
|
+
"PRECISION_UNSPECIFIED",
|
|
555
|
+
"FP16",
|
|
556
|
+
"FP8",
|
|
557
|
+
"FP8_MM",
|
|
558
|
+
"BF16",
|
|
559
|
+
"NF4",
|
|
560
|
+
"FP4",
|
|
561
|
+
]);
|
|
562
|
+
export const FireworksCreateDeploymentRequestSchema = z.object({
|
|
563
|
+
baseModel: z.string(),
|
|
564
|
+
displayName: z.string().optional(),
|
|
565
|
+
description: z.string().optional(),
|
|
566
|
+
minReplicaCount: z.number().optional(),
|
|
567
|
+
maxReplicaCount: z.number().optional(),
|
|
568
|
+
acceleratorCount: z.number().optional(),
|
|
569
|
+
acceleratorType: acceleratorTypeEnum.optional(),
|
|
570
|
+
precision: precisionEnum.optional(),
|
|
571
|
+
enableAddons: z.boolean().optional(),
|
|
572
|
+
draftTokenCount: z.number().optional(),
|
|
573
|
+
draftModel: z.string().optional(),
|
|
574
|
+
maxContextLength: z.number().optional(),
|
|
575
|
+
deploymentShape: z.string().optional(),
|
|
576
|
+
});
|
|
577
|
+
export const FireworksUpdateDeploymentRequestSchema = z.object({
|
|
578
|
+
baseModel: z.string().optional(),
|
|
579
|
+
displayName: z.string().optional(),
|
|
580
|
+
description: z.string().optional(),
|
|
581
|
+
minReplicaCount: z.number().optional(),
|
|
582
|
+
maxReplicaCount: z.number().optional(),
|
|
583
|
+
acceleratorCount: z.number().optional(),
|
|
584
|
+
acceleratorType: acceleratorTypeEnum.optional(),
|
|
585
|
+
precision: precisionEnum.optional(),
|
|
586
|
+
enableAddons: z.boolean().optional(),
|
|
587
|
+
maxContextLength: z.number().optional(),
|
|
588
|
+
deploymentShape: z.string().optional(),
|
|
589
|
+
});
|
|
590
|
+
export const FireworksScaleDeploymentRequestSchema = z.object({
|
|
591
|
+
replicaCount: z.number(),
|
|
592
|
+
});
|
|
593
|
+
// ---------------------------------------------------------------------------
|
|
594
|
+
// Deployed Models (LoRA)
|
|
595
|
+
// ---------------------------------------------------------------------------
|
|
596
|
+
export const FireworksCreateDeployedModelRequestSchema = z.object({
|
|
597
|
+
model: z.string(),
|
|
598
|
+
deployment: z.string(),
|
|
599
|
+
displayName: z.string().optional(),
|
|
600
|
+
description: z.string().optional(),
|
|
601
|
+
default: z.boolean().optional(),
|
|
602
|
+
serverless: z.boolean().optional(),
|
|
603
|
+
public: z.boolean().optional(),
|
|
604
|
+
});
|
|
605
|
+
export const FireworksUpdateDeployedModelRequestSchema = z.object({
|
|
606
|
+
displayName: z.string().optional(),
|
|
607
|
+
description: z.string().optional(),
|
|
608
|
+
model: z.string().optional(),
|
|
609
|
+
deployment: z.string().optional(),
|
|
610
|
+
default: z.boolean().optional(),
|
|
611
|
+
serverless: z.boolean().optional(),
|
|
612
|
+
public: z.boolean().optional(),
|
|
613
|
+
});
|
|
614
|
+
// ---------------------------------------------------------------------------
|
|
615
|
+
// Datasets
|
|
616
|
+
// ---------------------------------------------------------------------------
|
|
617
|
+
export const FireworksCreateDatasetRequestSchema = z.object({
|
|
618
|
+
dataset: z.record(z.string(), z.unknown()),
|
|
619
|
+
datasetId: z.string(),
|
|
620
|
+
sourceDatasetId: z.string().optional(),
|
|
621
|
+
filter: z.string().optional(),
|
|
622
|
+
});
|
|
623
|
+
export const FireworksUpdateDatasetRequestSchema = z.object({
|
|
624
|
+
displayName: z.string().optional(),
|
|
625
|
+
exampleCount: z.number().optional(),
|
|
626
|
+
externalUrl: z.string().optional(),
|
|
627
|
+
format: z.enum(["FORMAT_UNSPECIFIED", "CHAT", "COMPLETION", "RL"]).optional(),
|
|
628
|
+
sourceJobName: z.string().optional(),
|
|
629
|
+
});
|
|
630
|
+
export const FireworksDatasetGetUploadEndpointRequestSchema = z.object({
|
|
631
|
+
filenameToSize: z.record(z.string(), z.number()),
|
|
632
|
+
readMask: z.string().optional(),
|
|
633
|
+
});
|
|
634
|
+
export const FireworksDatasetValidateUploadRequestSchema = z
|
|
635
|
+
.object({})
|
|
636
|
+
.passthrough();
|
|
637
|
+
// ---------------------------------------------------------------------------
|
|
638
|
+
// Account management — users, API keys, secrets
|
|
639
|
+
// ---------------------------------------------------------------------------
|
|
640
|
+
export const FireworksCreateUserRequestSchema = z.object({
|
|
641
|
+
role: z.enum(["admin", "user", "contributor", "inference-user"]),
|
|
642
|
+
displayName: z.string().optional(),
|
|
643
|
+
email: z.string().optional(),
|
|
644
|
+
serviceAccount: z.boolean().optional(),
|
|
645
|
+
});
|
|
646
|
+
export const FireworksUpdateUserRequestSchema = z.object({
|
|
647
|
+
role: z.enum(["admin", "user", "contributor", "inference-user"]),
|
|
648
|
+
displayName: z.string().optional(),
|
|
649
|
+
email: z.string().optional(),
|
|
650
|
+
serviceAccount: z.boolean().optional(),
|
|
651
|
+
});
|
|
652
|
+
export const FireworksCreateApiKeyRequestSchema = z.object({
|
|
653
|
+
apiKey: z.object({
|
|
654
|
+
displayName: z.string().optional(),
|
|
655
|
+
expireTime: z.string().optional(),
|
|
656
|
+
}),
|
|
657
|
+
});
|
|
658
|
+
export const FireworksDeleteApiKeyRequestSchema = z.object({
|
|
659
|
+
keyId: z.string(),
|
|
660
|
+
});
|
|
661
|
+
export const FireworksCreateSecretRequestSchema = z.object({
|
|
662
|
+
keyName: z.string(),
|
|
663
|
+
value: z.string(),
|
|
664
|
+
name: z.string().optional(),
|
|
665
|
+
});
|
|
666
|
+
export const FireworksUpdateSecretRequestSchema = z.object({
|
|
667
|
+
keyName: z.string(),
|
|
668
|
+
value: z.string().optional(),
|
|
669
|
+
});
|
|
670
|
+
// ---------------------------------------------------------------------------
|
|
671
|
+
// Evaluators
|
|
672
|
+
// ---------------------------------------------------------------------------
|
|
673
|
+
export const FireworksCriterionSchema = z.object({
|
|
674
|
+
type: z.enum(["TYPE_UNSPECIFIED", "CODE_SNIPPETS"]).optional(),
|
|
675
|
+
name: z.string().optional(),
|
|
676
|
+
description: z.string().optional(),
|
|
677
|
+
codeSnippets: z
|
|
678
|
+
.object({
|
|
679
|
+
language: z.string().optional(),
|
|
680
|
+
fileContents: z.record(z.string(), z.string()).optional(),
|
|
681
|
+
entryFile: z.string().optional(),
|
|
682
|
+
entryFunc: z.string().optional(),
|
|
683
|
+
})
|
|
684
|
+
.optional(),
|
|
685
|
+
});
|
|
686
|
+
export const FireworksEvaluatorSourceSchema = z.object({
|
|
687
|
+
type: z
|
|
688
|
+
.enum(["TYPE_UNSPECIFIED", "TYPE_UPLOAD", "TYPE_GITHUB", "TYPE_TEMPORARY"])
|
|
689
|
+
.optional(),
|
|
690
|
+
githubRepositoryName: z.string().optional(),
|
|
691
|
+
});
|
|
692
|
+
export const FireworksCreateEvaluatorRequestSchema = z.object({
|
|
693
|
+
evaluatorId: z.string().optional(),
|
|
694
|
+
evaluator: z.object({
|
|
695
|
+
displayName: z.string().optional(),
|
|
696
|
+
description: z.string().optional(),
|
|
697
|
+
requirements: z.string().optional(),
|
|
698
|
+
entryPoint: z.string().optional(),
|
|
699
|
+
commitHash: z.string().optional(),
|
|
700
|
+
defaultDataset: z.string().optional(),
|
|
701
|
+
criteria: z.array(FireworksCriterionSchema).optional(),
|
|
702
|
+
source: FireworksEvaluatorSourceSchema.optional(),
|
|
703
|
+
}),
|
|
704
|
+
});
|
|
705
|
+
export const FireworksUpdateEvaluatorRequestSchema = z.object({
|
|
706
|
+
displayName: z.string().optional(),
|
|
707
|
+
description: z.string().optional(),
|
|
708
|
+
requirements: z.string().optional(),
|
|
709
|
+
entryPoint: z.string().optional(),
|
|
710
|
+
commitHash: z.string().optional(),
|
|
711
|
+
defaultDataset: z.string().optional(),
|
|
712
|
+
criteria: z.array(FireworksCriterionSchema).optional(),
|
|
713
|
+
source: FireworksEvaluatorSourceSchema.optional(),
|
|
714
|
+
});
|
|
715
|
+
export const FireworksGetUploadEndpointEvaluatorRequestSchema = z.object({
|
|
716
|
+
filenameToSize: z.record(z.string(), z.string()),
|
|
717
|
+
readMask: z.string().optional(),
|
|
718
|
+
});
|
|
719
|
+
// ---------------------------------------------------------------------------
|
|
720
|
+
// Evaluation Jobs
|
|
721
|
+
// ---------------------------------------------------------------------------
|
|
722
|
+
export const FireworksCreateEvaluationJobRequestSchema = z.object({
|
|
723
|
+
evaluationJobId: z.string().optional(),
|
|
724
|
+
leaderboardIds: z.array(z.string()).optional(),
|
|
725
|
+
evaluationJob: z.object({
|
|
726
|
+
displayName: z.string().optional(),
|
|
727
|
+
evaluator: z.string(),
|
|
728
|
+
inputDataset: z.string(),
|
|
729
|
+
outputDataset: z.string(),
|
|
730
|
+
outputStats: z.string().optional(),
|
|
731
|
+
awsS3Config: FireworksAwsS3ConfigSchema.optional(),
|
|
732
|
+
}),
|
|
733
|
+
});
|
|
734
|
+
// ---------------------------------------------------------------------------
|
|
735
|
+
// Empty schema (for delete endpoints with no payload)
|
|
736
|
+
// ---------------------------------------------------------------------------
|
|
737
|
+
export const FireworksEmptySchema = z.object({}).passthrough();
|
|
738
|
+
// ---------------------------------------------------------------------------
|
|
739
|
+
// Options
|
|
740
|
+
// ---------------------------------------------------------------------------
|
|
741
|
+
export const FireworksOptionsSchema = z.object({
|
|
742
|
+
apiKey: z.string().min(1),
|
|
743
|
+
baseURL: z.string().optional(),
|
|
744
|
+
audioBaseURL: z.string().optional(),
|
|
745
|
+
audioStreamingBaseURL: z.string().optional(),
|
|
746
|
+
timeout: z.number().int().positive().optional(),
|
|
747
|
+
fetch: z
|
|
748
|
+
.custom()
|
|
749
|
+
.optional(),
|
|
750
|
+
WebSocket: z
|
|
751
|
+
.custom()
|
|
752
|
+
.optional(),
|
|
753
|
+
});
|
|
754
|
+
//# sourceMappingURL=zod.js.map
|