@ai-sdk/prodia 2.0.0-beta.22 → 2.0.0-beta.24
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 +29 -0
- package/dist/index.js +144 -111
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/prodia-image-model.ts +18 -1
- package/src/prodia-language-model.ts +18 -1
- package/dist/index.d.mts +0 -90
- package/dist/index.mjs +0 -985
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @ai-sdk/prodia
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
8
|
+
|
|
9
|
+
**`@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.
|
|
10
|
+
|
|
11
|
+
**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.
|
|
12
|
+
|
|
13
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [b3976a2]
|
|
16
|
+
- Updated dependencies [ff5eba1]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
18
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
19
|
+
|
|
20
|
+
## 2.0.0-beta.23
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [ef992f8]
|
|
29
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
31
|
+
|
|
3
32
|
## 2.0.0-beta.22
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,60 +1,49 @@
|
|
|
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
|
-
createProdia: () => createProdia,
|
|
25
|
-
prodia: () => prodia
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/prodia-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
loadApiKey,
|
|
7
|
+
withoutTrailingSlash,
|
|
8
|
+
withUserAgentSuffix
|
|
9
|
+
} from "@ai-sdk/provider-utils";
|
|
32
10
|
|
|
33
11
|
// src/prodia-image-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
import {
|
|
13
|
+
combineHeaders,
|
|
14
|
+
lazySchema,
|
|
15
|
+
parseJSON,
|
|
16
|
+
parseProviderOptions,
|
|
17
|
+
postToApi,
|
|
18
|
+
resolve,
|
|
19
|
+
serializeModelOptions,
|
|
20
|
+
WORKFLOW_SERIALIZE,
|
|
21
|
+
WORKFLOW_DESERIALIZE,
|
|
22
|
+
zodSchema
|
|
23
|
+
} from "@ai-sdk/provider-utils";
|
|
24
|
+
import { z as z2 } from "zod/v4";
|
|
36
25
|
|
|
37
26
|
// src/prodia-api.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var prodiaJobResultSchema =
|
|
41
|
-
id:
|
|
42
|
-
created_at:
|
|
43
|
-
updated_at:
|
|
44
|
-
expires_at:
|
|
45
|
-
state:
|
|
46
|
-
current:
|
|
27
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
28
|
+
import { z } from "zod/v4";
|
|
29
|
+
var prodiaJobResultSchema = z.object({
|
|
30
|
+
id: z.string(),
|
|
31
|
+
created_at: z.string().optional(),
|
|
32
|
+
updated_at: z.string().optional(),
|
|
33
|
+
expires_at: z.string().optional(),
|
|
34
|
+
state: z.object({
|
|
35
|
+
current: z.string()
|
|
47
36
|
}).optional(),
|
|
48
|
-
config:
|
|
49
|
-
seed:
|
|
37
|
+
config: z.object({
|
|
38
|
+
seed: z.number().optional()
|
|
50
39
|
}).passthrough().optional(),
|
|
51
|
-
metrics:
|
|
52
|
-
elapsed:
|
|
53
|
-
ips:
|
|
40
|
+
metrics: z.object({
|
|
41
|
+
elapsed: z.number().optional(),
|
|
42
|
+
ips: z.number().optional()
|
|
54
43
|
}).optional(),
|
|
55
|
-
price:
|
|
56
|
-
product:
|
|
57
|
-
dollars:
|
|
44
|
+
price: z.object({
|
|
45
|
+
product: z.string(),
|
|
46
|
+
dollars: z.number()
|
|
58
47
|
}).nullish()
|
|
59
48
|
});
|
|
60
49
|
function buildProdiaProviderMetadata(jobResult) {
|
|
@@ -157,12 +146,12 @@ function parseMultipart(data, boundary) {
|
|
|
157
146
|
}
|
|
158
147
|
return parts;
|
|
159
148
|
}
|
|
160
|
-
var prodiaErrorSchema =
|
|
161
|
-
message:
|
|
162
|
-
detail:
|
|
163
|
-
error:
|
|
149
|
+
var prodiaErrorSchema = z.object({
|
|
150
|
+
message: z.string().optional(),
|
|
151
|
+
detail: z.unknown().optional(),
|
|
152
|
+
error: z.string().optional()
|
|
164
153
|
});
|
|
165
|
-
var prodiaFailedResponseHandler =
|
|
154
|
+
var prodiaFailedResponseHandler = createJsonErrorResponseHandler({
|
|
166
155
|
errorSchema: prodiaErrorSchema,
|
|
167
156
|
errorToMessage: (error) => {
|
|
168
157
|
var _a;
|
|
@@ -181,7 +170,7 @@ var prodiaFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
181
170
|
});
|
|
182
171
|
|
|
183
172
|
// src/prodia-image-model.ts
|
|
184
|
-
var ProdiaImageModel = class {
|
|
173
|
+
var ProdiaImageModel = class _ProdiaImageModel {
|
|
185
174
|
constructor(modelId, config) {
|
|
186
175
|
this.modelId = modelId;
|
|
187
176
|
this.config = config;
|
|
@@ -191,6 +180,15 @@ var ProdiaImageModel = class {
|
|
|
191
180
|
get provider() {
|
|
192
181
|
return this.config.provider;
|
|
193
182
|
}
|
|
183
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
184
|
+
return serializeModelOptions({
|
|
185
|
+
modelId: model.modelId,
|
|
186
|
+
config: model.config
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
190
|
+
return new _ProdiaImageModel(options.modelId, options.config);
|
|
191
|
+
}
|
|
194
192
|
async getArgs({
|
|
195
193
|
prompt,
|
|
196
194
|
size,
|
|
@@ -198,7 +196,7 @@ var ProdiaImageModel = class {
|
|
|
198
196
|
providerOptions
|
|
199
197
|
}) {
|
|
200
198
|
const warnings = [];
|
|
201
|
-
const prodiaOptions = await
|
|
199
|
+
const prodiaOptions = await parseProviderOptions({
|
|
202
200
|
provider: "prodia",
|
|
203
201
|
providerOptions,
|
|
204
202
|
schema: prodiaImageModelOptionsSchema
|
|
@@ -257,11 +255,11 @@ var ProdiaImageModel = class {
|
|
|
257
255
|
var _a, _b, _c;
|
|
258
256
|
const { body, warnings } = await this.getArgs(options);
|
|
259
257
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
260
|
-
const combinedHeaders =
|
|
261
|
-
await
|
|
258
|
+
const combinedHeaders = combineHeaders(
|
|
259
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
262
260
|
options.headers
|
|
263
261
|
);
|
|
264
|
-
const { value: multipartResult, responseHeaders } = await
|
|
262
|
+
const { value: multipartResult, responseHeaders } = await postToApi({
|
|
265
263
|
url: `${this.config.baseURL}/job?price=true`,
|
|
266
264
|
headers: {
|
|
267
265
|
...combinedHeaders,
|
|
@@ -313,33 +311,33 @@ var stylePresets = [
|
|
|
313
311
|
"texture",
|
|
314
312
|
"craft-clay"
|
|
315
313
|
];
|
|
316
|
-
var prodiaImageModelOptionsSchema =
|
|
317
|
-
() =>
|
|
318
|
-
|
|
314
|
+
var prodiaImageModelOptionsSchema = lazySchema(
|
|
315
|
+
() => zodSchema(
|
|
316
|
+
z2.object({
|
|
319
317
|
/**
|
|
320
318
|
* Amount of computational iterations to run. More is typically higher quality.
|
|
321
319
|
*/
|
|
322
|
-
steps:
|
|
320
|
+
steps: z2.number().int().min(1).max(4).optional(),
|
|
323
321
|
/**
|
|
324
322
|
* Width of the output image in pixels.
|
|
325
323
|
*/
|
|
326
|
-
width:
|
|
324
|
+
width: z2.number().int().min(256).max(1920).optional(),
|
|
327
325
|
/**
|
|
328
326
|
* Height of the output image in pixels.
|
|
329
327
|
*/
|
|
330
|
-
height:
|
|
328
|
+
height: z2.number().int().min(256).max(1920).optional(),
|
|
331
329
|
/**
|
|
332
330
|
* Apply a visual theme to your output image.
|
|
333
331
|
*/
|
|
334
|
-
stylePreset:
|
|
332
|
+
stylePreset: z2.enum(stylePresets).optional(),
|
|
335
333
|
/**
|
|
336
334
|
* Augment the output with a LoRa model.
|
|
337
335
|
*/
|
|
338
|
-
loras:
|
|
336
|
+
loras: z2.array(z2.string()).max(3).optional(),
|
|
339
337
|
/**
|
|
340
338
|
* When using JPEG output, return a progressive JPEG.
|
|
341
339
|
*/
|
|
342
|
-
progressive:
|
|
340
|
+
progressive: z2.boolean().optional()
|
|
343
341
|
})
|
|
344
342
|
)
|
|
345
343
|
);
|
|
@@ -370,9 +368,9 @@ function createMultipartResponseHandler() {
|
|
|
370
368
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
371
369
|
if (contentDisposition.includes('name="job"')) {
|
|
372
370
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
373
|
-
jobResult = await
|
|
371
|
+
jobResult = await parseJSON({
|
|
374
372
|
text: jsonStr,
|
|
375
|
-
schema:
|
|
373
|
+
schema: zodSchema(prodiaJobResultSchema)
|
|
376
374
|
});
|
|
377
375
|
} else if (contentDisposition.includes('name="output"')) {
|
|
378
376
|
imageBytes = part.body;
|
|
@@ -394,10 +392,27 @@ function createMultipartResponseHandler() {
|
|
|
394
392
|
}
|
|
395
393
|
|
|
396
394
|
// src/prodia-language-model.ts
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
395
|
+
import {
|
|
396
|
+
UnsupportedFunctionalityError
|
|
397
|
+
} from "@ai-sdk/provider";
|
|
398
|
+
import {
|
|
399
|
+
combineHeaders as combineHeaders2,
|
|
400
|
+
isCustomReasoning,
|
|
401
|
+
isProviderReference,
|
|
402
|
+
convertBase64ToUint8Array,
|
|
403
|
+
generateId,
|
|
404
|
+
lazySchema as lazySchema2,
|
|
405
|
+
parseJSON as parseJSON2,
|
|
406
|
+
parseProviderOptions as parseProviderOptions2,
|
|
407
|
+
postFormDataToApi,
|
|
408
|
+
resolve as resolve2,
|
|
409
|
+
serializeModelOptions as serializeModelOptions2,
|
|
410
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
411
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
|
|
412
|
+
zodSchema as zodSchema2
|
|
413
|
+
} from "@ai-sdk/provider-utils";
|
|
414
|
+
import { z as z3 } from "zod/v4";
|
|
415
|
+
var ProdiaLanguageModel = class _ProdiaLanguageModel {
|
|
401
416
|
constructor(modelId, config) {
|
|
402
417
|
this.modelId = modelId;
|
|
403
418
|
this.config = config;
|
|
@@ -407,6 +422,15 @@ var ProdiaLanguageModel = class {
|
|
|
407
422
|
get provider() {
|
|
408
423
|
return this.config.provider;
|
|
409
424
|
}
|
|
425
|
+
static [WORKFLOW_SERIALIZE2](model) {
|
|
426
|
+
return serializeModelOptions2({
|
|
427
|
+
modelId: model.modelId,
|
|
428
|
+
config: model.config
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
static [WORKFLOW_DESERIALIZE2](options) {
|
|
432
|
+
return new _ProdiaLanguageModel(options.modelId, options.config);
|
|
433
|
+
}
|
|
410
434
|
async doGenerate(options) {
|
|
411
435
|
var _a, _b, _c, _d;
|
|
412
436
|
const warnings = [];
|
|
@@ -440,14 +464,14 @@ var ProdiaLanguageModel = class {
|
|
|
440
464
|
if (options.responseFormat !== void 0 && options.responseFormat.type !== "text") {
|
|
441
465
|
warnings.push({ type: "unsupported", feature: "responseFormat" });
|
|
442
466
|
}
|
|
443
|
-
if (
|
|
467
|
+
if (isCustomReasoning(options.reasoning)) {
|
|
444
468
|
warnings.push({
|
|
445
469
|
type: "unsupported",
|
|
446
470
|
feature: "reasoning",
|
|
447
471
|
details: "This provider does not support reasoning configuration."
|
|
448
472
|
});
|
|
449
473
|
}
|
|
450
|
-
const prodiaOptions = await (
|
|
474
|
+
const prodiaOptions = await parseProviderOptions2({
|
|
451
475
|
provider: "prodia",
|
|
452
476
|
providerOptions: options.providerOptions,
|
|
453
477
|
schema: prodiaLanguageModelOptionsSchema
|
|
@@ -480,15 +504,15 @@ var ProdiaLanguageModel = class {
|
|
|
480
504
|
if (message.role === "user") {
|
|
481
505
|
for (const part of message.content) {
|
|
482
506
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
483
|
-
if (
|
|
484
|
-
throw new
|
|
507
|
+
if (isProviderReference(part.data)) {
|
|
508
|
+
throw new UnsupportedFunctionalityError({
|
|
485
509
|
functionality: "file parts with provider references"
|
|
486
510
|
});
|
|
487
511
|
}
|
|
488
512
|
if (part.data instanceof Uint8Array) {
|
|
489
513
|
imageBytes = part.data;
|
|
490
514
|
} else if (typeof part.data === "string") {
|
|
491
|
-
imageBytes =
|
|
515
|
+
imageBytes = convertBase64ToUint8Array(part.data);
|
|
492
516
|
} else if (part.data instanceof URL) {
|
|
493
517
|
const fetchFn = (_a = this.config.fetch) != null ? _a : globalThis.fetch;
|
|
494
518
|
const response = await fetchFn(part.data.toString());
|
|
@@ -514,8 +538,8 @@ var ProdiaLanguageModel = class {
|
|
|
514
538
|
config: jobConfig
|
|
515
539
|
};
|
|
516
540
|
const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
|
|
517
|
-
const combinedHeaders = (
|
|
518
|
-
await (
|
|
541
|
+
const combinedHeaders = combineHeaders2(
|
|
542
|
+
this.config.headers ? await resolve2(this.config.headers) : void 0,
|
|
519
543
|
options.headers
|
|
520
544
|
);
|
|
521
545
|
const formData = new FormData();
|
|
@@ -532,7 +556,7 @@ var ProdiaLanguageModel = class {
|
|
|
532
556
|
"input" + ext
|
|
533
557
|
);
|
|
534
558
|
}
|
|
535
|
-
const { value: multipartResult, responseHeaders } = await
|
|
559
|
+
const { value: multipartResult, responseHeaders } = await postFormDataToApi(
|
|
536
560
|
{
|
|
537
561
|
url: `${this.config.baseURL}/job?price=true`,
|
|
538
562
|
headers: {
|
|
@@ -602,7 +626,7 @@ var ProdiaLanguageModel = class {
|
|
|
602
626
|
});
|
|
603
627
|
for (const part of result.content) {
|
|
604
628
|
if (part.type === "text") {
|
|
605
|
-
const id =
|
|
629
|
+
const id = generateId();
|
|
606
630
|
controller.enqueue({ type: "text-start", id });
|
|
607
631
|
controller.enqueue({
|
|
608
632
|
type: "text-delta",
|
|
@@ -635,13 +659,13 @@ var ProdiaLanguageModel = class {
|
|
|
635
659
|
};
|
|
636
660
|
}
|
|
637
661
|
};
|
|
638
|
-
var prodiaLanguageModelOptionsSchema = (
|
|
639
|
-
() => (
|
|
640
|
-
|
|
662
|
+
var prodiaLanguageModelOptionsSchema = lazySchema2(
|
|
663
|
+
() => zodSchema2(
|
|
664
|
+
z3.object({
|
|
641
665
|
/**
|
|
642
666
|
* Aspect ratio for the output image.
|
|
643
667
|
*/
|
|
644
|
-
aspectRatio:
|
|
668
|
+
aspectRatio: z3.enum([
|
|
645
669
|
"1:1",
|
|
646
670
|
"2:3",
|
|
647
671
|
"3:2",
|
|
@@ -685,9 +709,9 @@ function createLanguageMultipartResponseHandler() {
|
|
|
685
709
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
686
710
|
if (contentDisposition.includes('name="job"')) {
|
|
687
711
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
688
|
-
jobResult = await (
|
|
712
|
+
jobResult = await parseJSON2({
|
|
689
713
|
text: jsonStr,
|
|
690
|
-
schema: (
|
|
714
|
+
schema: zodSchema2(prodiaJobResultSchema)
|
|
691
715
|
});
|
|
692
716
|
} else if (contentDisposition.includes('name="output"')) {
|
|
693
717
|
if (partContentType.startsWith("text/") || contentDisposition.includes(".txt")) {
|
|
@@ -711,8 +735,18 @@ function createLanguageMultipartResponseHandler() {
|
|
|
711
735
|
}
|
|
712
736
|
|
|
713
737
|
// src/prodia-video-model.ts
|
|
714
|
-
|
|
715
|
-
|
|
738
|
+
import {
|
|
739
|
+
combineHeaders as combineHeaders3,
|
|
740
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
741
|
+
lazySchema as lazySchema3,
|
|
742
|
+
parseJSON as parseJSON3,
|
|
743
|
+
parseProviderOptions as parseProviderOptions3,
|
|
744
|
+
postFormDataToApi as postFormDataToApi2,
|
|
745
|
+
postToApi as postToApi2,
|
|
746
|
+
resolve as resolve3,
|
|
747
|
+
zodSchema as zodSchema3
|
|
748
|
+
} from "@ai-sdk/provider-utils";
|
|
749
|
+
import { z as z4 } from "zod/v4";
|
|
716
750
|
var ProdiaVideoModel = class {
|
|
717
751
|
constructor(modelId, config) {
|
|
718
752
|
this.modelId = modelId;
|
|
@@ -726,7 +760,7 @@ var ProdiaVideoModel = class {
|
|
|
726
760
|
async doGenerate(options) {
|
|
727
761
|
var _a, _b, _c;
|
|
728
762
|
const warnings = [];
|
|
729
|
-
const prodiaOptions = await (
|
|
763
|
+
const prodiaOptions = await parseProviderOptions3({
|
|
730
764
|
provider: "prodia",
|
|
731
765
|
providerOptions: options.providerOptions,
|
|
732
766
|
schema: prodiaVideoModelOptionsSchema
|
|
@@ -746,8 +780,8 @@ var ProdiaVideoModel = class {
|
|
|
746
780
|
config: jobConfig
|
|
747
781
|
};
|
|
748
782
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
749
|
-
const combinedHeaders = (
|
|
750
|
-
await (
|
|
783
|
+
const combinedHeaders = combineHeaders3(
|
|
784
|
+
await resolve3(this.config.headers),
|
|
751
785
|
options.headers
|
|
752
786
|
);
|
|
753
787
|
let multipartResult;
|
|
@@ -768,7 +802,7 @@ var ProdiaVideoModel = class {
|
|
|
768
802
|
new Blob([imageData.bytes], { type: imageData.mediaType }),
|
|
769
803
|
"input" + getExtension(imageData.mediaType)
|
|
770
804
|
);
|
|
771
|
-
const result = await (
|
|
805
|
+
const result = await postFormDataToApi2({
|
|
772
806
|
url: `${this.config.baseURL}/job?price=true`,
|
|
773
807
|
headers: {
|
|
774
808
|
...combinedHeaders,
|
|
@@ -783,7 +817,7 @@ var ProdiaVideoModel = class {
|
|
|
783
817
|
multipartResult = result.value;
|
|
784
818
|
responseHeaders = result.responseHeaders;
|
|
785
819
|
} else {
|
|
786
|
-
const result = await (
|
|
820
|
+
const result = await postToApi2({
|
|
787
821
|
url: `${this.config.baseURL}/job?price=true`,
|
|
788
822
|
headers: {
|
|
789
823
|
...combinedHeaders,
|
|
@@ -825,13 +859,13 @@ var ProdiaVideoModel = class {
|
|
|
825
859
|
};
|
|
826
860
|
}
|
|
827
861
|
};
|
|
828
|
-
var prodiaVideoModelOptionsSchema = (
|
|
829
|
-
() => (
|
|
830
|
-
|
|
862
|
+
var prodiaVideoModelOptionsSchema = lazySchema3(
|
|
863
|
+
() => zodSchema3(
|
|
864
|
+
z4.object({
|
|
831
865
|
/**
|
|
832
866
|
* Video resolution (e.g. "480p", "720p").
|
|
833
867
|
*/
|
|
834
|
-
resolution:
|
|
868
|
+
resolution: z4.string().optional()
|
|
835
869
|
})
|
|
836
870
|
)
|
|
837
871
|
);
|
|
@@ -863,9 +897,9 @@ function createVideoMultipartResponseHandler() {
|
|
|
863
897
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
864
898
|
if (contentDisposition.includes('name="job"')) {
|
|
865
899
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
866
|
-
jobResult = await (
|
|
900
|
+
jobResult = await parseJSON3({
|
|
867
901
|
text: jsonStr,
|
|
868
|
-
schema: (
|
|
902
|
+
schema: zodSchema3(prodiaJobResultSchema)
|
|
869
903
|
});
|
|
870
904
|
} else if (contentDisposition.includes('name="output"')) {
|
|
871
905
|
videoBytes = part.body;
|
|
@@ -892,7 +926,7 @@ function createVideoMultipartResponseHandler() {
|
|
|
892
926
|
async function resolveVideoFileData(file, fetchFunction) {
|
|
893
927
|
var _a;
|
|
894
928
|
if (file.type === "file") {
|
|
895
|
-
const data = typeof file.data === "string" ? (
|
|
929
|
+
const data = typeof file.data === "string" ? convertBase64ToUint8Array2(file.data) : file.data;
|
|
896
930
|
return { bytes: data, mediaType: file.mediaType };
|
|
897
931
|
}
|
|
898
932
|
const response = await (fetchFunction != null ? fetchFunction : globalThis.fetch)(file.url);
|
|
@@ -913,16 +947,16 @@ function getExtension(mediaType) {
|
|
|
913
947
|
}
|
|
914
948
|
|
|
915
949
|
// src/version.ts
|
|
916
|
-
var VERSION = true ? "2.0.0-beta.
|
|
950
|
+
var VERSION = true ? "2.0.0-beta.24" : "0.0.0-test";
|
|
917
951
|
|
|
918
952
|
// src/prodia-provider.ts
|
|
919
953
|
var defaultBaseURL = "https://inference.prodia.com/v2";
|
|
920
954
|
function createProdia(options = {}) {
|
|
921
955
|
var _a;
|
|
922
|
-
const baseURL =
|
|
923
|
-
const getHeaders = () =>
|
|
956
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
957
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
924
958
|
{
|
|
925
|
-
Authorization: `Bearer ${
|
|
959
|
+
Authorization: `Bearer ${loadApiKey({
|
|
926
960
|
apiKey: options.apiKey,
|
|
927
961
|
environmentVariableName: "PRODIA_TOKEN",
|
|
928
962
|
description: "Prodia"
|
|
@@ -950,7 +984,7 @@ function createProdia(options = {}) {
|
|
|
950
984
|
fetch: options.fetch
|
|
951
985
|
});
|
|
952
986
|
const embeddingModel = (modelId) => {
|
|
953
|
-
throw new
|
|
987
|
+
throw new NoSuchModelError({
|
|
954
988
|
modelId,
|
|
955
989
|
modelType: "embeddingModel"
|
|
956
990
|
});
|
|
@@ -967,10 +1001,9 @@ function createProdia(options = {}) {
|
|
|
967
1001
|
};
|
|
968
1002
|
}
|
|
969
1003
|
var prodia = createProdia();
|
|
970
|
-
|
|
971
|
-
0 && (module.exports = {
|
|
1004
|
+
export {
|
|
972
1005
|
VERSION,
|
|
973
1006
|
createProdia,
|
|
974
1007
|
prodia
|
|
975
|
-
}
|
|
1008
|
+
};
|
|
976
1009
|
//# sourceMappingURL=index.js.map
|