@ai-sdk/fal 3.0.0-beta.9 → 3.0.0-canary.32
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 +202 -0
- package/README.md +2 -0
- package/dist/index.js +303 -233
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- package/src/fal-config.ts +2 -2
- package/src/{fal-image-options.ts → fal-image-model-options.ts} +5 -1
- package/src/fal-image-model.ts +23 -6
- package/src/fal-provider.ts +10 -10
- package/src/fal-speech-model-options.ts +21 -0
- package/src/fal-speech-model.ts +22 -24
- package/src/fal-transcription-model-options.ts +43 -0
- package/src/fal-transcription-model.ts +25 -49
- package/src/fal-video-model-options.ts +39 -0
- package/src/fal-video-model.ts +6 -41
- package/src/index.ts +4 -4
- package/dist/index.d.mts +0 -156
- package/dist/index.mjs +0 -1126
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,72 +1,66 @@
|
|
|
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
|
-
VERSION: () => VERSION,
|
|
24
|
-
createFal: () => createFal,
|
|
25
|
-
fal: () => fal
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/fal-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
withoutTrailingSlash,
|
|
7
|
+
withUserAgentSuffix
|
|
8
|
+
} from "@ai-sdk/provider-utils";
|
|
32
9
|
|
|
33
10
|
// src/fal-image-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
import {
|
|
12
|
+
combineHeaders,
|
|
13
|
+
convertImageModelFileToDataUri,
|
|
14
|
+
createBinaryResponseHandler,
|
|
15
|
+
createJsonErrorResponseHandler,
|
|
16
|
+
createJsonResponseHandler,
|
|
17
|
+
createStatusCodeErrorResponseHandler,
|
|
18
|
+
getFromApi,
|
|
19
|
+
parseProviderOptions,
|
|
20
|
+
postJsonToApi,
|
|
21
|
+
resolve,
|
|
22
|
+
serializeModelOptions,
|
|
23
|
+
WORKFLOW_SERIALIZE,
|
|
24
|
+
WORKFLOW_DESERIALIZE
|
|
25
|
+
} from "@ai-sdk/provider-utils";
|
|
26
|
+
import { z as z2 } from "zod/v4";
|
|
36
27
|
|
|
37
|
-
// src/fal-image-options.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
// src/fal-image-model-options.ts
|
|
29
|
+
import {
|
|
30
|
+
lazySchema,
|
|
31
|
+
zodSchema
|
|
32
|
+
} from "@ai-sdk/provider-utils";
|
|
33
|
+
import { z } from "zod/v4";
|
|
34
|
+
var falImageModelOptionsSchema = lazySchema(
|
|
35
|
+
() => zodSchema(
|
|
36
|
+
z.object({
|
|
43
37
|
/** @deprecated use prompt.images instead */
|
|
44
|
-
imageUrl:
|
|
38
|
+
imageUrl: z.string().nullish().meta({
|
|
45
39
|
deprecated: true,
|
|
46
40
|
description: "Use `prompt.images` instead"
|
|
47
41
|
}),
|
|
48
|
-
maskUrl:
|
|
49
|
-
guidanceScale:
|
|
50
|
-
numInferenceSteps:
|
|
51
|
-
enableSafetyChecker:
|
|
52
|
-
outputFormat:
|
|
53
|
-
syncMode:
|
|
54
|
-
strength:
|
|
55
|
-
acceleration:
|
|
56
|
-
safetyTolerance:
|
|
42
|
+
maskUrl: z.string().nullish().meta({ deprecated: true, description: "Use `prompt.mask` instead" }),
|
|
43
|
+
guidanceScale: z.number().min(1).max(20).nullish(),
|
|
44
|
+
numInferenceSteps: z.number().min(1).max(50).nullish(),
|
|
45
|
+
enableSafetyChecker: z.boolean().nullish(),
|
|
46
|
+
outputFormat: z.enum(["jpeg", "png"]).nullish(),
|
|
47
|
+
syncMode: z.boolean().nullish(),
|
|
48
|
+
strength: z.number().nullish(),
|
|
49
|
+
acceleration: z.enum(["none", "regular", "high"]).nullish(),
|
|
50
|
+
safetyTolerance: z.enum(["1", "2", "3", "4", "5", "6"]).or(z.number().min(1).max(6)).nullish(),
|
|
57
51
|
/**
|
|
58
52
|
* When true, converts multiple input images to `image_urls` array instead of `image_url` string.
|
|
59
53
|
*/
|
|
60
|
-
useMultipleImages:
|
|
54
|
+
useMultipleImages: z.boolean().nullish(),
|
|
61
55
|
// Deprecated snake_case versions
|
|
62
|
-
image_url:
|
|
63
|
-
mask_url:
|
|
64
|
-
guidance_scale:
|
|
65
|
-
num_inference_steps:
|
|
66
|
-
enable_safety_checker:
|
|
67
|
-
output_format:
|
|
68
|
-
sync_mode:
|
|
69
|
-
safety_tolerance:
|
|
56
|
+
image_url: z.string().nullish(),
|
|
57
|
+
mask_url: z.string().nullish(),
|
|
58
|
+
guidance_scale: z.number().min(1).max(20).nullish(),
|
|
59
|
+
num_inference_steps: z.number().min(1).max(50).nullish(),
|
|
60
|
+
enable_safety_checker: z.boolean().nullish(),
|
|
61
|
+
output_format: z.enum(["jpeg", "png"]).nullish(),
|
|
62
|
+
sync_mode: z.boolean().nullish(),
|
|
63
|
+
safety_tolerance: z.enum(["1", "2", "3", "4", "5", "6"]).or(z.number().min(1).max(6)).nullish()
|
|
70
64
|
}).passthrough().transform((data) => {
|
|
71
65
|
const result = {};
|
|
72
66
|
const deprecatedKeys = [];
|
|
@@ -133,7 +127,7 @@ var falImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
133
127
|
);
|
|
134
128
|
|
|
135
129
|
// src/fal-image-model.ts
|
|
136
|
-
var FalImageModel = class {
|
|
130
|
+
var FalImageModel = class _FalImageModel {
|
|
137
131
|
constructor(modelId, config) {
|
|
138
132
|
this.modelId = modelId;
|
|
139
133
|
this.config = config;
|
|
@@ -143,6 +137,15 @@ var FalImageModel = class {
|
|
|
143
137
|
get provider() {
|
|
144
138
|
return this.config.provider;
|
|
145
139
|
}
|
|
140
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
141
|
+
return serializeModelOptions({
|
|
142
|
+
modelId: model.modelId,
|
|
143
|
+
config: model.config
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
147
|
+
return new _FalImageModel(options.modelId, options.config);
|
|
148
|
+
}
|
|
146
149
|
async getArgs({
|
|
147
150
|
prompt,
|
|
148
151
|
n,
|
|
@@ -162,7 +165,7 @@ var FalImageModel = class {
|
|
|
162
165
|
} else if (aspectRatio) {
|
|
163
166
|
imageSize = convertAspectRatioToSize(aspectRatio);
|
|
164
167
|
}
|
|
165
|
-
const falOptions = await
|
|
168
|
+
const falOptions = await parseProviderOptions({
|
|
166
169
|
provider: "fal",
|
|
167
170
|
providerOptions,
|
|
168
171
|
schema: falImageModelOptionsSchema
|
|
@@ -177,10 +180,10 @@ var FalImageModel = class {
|
|
|
177
180
|
const useMultipleImages = (falOptions == null ? void 0 : falOptions.useMultipleImages) === true;
|
|
178
181
|
if (useMultipleImages) {
|
|
179
182
|
requestBody.image_urls = files.map(
|
|
180
|
-
(file) =>
|
|
183
|
+
(file) => convertImageModelFileToDataUri(file)
|
|
181
184
|
);
|
|
182
185
|
} else {
|
|
183
|
-
requestBody.image_url =
|
|
186
|
+
requestBody.image_url = convertImageModelFileToDataUri(files[0]);
|
|
184
187
|
if (files.length > 1) {
|
|
185
188
|
warnings.push({
|
|
186
189
|
type: "other",
|
|
@@ -190,7 +193,7 @@ var FalImageModel = class {
|
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
if (mask != null) {
|
|
193
|
-
requestBody.mask_url =
|
|
196
|
+
requestBody.mask_url = convertImageModelFileToDataUri(mask);
|
|
194
197
|
}
|
|
195
198
|
if (falOptions) {
|
|
196
199
|
const deprecatedKeys = "__deprecatedKeys" in falOptions ? falOptions.__deprecatedKeys : void 0;
|
|
@@ -231,15 +234,15 @@ var FalImageModel = class {
|
|
|
231
234
|
var _a, _b, _c;
|
|
232
235
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
233
236
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
234
|
-
const { value, responseHeaders } = await
|
|
237
|
+
const { value, responseHeaders } = await postJsonToApi({
|
|
235
238
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
236
|
-
headers:
|
|
237
|
-
await
|
|
239
|
+
headers: combineHeaders(
|
|
240
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
238
241
|
options.headers
|
|
239
242
|
),
|
|
240
243
|
body: requestBody,
|
|
241
244
|
failedResponseHandler: falFailedResponseHandler,
|
|
242
|
-
successfulResponseHandler:
|
|
245
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
243
246
|
falImageResponseSchema
|
|
244
247
|
),
|
|
245
248
|
abortSignal: options.abortSignal,
|
|
@@ -273,7 +276,7 @@ var FalImageModel = class {
|
|
|
273
276
|
images: targetImages.map((image, index) => {
|
|
274
277
|
var _a2;
|
|
275
278
|
const {
|
|
276
|
-
url,
|
|
279
|
+
url: _url,
|
|
277
280
|
content_type: contentType,
|
|
278
281
|
file_name: fileName,
|
|
279
282
|
file_data: fileData,
|
|
@@ -298,13 +301,13 @@ var FalImageModel = class {
|
|
|
298
301
|
};
|
|
299
302
|
}
|
|
300
303
|
async downloadImage(url, abortSignal) {
|
|
301
|
-
const { value: response } = await
|
|
304
|
+
const { value: response } = await getFromApi({
|
|
302
305
|
url,
|
|
303
306
|
// No specific headers should be needed for this request as it's a
|
|
304
307
|
// generated image provided by fal.ai.
|
|
305
308
|
abortSignal,
|
|
306
|
-
failedResponseHandler:
|
|
307
|
-
successfulResponseHandler:
|
|
309
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
310
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
308
311
|
fetch: this.config.fetch
|
|
309
312
|
});
|
|
310
313
|
return response;
|
|
@@ -338,60 +341,60 @@ function convertAspectRatioToSize(aspectRatio) {
|
|
|
338
341
|
}
|
|
339
342
|
return void 0;
|
|
340
343
|
}
|
|
341
|
-
var falValidationErrorSchema =
|
|
342
|
-
detail:
|
|
343
|
-
|
|
344
|
-
loc:
|
|
345
|
-
msg:
|
|
346
|
-
type:
|
|
344
|
+
var falValidationErrorSchema = z2.object({
|
|
345
|
+
detail: z2.array(
|
|
346
|
+
z2.object({
|
|
347
|
+
loc: z2.array(z2.string()),
|
|
348
|
+
msg: z2.string(),
|
|
349
|
+
type: z2.string()
|
|
347
350
|
})
|
|
348
351
|
)
|
|
349
352
|
});
|
|
350
|
-
var falHttpErrorSchema =
|
|
351
|
-
message:
|
|
353
|
+
var falHttpErrorSchema = z2.object({
|
|
354
|
+
message: z2.string()
|
|
352
355
|
});
|
|
353
|
-
var falErrorSchema =
|
|
354
|
-
var falImageSchema =
|
|
355
|
-
url:
|
|
356
|
-
width:
|
|
357
|
-
height:
|
|
356
|
+
var falErrorSchema = z2.union([falValidationErrorSchema, falHttpErrorSchema]);
|
|
357
|
+
var falImageSchema = z2.object({
|
|
358
|
+
url: z2.string(),
|
|
359
|
+
width: z2.number().nullish(),
|
|
360
|
+
height: z2.number().nullish(),
|
|
358
361
|
// e.g. https://fal.ai/models/fal-ai/fashn/tryon/v1.6/api#schema-output
|
|
359
|
-
content_type:
|
|
362
|
+
content_type: z2.string().nullish(),
|
|
360
363
|
// e.g. https://fal.ai/models/fal-ai/flowedit/api#schema-output
|
|
361
|
-
file_name:
|
|
362
|
-
file_data:
|
|
363
|
-
file_size:
|
|
364
|
+
file_name: z2.string().nullish(),
|
|
365
|
+
file_data: z2.string().optional(),
|
|
366
|
+
file_size: z2.number().nullish()
|
|
364
367
|
});
|
|
365
|
-
var loraFileSchema =
|
|
366
|
-
url:
|
|
367
|
-
content_type:
|
|
368
|
-
file_name:
|
|
369
|
-
file_data:
|
|
370
|
-
file_size:
|
|
368
|
+
var loraFileSchema = z2.object({
|
|
369
|
+
url: z2.string(),
|
|
370
|
+
content_type: z2.string().optional(),
|
|
371
|
+
file_name: z2.string().nullable().optional(),
|
|
372
|
+
file_data: z2.string().optional(),
|
|
373
|
+
file_size: z2.number().nullable().optional()
|
|
371
374
|
});
|
|
372
|
-
var commonResponseSchema =
|
|
373
|
-
timings:
|
|
374
|
-
inference:
|
|
375
|
+
var commonResponseSchema = z2.object({
|
|
376
|
+
timings: z2.object({
|
|
377
|
+
inference: z2.number().optional()
|
|
375
378
|
}).optional(),
|
|
376
|
-
seed:
|
|
377
|
-
has_nsfw_concepts:
|
|
378
|
-
prompt:
|
|
379
|
+
seed: z2.number().optional(),
|
|
380
|
+
has_nsfw_concepts: z2.array(z2.boolean()).optional(),
|
|
381
|
+
prompt: z2.string().optional(),
|
|
379
382
|
// https://fal.ai/models/fal-ai/lcm/api#schema-output
|
|
380
|
-
nsfw_content_detected:
|
|
381
|
-
num_inference_steps:
|
|
383
|
+
nsfw_content_detected: z2.array(z2.boolean()).optional(),
|
|
384
|
+
num_inference_steps: z2.number().optional(),
|
|
382
385
|
// https://fal.ai/models/fal-ai/lora/api#schema-output
|
|
383
386
|
debug_latents: loraFileSchema.optional(),
|
|
384
387
|
debug_per_pass_latents: loraFileSchema.optional()
|
|
385
388
|
});
|
|
386
|
-
var base =
|
|
387
|
-
var falImageResponseSchema =
|
|
388
|
-
base.extend({ images:
|
|
389
|
+
var base = z2.looseObject(commonResponseSchema.shape);
|
|
390
|
+
var falImageResponseSchema = z2.union([
|
|
391
|
+
base.extend({ images: z2.array(falImageSchema) }),
|
|
389
392
|
base.extend({ image: falImageSchema })
|
|
390
|
-
]).transform((v) => "images" in v ? v : { ...v, images: [v.image] }).pipe(base.extend({ images:
|
|
393
|
+
]).transform((v) => "images" in v ? v : { ...v, images: [v.image] }).pipe(base.extend({ images: z2.array(falImageSchema) }));
|
|
391
394
|
function isValidationError(error) {
|
|
392
395
|
return falValidationErrorSchema.safeParse(error).success;
|
|
393
396
|
}
|
|
394
|
-
var falFailedResponseHandler =
|
|
397
|
+
var falFailedResponseHandler = createJsonErrorResponseHandler({
|
|
395
398
|
errorSchema: falErrorSchema,
|
|
396
399
|
errorToMessage: (error) => {
|
|
397
400
|
var _a;
|
|
@@ -403,54 +406,71 @@ var falFailedResponseHandler = (0, import_provider_utils2.createJsonErrorRespons
|
|
|
403
406
|
});
|
|
404
407
|
|
|
405
408
|
// src/fal-transcription-model.ts
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
import {
|
|
410
|
+
AISDKError
|
|
411
|
+
} from "@ai-sdk/provider";
|
|
412
|
+
import {
|
|
413
|
+
combineHeaders as combineHeaders2,
|
|
414
|
+
convertUint8ArrayToBase64,
|
|
415
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
|
|
416
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
417
|
+
delay,
|
|
418
|
+
getFromApi as getFromApi2,
|
|
419
|
+
parseProviderOptions as parseProviderOptions2,
|
|
420
|
+
postJsonToApi as postJsonToApi2,
|
|
421
|
+
serializeModelOptions as serializeModelOptions2,
|
|
422
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
423
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
424
|
+
} from "@ai-sdk/provider-utils";
|
|
425
|
+
import { z as z5 } from "zod/v4";
|
|
409
426
|
|
|
410
427
|
// src/fal-error.ts
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
var falErrorDataSchema =
|
|
414
|
-
error:
|
|
415
|
-
message:
|
|
416
|
-
code:
|
|
428
|
+
import { z as z3 } from "zod/v4";
|
|
429
|
+
import { createJsonErrorResponseHandler as createJsonErrorResponseHandler2 } from "@ai-sdk/provider-utils";
|
|
430
|
+
var falErrorDataSchema = z3.object({
|
|
431
|
+
error: z3.object({
|
|
432
|
+
message: z3.string(),
|
|
433
|
+
code: z3.number()
|
|
417
434
|
})
|
|
418
435
|
});
|
|
419
|
-
var falFailedResponseHandler2 = (
|
|
436
|
+
var falFailedResponseHandler2 = createJsonErrorResponseHandler2({
|
|
420
437
|
errorSchema: falErrorDataSchema,
|
|
421
438
|
errorToMessage: (data) => data.error.message
|
|
422
439
|
});
|
|
423
440
|
|
|
424
|
-
// src/fal-transcription-model.ts
|
|
425
|
-
|
|
441
|
+
// src/fal-transcription-model-options.ts
|
|
442
|
+
import { z as z4 } from "zod/v4";
|
|
443
|
+
var falTranscriptionModelOptionsSchema = z4.object({
|
|
426
444
|
/**
|
|
427
445
|
* Language of the audio file. If set to null, the language will be automatically detected. Defaults to null.
|
|
428
446
|
*
|
|
429
447
|
* If translate is selected as the task, the audio will be translated to English, regardless of the language selected.
|
|
430
448
|
*/
|
|
431
|
-
language:
|
|
449
|
+
language: z4.union([z4.enum(["en"]), z4.string()]).nullish().default("en"),
|
|
432
450
|
/**
|
|
433
451
|
* Whether to diarize the audio file. Defaults to true.
|
|
434
452
|
*/
|
|
435
|
-
diarize:
|
|
453
|
+
diarize: z4.boolean().nullish().default(true),
|
|
436
454
|
/**
|
|
437
455
|
* Level of the chunks to return. Either segment or word. Default value: "segment"
|
|
438
456
|
*/
|
|
439
|
-
chunkLevel:
|
|
457
|
+
chunkLevel: z4.enum(["segment", "word"]).nullish().default("segment"),
|
|
440
458
|
/**
|
|
441
459
|
* Version of the model to use. All of the models are the Whisper large variant. Default value: "3"
|
|
442
460
|
*/
|
|
443
|
-
version:
|
|
461
|
+
version: z4.enum(["3"]).nullish().default("3"),
|
|
444
462
|
/**
|
|
445
463
|
* Default value: 64
|
|
446
464
|
*/
|
|
447
|
-
batchSize:
|
|
465
|
+
batchSize: z4.number().nullish().default(64),
|
|
448
466
|
/**
|
|
449
467
|
* Number of speakers in the audio file. Defaults to null. If not provided, the number of speakers will be automatically detected.
|
|
450
468
|
*/
|
|
451
|
-
numSpeakers:
|
|
469
|
+
numSpeakers: z4.number().nullable().nullish()
|
|
452
470
|
});
|
|
453
|
-
|
|
471
|
+
|
|
472
|
+
// src/fal-transcription-model.ts
|
|
473
|
+
var FalTranscriptionModel = class _FalTranscriptionModel {
|
|
454
474
|
constructor(modelId, config) {
|
|
455
475
|
this.modelId = modelId;
|
|
456
476
|
this.config = config;
|
|
@@ -459,12 +479,21 @@ var FalTranscriptionModel = class {
|
|
|
459
479
|
get provider() {
|
|
460
480
|
return this.config.provider;
|
|
461
481
|
}
|
|
482
|
+
static [WORKFLOW_SERIALIZE2](model) {
|
|
483
|
+
return serializeModelOptions2({
|
|
484
|
+
modelId: model.modelId,
|
|
485
|
+
config: model.config
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
static [WORKFLOW_DESERIALIZE2](options) {
|
|
489
|
+
return new _FalTranscriptionModel(options.modelId, options.config);
|
|
490
|
+
}
|
|
462
491
|
async getArgs({
|
|
463
492
|
providerOptions
|
|
464
493
|
}) {
|
|
465
494
|
var _a, _b, _c;
|
|
466
495
|
const warnings = [];
|
|
467
|
-
const falOptions = await (
|
|
496
|
+
const falOptions = await parseProviderOptions2({
|
|
468
497
|
provider: "fal",
|
|
469
498
|
providerOptions,
|
|
470
499
|
schema: falTranscriptionModelOptionsSchema
|
|
@@ -492,23 +521,23 @@ var FalTranscriptionModel = class {
|
|
|
492
521
|
};
|
|
493
522
|
}
|
|
494
523
|
async doGenerate(options) {
|
|
495
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
524
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
496
525
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
497
526
|
const { body, warnings } = await this.getArgs(options);
|
|
498
|
-
const base64Audio = typeof options.audio === "string" ? options.audio :
|
|
527
|
+
const base64Audio = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase64(options.audio);
|
|
499
528
|
const audioUrl = `data:${options.mediaType};base64,${base64Audio}`;
|
|
500
|
-
const { value: queueResponse } = await (
|
|
529
|
+
const { value: queueResponse } = await postJsonToApi2({
|
|
501
530
|
url: this.config.url({
|
|
502
531
|
path: `https://queue.fal.run/fal-ai/${this.modelId}`,
|
|
503
532
|
modelId: this.modelId
|
|
504
533
|
}),
|
|
505
|
-
headers: (
|
|
534
|
+
headers: combineHeaders2((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
506
535
|
body: {
|
|
507
536
|
...body,
|
|
508
537
|
audio_url: audioUrl
|
|
509
538
|
},
|
|
510
539
|
failedResponseHandler: falFailedResponseHandler2,
|
|
511
|
-
successfulResponseHandler: (
|
|
540
|
+
successfulResponseHandler: createJsonResponseHandler2(falJobResponseSchema),
|
|
512
541
|
abortSignal: options.abortSignal,
|
|
513
542
|
fetch: this.config.fetch
|
|
514
543
|
});
|
|
@@ -524,12 +553,12 @@ var FalTranscriptionModel = class {
|
|
|
524
553
|
value: statusResponse,
|
|
525
554
|
responseHeaders: statusHeaders,
|
|
526
555
|
rawValue: statusRawResponse
|
|
527
|
-
} = await (
|
|
556
|
+
} = await getFromApi2({
|
|
528
557
|
url: this.config.url({
|
|
529
558
|
path: `https://queue.fal.run/fal-ai/${this.modelId}/requests/${queueResponse.request_id}`,
|
|
530
559
|
modelId: this.modelId
|
|
531
560
|
}),
|
|
532
|
-
headers: (
|
|
561
|
+
headers: combineHeaders2((_g = (_f = this.config).headers) == null ? void 0 : _g.call(_f), options.headers),
|
|
533
562
|
failedResponseHandler: async ({
|
|
534
563
|
requestBodyValues,
|
|
535
564
|
response: response2,
|
|
@@ -544,12 +573,12 @@ var FalTranscriptionModel = class {
|
|
|
544
573
|
responseHeaders: {}
|
|
545
574
|
};
|
|
546
575
|
}
|
|
547
|
-
return (
|
|
576
|
+
return createJsonErrorResponseHandler3({
|
|
548
577
|
errorSchema: falErrorDataSchema,
|
|
549
578
|
errorToMessage: (data) => data.error.message
|
|
550
579
|
})({ requestBodyValues, response: response2, url });
|
|
551
580
|
},
|
|
552
|
-
successfulResponseHandler: (
|
|
581
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
553
582
|
falTranscriptionResponseSchema
|
|
554
583
|
),
|
|
555
584
|
abortSignal: options.abortSignal,
|
|
@@ -566,26 +595,26 @@ var FalTranscriptionModel = class {
|
|
|
566
595
|
}
|
|
567
596
|
}
|
|
568
597
|
if (Date.now() - startTime > timeoutMs) {
|
|
569
|
-
throw new
|
|
598
|
+
throw new AISDKError({
|
|
570
599
|
message: "Transcription request timed out after 60 seconds",
|
|
571
600
|
name: "TranscriptionRequestTimedOut",
|
|
572
601
|
cause: response
|
|
573
602
|
});
|
|
574
603
|
}
|
|
575
|
-
await
|
|
604
|
+
await delay(pollIntervalMs);
|
|
576
605
|
}
|
|
577
606
|
return {
|
|
578
607
|
text: response.text,
|
|
579
|
-
segments: (
|
|
608
|
+
segments: (_i = (_h = response.chunks) == null ? void 0 : _h.map((chunk) => {
|
|
580
609
|
var _a2, _b2, _c2, _d2;
|
|
581
610
|
return {
|
|
582
611
|
text: chunk.text,
|
|
583
612
|
startSecond: (_b2 = (_a2 = chunk.timestamp) == null ? void 0 : _a2.at(0)) != null ? _b2 : 0,
|
|
584
613
|
endSecond: (_d2 = (_c2 = chunk.timestamp) == null ? void 0 : _c2.at(1)) != null ? _d2 : 0
|
|
585
614
|
};
|
|
586
|
-
})) != null ?
|
|
587
|
-
language: (
|
|
588
|
-
durationInSeconds: (
|
|
615
|
+
})) != null ? _i : [],
|
|
616
|
+
language: (_k = (_j = response.inferred_languages) == null ? void 0 : _j.at(0)) != null ? _k : void 0,
|
|
617
|
+
durationInSeconds: (_o = (_n = (_m = (_l = response.chunks) == null ? void 0 : _l.at(-1)) == null ? void 0 : _m.timestamp) == null ? void 0 : _n.at(1)) != null ? _o : void 0,
|
|
589
618
|
warnings,
|
|
590
619
|
response: {
|
|
591
620
|
timestamp: currentDate,
|
|
@@ -596,23 +625,37 @@ var FalTranscriptionModel = class {
|
|
|
596
625
|
};
|
|
597
626
|
}
|
|
598
627
|
};
|
|
599
|
-
var falJobResponseSchema =
|
|
600
|
-
request_id:
|
|
628
|
+
var falJobResponseSchema = z5.object({
|
|
629
|
+
request_id: z5.string().nullish()
|
|
601
630
|
});
|
|
602
|
-
var falTranscriptionResponseSchema =
|
|
603
|
-
text:
|
|
604
|
-
chunks:
|
|
605
|
-
|
|
606
|
-
text:
|
|
607
|
-
timestamp:
|
|
631
|
+
var falTranscriptionResponseSchema = z5.object({
|
|
632
|
+
text: z5.string(),
|
|
633
|
+
chunks: z5.array(
|
|
634
|
+
z5.object({
|
|
635
|
+
text: z5.string(),
|
|
636
|
+
timestamp: z5.array(z5.number()).nullish()
|
|
608
637
|
})
|
|
609
638
|
).nullish(),
|
|
610
|
-
inferred_languages:
|
|
639
|
+
inferred_languages: z5.array(z5.string()).nullish()
|
|
611
640
|
});
|
|
612
641
|
|
|
613
642
|
// src/fal-speech-model.ts
|
|
614
|
-
|
|
615
|
-
|
|
643
|
+
import {
|
|
644
|
+
combineHeaders as combineHeaders3,
|
|
645
|
+
createBinaryResponseHandler as createBinaryResponseHandler2,
|
|
646
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
647
|
+
createStatusCodeErrorResponseHandler as createStatusCodeErrorResponseHandler2,
|
|
648
|
+
getFromApi as getFromApi3,
|
|
649
|
+
parseProviderOptions as parseProviderOptions3,
|
|
650
|
+
postJsonToApi as postJsonToApi3,
|
|
651
|
+
serializeModelOptions as serializeModelOptions3,
|
|
652
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
653
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
|
|
654
|
+
} from "@ai-sdk/provider-utils";
|
|
655
|
+
import { z as z7 } from "zod/v4";
|
|
656
|
+
|
|
657
|
+
// src/fal-speech-model-options.ts
|
|
658
|
+
import { z as z6 } from "zod/v4";
|
|
616
659
|
|
|
617
660
|
// src/fal-api-types.ts
|
|
618
661
|
var FAL_LANGUAGE_BOOSTS = [
|
|
@@ -652,21 +695,23 @@ var FAL_EMOTIONS = [
|
|
|
652
695
|
"neutral"
|
|
653
696
|
];
|
|
654
697
|
|
|
655
|
-
// src/fal-speech-model.ts
|
|
656
|
-
var falSpeechModelOptionsSchema =
|
|
657
|
-
voice_setting:
|
|
658
|
-
speed:
|
|
659
|
-
vol:
|
|
660
|
-
voice_id:
|
|
661
|
-
pitch:
|
|
662
|
-
english_normalization:
|
|
663
|
-
emotion:
|
|
698
|
+
// src/fal-speech-model-options.ts
|
|
699
|
+
var falSpeechModelOptionsSchema = z6.looseObject({
|
|
700
|
+
voice_setting: z6.object({
|
|
701
|
+
speed: z6.number().nullish(),
|
|
702
|
+
vol: z6.number().nullish(),
|
|
703
|
+
voice_id: z6.string().nullish(),
|
|
704
|
+
pitch: z6.number().nullish(),
|
|
705
|
+
english_normalization: z6.boolean().nullish(),
|
|
706
|
+
emotion: z6.enum(FAL_EMOTIONS).nullish()
|
|
664
707
|
}).partial().nullish(),
|
|
665
|
-
audio_setting:
|
|
666
|
-
language_boost:
|
|
667
|
-
pronunciation_dict:
|
|
708
|
+
audio_setting: z6.record(z6.string(), z6.unknown()).nullish(),
|
|
709
|
+
language_boost: z6.enum(FAL_LANGUAGE_BOOSTS).nullish(),
|
|
710
|
+
pronunciation_dict: z6.record(z6.string(), z6.string()).nullish()
|
|
668
711
|
});
|
|
669
|
-
|
|
712
|
+
|
|
713
|
+
// src/fal-speech-model.ts
|
|
714
|
+
var FalSpeechModel = class _FalSpeechModel {
|
|
670
715
|
constructor(modelId, config) {
|
|
671
716
|
this.modelId = modelId;
|
|
672
717
|
this.config = config;
|
|
@@ -675,6 +720,15 @@ var FalSpeechModel = class {
|
|
|
675
720
|
get provider() {
|
|
676
721
|
return this.config.provider;
|
|
677
722
|
}
|
|
723
|
+
static [WORKFLOW_SERIALIZE3](model) {
|
|
724
|
+
return serializeModelOptions3({
|
|
725
|
+
modelId: model.modelId,
|
|
726
|
+
config: model.config
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
static [WORKFLOW_DESERIALIZE3](options) {
|
|
730
|
+
return new _FalSpeechModel(options.modelId, options.config);
|
|
731
|
+
}
|
|
678
732
|
async getArgs({
|
|
679
733
|
text,
|
|
680
734
|
voice,
|
|
@@ -684,7 +738,7 @@ var FalSpeechModel = class {
|
|
|
684
738
|
providerOptions
|
|
685
739
|
}) {
|
|
686
740
|
const warnings = [];
|
|
687
|
-
const falOptions = await (
|
|
741
|
+
const falOptions = await parseProviderOptions3({
|
|
688
742
|
provider: "fal",
|
|
689
743
|
providerOptions,
|
|
690
744
|
schema: falSpeechModelOptionsSchema
|
|
@@ -713,32 +767,32 @@ var FalSpeechModel = class {
|
|
|
713
767
|
return { requestBody, warnings };
|
|
714
768
|
}
|
|
715
769
|
async doGenerate(options) {
|
|
716
|
-
var _a, _b, _c;
|
|
770
|
+
var _a, _b, _c, _d, _e;
|
|
717
771
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
718
772
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
719
773
|
const {
|
|
720
774
|
value: json,
|
|
721
775
|
responseHeaders,
|
|
722
776
|
rawValue
|
|
723
|
-
} = await (
|
|
777
|
+
} = await postJsonToApi3({
|
|
724
778
|
url: this.config.url({
|
|
725
779
|
path: `https://fal.run/${this.modelId}`,
|
|
726
780
|
modelId: this.modelId
|
|
727
781
|
}),
|
|
728
|
-
headers: (
|
|
782
|
+
headers: combineHeaders3((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
729
783
|
body: requestBody,
|
|
730
784
|
failedResponseHandler: falFailedResponseHandler2,
|
|
731
|
-
successfulResponseHandler: (
|
|
785
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
732
786
|
falSpeechResponseSchema
|
|
733
787
|
),
|
|
734
788
|
abortSignal: options.abortSignal,
|
|
735
789
|
fetch: this.config.fetch
|
|
736
790
|
});
|
|
737
791
|
const audioUrl = json.audio.url;
|
|
738
|
-
const { value: audio } = await (
|
|
792
|
+
const { value: audio } = await getFromApi3({
|
|
739
793
|
url: audioUrl,
|
|
740
|
-
failedResponseHandler: (
|
|
741
|
-
successfulResponseHandler: (
|
|
794
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler2(),
|
|
795
|
+
successfulResponseHandler: createBinaryResponseHandler2(),
|
|
742
796
|
abortSignal: options.abortSignal,
|
|
743
797
|
fetch: this.config.fetch
|
|
744
798
|
});
|
|
@@ -757,34 +811,51 @@ var FalSpeechModel = class {
|
|
|
757
811
|
};
|
|
758
812
|
}
|
|
759
813
|
};
|
|
760
|
-
var falSpeechResponseSchema =
|
|
761
|
-
audio:
|
|
762
|
-
duration_ms:
|
|
763
|
-
request_id:
|
|
814
|
+
var falSpeechResponseSchema = z7.object({
|
|
815
|
+
audio: z7.object({ url: z7.string() }),
|
|
816
|
+
duration_ms: z7.number().optional(),
|
|
817
|
+
request_id: z7.string().optional()
|
|
764
818
|
});
|
|
765
819
|
|
|
766
820
|
// src/fal-video-model.ts
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
821
|
+
import {
|
|
822
|
+
AISDKError as AISDKError2
|
|
823
|
+
} from "@ai-sdk/provider";
|
|
824
|
+
import {
|
|
825
|
+
combineHeaders as combineHeaders4,
|
|
826
|
+
convertImageModelFileToDataUri as convertImageModelFileToDataUri2,
|
|
827
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
|
|
828
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
829
|
+
delay as delay2,
|
|
830
|
+
getFromApi as getFromApi4,
|
|
831
|
+
parseProviderOptions as parseProviderOptions4,
|
|
832
|
+
postJsonToApi as postJsonToApi4
|
|
833
|
+
} from "@ai-sdk/provider-utils";
|
|
834
|
+
import { z as z9 } from "zod/v4";
|
|
835
|
+
|
|
836
|
+
// src/fal-video-model-options.ts
|
|
837
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
838
|
+
import { z as z8 } from "zod/v4";
|
|
839
|
+
var falVideoModelOptionsSchema = lazySchema2(
|
|
840
|
+
() => zodSchema2(
|
|
841
|
+
z8.object({
|
|
773
842
|
// Video loop - only for Luma models
|
|
774
|
-
loop:
|
|
843
|
+
loop: z8.boolean().nullish(),
|
|
775
844
|
// Motion strength (provider-specific)
|
|
776
|
-
motionStrength:
|
|
845
|
+
motionStrength: z8.number().min(0).max(1).nullish(),
|
|
777
846
|
// Polling configuration
|
|
778
|
-
pollIntervalMs:
|
|
779
|
-
pollTimeoutMs:
|
|
847
|
+
pollIntervalMs: z8.number().positive().nullish(),
|
|
848
|
+
pollTimeoutMs: z8.number().positive().nullish(),
|
|
780
849
|
// Resolution (model-specific, e.g., '480p', '720p', '1080p')
|
|
781
|
-
resolution:
|
|
850
|
+
resolution: z8.string().nullish(),
|
|
782
851
|
// Model-specific parameters
|
|
783
|
-
negativePrompt:
|
|
784
|
-
promptOptimizer:
|
|
852
|
+
negativePrompt: z8.string().nullish(),
|
|
853
|
+
promptOptimizer: z8.boolean().nullish()
|
|
785
854
|
}).passthrough()
|
|
786
855
|
)
|
|
787
856
|
);
|
|
857
|
+
|
|
858
|
+
// src/fal-video-model.ts
|
|
788
859
|
var FalVideoModel = class {
|
|
789
860
|
constructor(modelId, config) {
|
|
790
861
|
this.modelId = modelId;
|
|
@@ -800,10 +871,10 @@ var FalVideoModel = class {
|
|
|
800
871
|
return this.modelId.replace(/^fal-ai\//, "").replace(/^fal\//, "");
|
|
801
872
|
}
|
|
802
873
|
async doGenerate(options) {
|
|
803
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
874
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
804
875
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
805
876
|
const warnings = [];
|
|
806
|
-
const falOptions = await (
|
|
877
|
+
const falOptions = await parseProviderOptions4({
|
|
807
878
|
provider: "fal",
|
|
808
879
|
providerOptions: options.providerOptions,
|
|
809
880
|
schema: falVideoModelOptionsSchema
|
|
@@ -816,7 +887,7 @@ var FalVideoModel = class {
|
|
|
816
887
|
if (options.image.type === "url") {
|
|
817
888
|
body.image_url = options.image.url;
|
|
818
889
|
} else {
|
|
819
|
-
body.image_url = (
|
|
890
|
+
body.image_url = convertImageModelFileToDataUri2(options.image);
|
|
820
891
|
}
|
|
821
892
|
}
|
|
822
893
|
if (options.aspectRatio) {
|
|
@@ -859,38 +930,38 @@ var FalVideoModel = class {
|
|
|
859
930
|
}
|
|
860
931
|
}
|
|
861
932
|
}
|
|
862
|
-
const { value: queueResponse } = await (
|
|
933
|
+
const { value: queueResponse } = await postJsonToApi4({
|
|
863
934
|
url: this.config.url({
|
|
864
935
|
path: `https://queue.fal.run/fal-ai/${this.normalizedModelId}`,
|
|
865
936
|
modelId: this.modelId
|
|
866
937
|
}),
|
|
867
|
-
headers: (
|
|
938
|
+
headers: combineHeaders4((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
868
939
|
body,
|
|
869
940
|
failedResponseHandler: falFailedResponseHandler2,
|
|
870
|
-
successfulResponseHandler: (
|
|
941
|
+
successfulResponseHandler: createJsonResponseHandler4(falJobResponseSchema2),
|
|
871
942
|
abortSignal: options.abortSignal,
|
|
872
943
|
fetch: this.config.fetch
|
|
873
944
|
});
|
|
874
945
|
const responseUrl = queueResponse.response_url;
|
|
875
946
|
if (!responseUrl) {
|
|
876
|
-
throw new
|
|
947
|
+
throw new AISDKError2({
|
|
877
948
|
name: "FAL_VIDEO_GENERATION_ERROR",
|
|
878
949
|
message: "No response URL returned from queue endpoint"
|
|
879
950
|
});
|
|
880
951
|
}
|
|
881
|
-
const pollIntervalMs = (
|
|
882
|
-
const pollTimeoutMs = (
|
|
952
|
+
const pollIntervalMs = (_f = falOptions == null ? void 0 : falOptions.pollIntervalMs) != null ? _f : 2e3;
|
|
953
|
+
const pollTimeoutMs = (_g = falOptions == null ? void 0 : falOptions.pollTimeoutMs) != null ? _g : 3e5;
|
|
883
954
|
const startTime = Date.now();
|
|
884
955
|
let response;
|
|
885
956
|
let responseHeaders;
|
|
886
957
|
while (true) {
|
|
887
958
|
try {
|
|
888
|
-
const { value: statusResponse, responseHeaders: statusHeaders } = await (
|
|
959
|
+
const { value: statusResponse, responseHeaders: statusHeaders } = await getFromApi4({
|
|
889
960
|
url: this.config.url({
|
|
890
961
|
path: responseUrl,
|
|
891
962
|
modelId: this.modelId
|
|
892
963
|
}),
|
|
893
|
-
headers: (
|
|
964
|
+
headers: combineHeaders4((_i = (_h = this.config).headers) == null ? void 0 : _i.call(_h), options.headers),
|
|
894
965
|
failedResponseHandler: async ({
|
|
895
966
|
response: response2,
|
|
896
967
|
url,
|
|
@@ -904,12 +975,12 @@ var FalVideoModel = class {
|
|
|
904
975
|
responseHeaders: {}
|
|
905
976
|
};
|
|
906
977
|
}
|
|
907
|
-
return (
|
|
978
|
+
return createJsonErrorResponseHandler4({
|
|
908
979
|
errorSchema: falErrorDataSchema,
|
|
909
980
|
errorToMessage: (data) => data.error.message
|
|
910
981
|
})({ response: response2, url, requestBodyValues });
|
|
911
982
|
},
|
|
912
|
-
successfulResponseHandler: (
|
|
983
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
913
984
|
falVideoResponseSchema
|
|
914
985
|
),
|
|
915
986
|
abortSignal: options.abortSignal,
|
|
@@ -925,22 +996,22 @@ var FalVideoModel = class {
|
|
|
925
996
|
}
|
|
926
997
|
}
|
|
927
998
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
928
|
-
throw new
|
|
999
|
+
throw new AISDKError2({
|
|
929
1000
|
name: "FAL_VIDEO_GENERATION_TIMEOUT",
|
|
930
1001
|
message: `Video generation request timed out after ${pollTimeoutMs}ms`
|
|
931
1002
|
});
|
|
932
1003
|
}
|
|
933
|
-
await (
|
|
934
|
-
if ((
|
|
935
|
-
throw new
|
|
1004
|
+
await delay2(pollIntervalMs);
|
|
1005
|
+
if ((_j = options.abortSignal) == null ? void 0 : _j.aborted) {
|
|
1006
|
+
throw new AISDKError2({
|
|
936
1007
|
name: "FAL_VIDEO_GENERATION_ABORTED",
|
|
937
1008
|
message: "Video generation request was aborted"
|
|
938
1009
|
});
|
|
939
1010
|
}
|
|
940
1011
|
}
|
|
941
|
-
const videoUrl = (
|
|
1012
|
+
const videoUrl = (_k = response.video) == null ? void 0 : _k.url;
|
|
942
1013
|
if (!videoUrl || !response.video) {
|
|
943
|
-
throw new
|
|
1014
|
+
throw new AISDKError2({
|
|
944
1015
|
name: "FAL_VIDEO_GENERATION_ERROR",
|
|
945
1016
|
message: "No video URL in response"
|
|
946
1017
|
});
|
|
@@ -980,29 +1051,29 @@ var FalVideoModel = class {
|
|
|
980
1051
|
};
|
|
981
1052
|
}
|
|
982
1053
|
};
|
|
983
|
-
var falJobResponseSchema2 =
|
|
984
|
-
request_id:
|
|
985
|
-
response_url:
|
|
1054
|
+
var falJobResponseSchema2 = z9.object({
|
|
1055
|
+
request_id: z9.string().nullish(),
|
|
1056
|
+
response_url: z9.string().nullish()
|
|
986
1057
|
});
|
|
987
|
-
var falVideoResponseSchema =
|
|
988
|
-
video:
|
|
989
|
-
url:
|
|
990
|
-
width:
|
|
991
|
-
height:
|
|
992
|
-
duration:
|
|
993
|
-
fps:
|
|
994
|
-
content_type:
|
|
1058
|
+
var falVideoResponseSchema = z9.object({
|
|
1059
|
+
video: z9.object({
|
|
1060
|
+
url: z9.string(),
|
|
1061
|
+
width: z9.number().nullish(),
|
|
1062
|
+
height: z9.number().nullish(),
|
|
1063
|
+
duration: z9.number().nullish(),
|
|
1064
|
+
fps: z9.number().nullish(),
|
|
1065
|
+
content_type: z9.string().nullish()
|
|
995
1066
|
}).nullish(),
|
|
996
|
-
seed:
|
|
997
|
-
timings:
|
|
998
|
-
inference:
|
|
1067
|
+
seed: z9.number().nullish(),
|
|
1068
|
+
timings: z9.object({
|
|
1069
|
+
inference: z9.number().nullish()
|
|
999
1070
|
}).nullish(),
|
|
1000
|
-
has_nsfw_concepts:
|
|
1001
|
-
prompt:
|
|
1071
|
+
has_nsfw_concepts: z9.array(z9.boolean()).nullish(),
|
|
1072
|
+
prompt: z9.string().nullish()
|
|
1002
1073
|
});
|
|
1003
1074
|
|
|
1004
1075
|
// src/version.ts
|
|
1005
|
-
var VERSION = true ? "3.0.0-
|
|
1076
|
+
var VERSION = true ? "3.0.0-canary.32" : "0.0.0-test";
|
|
1006
1077
|
|
|
1007
1078
|
// src/fal-provider.ts
|
|
1008
1079
|
var defaultBaseURL = "https://fal.run";
|
|
@@ -1039,8 +1110,8 @@ function loadFalApiKey({
|
|
|
1039
1110
|
}
|
|
1040
1111
|
function createFal(options = {}) {
|
|
1041
1112
|
var _a;
|
|
1042
|
-
const baseURL =
|
|
1043
|
-
const getHeaders = () =>
|
|
1113
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
1114
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
1044
1115
|
{
|
|
1045
1116
|
Authorization: `Key ${loadFalApiKey({
|
|
1046
1117
|
apiKey: options.apiKey
|
|
@@ -1074,7 +1145,7 @@ function createFal(options = {}) {
|
|
|
1074
1145
|
fetch: options.fetch
|
|
1075
1146
|
});
|
|
1076
1147
|
const embeddingModel = (modelId) => {
|
|
1077
|
-
throw new
|
|
1148
|
+
throw new NoSuchModelError({
|
|
1078
1149
|
modelId,
|
|
1079
1150
|
modelType: "embeddingModel"
|
|
1080
1151
|
});
|
|
@@ -1084,7 +1155,7 @@ function createFal(options = {}) {
|
|
|
1084
1155
|
imageModel: createImageModel,
|
|
1085
1156
|
image: createImageModel,
|
|
1086
1157
|
languageModel: (modelId) => {
|
|
1087
|
-
throw new
|
|
1158
|
+
throw new NoSuchModelError({
|
|
1088
1159
|
modelId,
|
|
1089
1160
|
modelType: "languageModel"
|
|
1090
1161
|
});
|
|
@@ -1098,10 +1169,9 @@ function createFal(options = {}) {
|
|
|
1098
1169
|
};
|
|
1099
1170
|
}
|
|
1100
1171
|
var fal = createFal();
|
|
1101
|
-
|
|
1102
|
-
0 && (module.exports = {
|
|
1172
|
+
export {
|
|
1103
1173
|
VERSION,
|
|
1104
1174
|
createFal,
|
|
1105
1175
|
fal
|
|
1106
|
-
}
|
|
1176
|
+
};
|
|
1107
1177
|
//# sourceMappingURL=index.js.map
|