@ai-sdk/prodia 2.0.0-beta.5 → 2.0.0-beta.53
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 +397 -1
- package/README.md +2 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +281 -190
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/index.ts +3 -3
- package/src/prodia-api.ts +5 -2
- package/src/prodia-image-model-options.ts +61 -0
- package/src/prodia-image-model.ts +21 -61
- package/src/prodia-language-model-options.ts +35 -0
- package/src/prodia-language-model.ts +84 -56
- package/src/prodia-provider.ts +2 -2
- package/src/prodia-video-model-options.ts +21 -0
- package/src/prodia-video-model.ts +12 -28
- package/dist/index.d.mts +0 -90
- package/dist/index.mjs +0 -968
- package/dist/index.mjs.map +0 -1
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
|
+
parseJSON,
|
|
15
|
+
parseProviderOptions,
|
|
16
|
+
postToApi,
|
|
17
|
+
resolve,
|
|
18
|
+
serializeModelOptions,
|
|
19
|
+
WORKFLOW_SERIALIZE,
|
|
20
|
+
WORKFLOW_DESERIALIZE,
|
|
21
|
+
zodSchema as zodSchema2
|
|
22
|
+
} from "@ai-sdk/provider-utils";
|
|
36
23
|
|
|
37
24
|
// src/prodia-api.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
import {
|
|
26
|
+
createJsonErrorResponseHandler
|
|
27
|
+
} 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;
|
|
@@ -180,8 +169,64 @@ var prodiaFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
180
169
|
}
|
|
181
170
|
});
|
|
182
171
|
|
|
172
|
+
// src/prodia-image-model-options.ts
|
|
173
|
+
import {
|
|
174
|
+
lazySchema,
|
|
175
|
+
zodSchema
|
|
176
|
+
} from "@ai-sdk/provider-utils";
|
|
177
|
+
import { z as z2 } from "zod/v4";
|
|
178
|
+
var stylePresets = [
|
|
179
|
+
"3d-model",
|
|
180
|
+
"analog-film",
|
|
181
|
+
"anime",
|
|
182
|
+
"cinematic",
|
|
183
|
+
"comic-book",
|
|
184
|
+
"digital-art",
|
|
185
|
+
"enhance",
|
|
186
|
+
"fantasy-art",
|
|
187
|
+
"isometric",
|
|
188
|
+
"line-art",
|
|
189
|
+
"low-poly",
|
|
190
|
+
"neon-punk",
|
|
191
|
+
"origami",
|
|
192
|
+
"photographic",
|
|
193
|
+
"pixel-art",
|
|
194
|
+
"texture",
|
|
195
|
+
"craft-clay"
|
|
196
|
+
];
|
|
197
|
+
var prodiaImageModelOptionsSchema = lazySchema(
|
|
198
|
+
() => zodSchema(
|
|
199
|
+
z2.object({
|
|
200
|
+
/**
|
|
201
|
+
* Amount of computational iterations to run. More is typically higher quality.
|
|
202
|
+
*/
|
|
203
|
+
steps: z2.number().int().min(1).max(4).optional(),
|
|
204
|
+
/**
|
|
205
|
+
* Width of the output image in pixels.
|
|
206
|
+
*/
|
|
207
|
+
width: z2.number().int().min(256).max(1920).optional(),
|
|
208
|
+
/**
|
|
209
|
+
* Height of the output image in pixels.
|
|
210
|
+
*/
|
|
211
|
+
height: z2.number().int().min(256).max(1920).optional(),
|
|
212
|
+
/**
|
|
213
|
+
* Apply a visual theme to your output image.
|
|
214
|
+
*/
|
|
215
|
+
stylePreset: z2.enum(stylePresets).optional(),
|
|
216
|
+
/**
|
|
217
|
+
* Augment the output with a LoRa model.
|
|
218
|
+
*/
|
|
219
|
+
loras: z2.array(z2.string()).max(3).optional(),
|
|
220
|
+
/**
|
|
221
|
+
* When using JPEG output, return a progressive JPEG.
|
|
222
|
+
*/
|
|
223
|
+
progressive: z2.boolean().optional()
|
|
224
|
+
})
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
|
|
183
228
|
// src/prodia-image-model.ts
|
|
184
|
-
var ProdiaImageModel = class {
|
|
229
|
+
var ProdiaImageModel = class _ProdiaImageModel {
|
|
185
230
|
constructor(modelId, config) {
|
|
186
231
|
this.modelId = modelId;
|
|
187
232
|
this.config = config;
|
|
@@ -191,6 +236,15 @@ var ProdiaImageModel = class {
|
|
|
191
236
|
get provider() {
|
|
192
237
|
return this.config.provider;
|
|
193
238
|
}
|
|
239
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
240
|
+
return serializeModelOptions({
|
|
241
|
+
modelId: model.modelId,
|
|
242
|
+
config: model.config
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
246
|
+
return new _ProdiaImageModel(options.modelId, options.config);
|
|
247
|
+
}
|
|
194
248
|
async getArgs({
|
|
195
249
|
prompt,
|
|
196
250
|
size,
|
|
@@ -198,7 +252,7 @@ var ProdiaImageModel = class {
|
|
|
198
252
|
providerOptions
|
|
199
253
|
}) {
|
|
200
254
|
const warnings = [];
|
|
201
|
-
const prodiaOptions = await
|
|
255
|
+
const prodiaOptions = await parseProviderOptions({
|
|
202
256
|
provider: "prodia",
|
|
203
257
|
providerOptions,
|
|
204
258
|
schema: prodiaImageModelOptionsSchema
|
|
@@ -257,11 +311,11 @@ var ProdiaImageModel = class {
|
|
|
257
311
|
var _a, _b, _c;
|
|
258
312
|
const { body, warnings } = await this.getArgs(options);
|
|
259
313
|
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
|
|
314
|
+
const combinedHeaders = combineHeaders(
|
|
315
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
262
316
|
options.headers
|
|
263
317
|
);
|
|
264
|
-
const { value: multipartResult, responseHeaders } = await
|
|
318
|
+
const { value: multipartResult, responseHeaders } = await postToApi({
|
|
265
319
|
url: `${this.config.baseURL}/job?price=true`,
|
|
266
320
|
headers: {
|
|
267
321
|
...combinedHeaders,
|
|
@@ -294,55 +348,6 @@ var ProdiaImageModel = class {
|
|
|
294
348
|
};
|
|
295
349
|
}
|
|
296
350
|
};
|
|
297
|
-
var stylePresets = [
|
|
298
|
-
"3d-model",
|
|
299
|
-
"analog-film",
|
|
300
|
-
"anime",
|
|
301
|
-
"cinematic",
|
|
302
|
-
"comic-book",
|
|
303
|
-
"digital-art",
|
|
304
|
-
"enhance",
|
|
305
|
-
"fantasy-art",
|
|
306
|
-
"isometric",
|
|
307
|
-
"line-art",
|
|
308
|
-
"low-poly",
|
|
309
|
-
"neon-punk",
|
|
310
|
-
"origami",
|
|
311
|
-
"photographic",
|
|
312
|
-
"pixel-art",
|
|
313
|
-
"texture",
|
|
314
|
-
"craft-clay"
|
|
315
|
-
];
|
|
316
|
-
var prodiaImageModelOptionsSchema = (0, import_provider_utils2.lazySchema)(
|
|
317
|
-
() => (0, import_provider_utils2.zodSchema)(
|
|
318
|
-
import_v42.z.object({
|
|
319
|
-
/**
|
|
320
|
-
* Amount of computational iterations to run. More is typically higher quality.
|
|
321
|
-
*/
|
|
322
|
-
steps: import_v42.z.number().int().min(1).max(4).optional(),
|
|
323
|
-
/**
|
|
324
|
-
* Width of the output image in pixels.
|
|
325
|
-
*/
|
|
326
|
-
width: import_v42.z.number().int().min(256).max(1920).optional(),
|
|
327
|
-
/**
|
|
328
|
-
* Height of the output image in pixels.
|
|
329
|
-
*/
|
|
330
|
-
height: import_v42.z.number().int().min(256).max(1920).optional(),
|
|
331
|
-
/**
|
|
332
|
-
* Apply a visual theme to your output image.
|
|
333
|
-
*/
|
|
334
|
-
stylePreset: import_v42.z.enum(stylePresets).optional(),
|
|
335
|
-
/**
|
|
336
|
-
* Augment the output with a LoRa model.
|
|
337
|
-
*/
|
|
338
|
-
loras: import_v42.z.array(import_v42.z.string()).max(3).optional(),
|
|
339
|
-
/**
|
|
340
|
-
* When using JPEG output, return a progressive JPEG.
|
|
341
|
-
*/
|
|
342
|
-
progressive: import_v42.z.boolean().optional()
|
|
343
|
-
})
|
|
344
|
-
)
|
|
345
|
-
);
|
|
346
351
|
function createMultipartResponseHandler() {
|
|
347
352
|
return async ({
|
|
348
353
|
response
|
|
@@ -370,9 +375,9 @@ function createMultipartResponseHandler() {
|
|
|
370
375
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
371
376
|
if (contentDisposition.includes('name="job"')) {
|
|
372
377
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
373
|
-
jobResult = await
|
|
378
|
+
jobResult = await parseJSON({
|
|
374
379
|
text: jsonStr,
|
|
375
|
-
schema: (
|
|
380
|
+
schema: zodSchema2(prodiaJobResultSchema)
|
|
376
381
|
});
|
|
377
382
|
} else if (contentDisposition.includes('name="output"')) {
|
|
378
383
|
imageBytes = part.body;
|
|
@@ -394,9 +399,58 @@ function createMultipartResponseHandler() {
|
|
|
394
399
|
}
|
|
395
400
|
|
|
396
401
|
// src/prodia-language-model.ts
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
402
|
+
import {
|
|
403
|
+
UnsupportedFunctionalityError
|
|
404
|
+
} from "@ai-sdk/provider";
|
|
405
|
+
import {
|
|
406
|
+
combineHeaders as combineHeaders2,
|
|
407
|
+
isCustomReasoning,
|
|
408
|
+
convertBase64ToUint8Array,
|
|
409
|
+
detectMediaType,
|
|
410
|
+
generateId,
|
|
411
|
+
getTopLevelMediaType,
|
|
412
|
+
isFullMediaType,
|
|
413
|
+
parseJSON as parseJSON2,
|
|
414
|
+
parseProviderOptions as parseProviderOptions2,
|
|
415
|
+
postFormDataToApi,
|
|
416
|
+
resolve as resolve2,
|
|
417
|
+
serializeModelOptions as serializeModelOptions2,
|
|
418
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
419
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
|
|
420
|
+
zodSchema as zodSchema4
|
|
421
|
+
} from "@ai-sdk/provider-utils";
|
|
422
|
+
|
|
423
|
+
// src/prodia-language-model-options.ts
|
|
424
|
+
import {
|
|
425
|
+
lazySchema as lazySchema2,
|
|
426
|
+
zodSchema as zodSchema3
|
|
427
|
+
} from "@ai-sdk/provider-utils";
|
|
428
|
+
import { z as z3 } from "zod/v4";
|
|
429
|
+
var prodiaLanguageModelOptionsSchema = lazySchema2(
|
|
430
|
+
() => zodSchema3(
|
|
431
|
+
z3.object({
|
|
432
|
+
/**
|
|
433
|
+
* Aspect ratio for the output image.
|
|
434
|
+
*/
|
|
435
|
+
aspectRatio: z3.enum([
|
|
436
|
+
"1:1",
|
|
437
|
+
"2:3",
|
|
438
|
+
"3:2",
|
|
439
|
+
"4:5",
|
|
440
|
+
"5:4",
|
|
441
|
+
"4:7",
|
|
442
|
+
"7:4",
|
|
443
|
+
"9:16",
|
|
444
|
+
"16:9",
|
|
445
|
+
"9:21",
|
|
446
|
+
"21:9"
|
|
447
|
+
]).optional()
|
|
448
|
+
})
|
|
449
|
+
)
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
// src/prodia-language-model.ts
|
|
453
|
+
var ProdiaLanguageModel = class _ProdiaLanguageModel {
|
|
400
454
|
constructor(modelId, config) {
|
|
401
455
|
this.modelId = modelId;
|
|
402
456
|
this.config = config;
|
|
@@ -406,6 +460,15 @@ var ProdiaLanguageModel = class {
|
|
|
406
460
|
get provider() {
|
|
407
461
|
return this.config.provider;
|
|
408
462
|
}
|
|
463
|
+
static [WORKFLOW_SERIALIZE2](model) {
|
|
464
|
+
return serializeModelOptions2({
|
|
465
|
+
modelId: model.modelId,
|
|
466
|
+
config: model.config
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
static [WORKFLOW_DESERIALIZE2](options) {
|
|
470
|
+
return new _ProdiaLanguageModel(options.modelId, options.config);
|
|
471
|
+
}
|
|
409
472
|
async doGenerate(options) {
|
|
410
473
|
var _a, _b, _c, _d;
|
|
411
474
|
const warnings = [];
|
|
@@ -439,7 +502,14 @@ var ProdiaLanguageModel = class {
|
|
|
439
502
|
if (options.responseFormat !== void 0 && options.responseFormat.type !== "text") {
|
|
440
503
|
warnings.push({ type: "unsupported", feature: "responseFormat" });
|
|
441
504
|
}
|
|
442
|
-
|
|
505
|
+
if (isCustomReasoning(options.reasoning)) {
|
|
506
|
+
warnings.push({
|
|
507
|
+
type: "unsupported",
|
|
508
|
+
feature: "reasoning",
|
|
509
|
+
details: "This provider does not support reasoning configuration."
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
const prodiaOptions = await parseProviderOptions2({
|
|
443
513
|
provider: "prodia",
|
|
444
514
|
providerOptions: options.providerOptions,
|
|
445
515
|
schema: prodiaLanguageModelOptionsSchema
|
|
@@ -471,18 +541,45 @@ var ProdiaLanguageModel = class {
|
|
|
471
541
|
const message = options.prompt[i];
|
|
472
542
|
if (message.role === "user") {
|
|
473
543
|
for (const part of message.content) {
|
|
474
|
-
if (part.type === "file" && part.mediaType
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
544
|
+
if (part.type === "file" && getTopLevelMediaType(part.mediaType) === "image") {
|
|
545
|
+
switch (part.data.type) {
|
|
546
|
+
case "reference": {
|
|
547
|
+
throw new UnsupportedFunctionalityError({
|
|
548
|
+
functionality: "file parts with provider references"
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
case "text": {
|
|
552
|
+
throw new UnsupportedFunctionalityError({
|
|
553
|
+
functionality: "text file parts"
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
case "data": {
|
|
557
|
+
if (part.data.data instanceof Uint8Array) {
|
|
558
|
+
imageBytes = part.data.data;
|
|
559
|
+
} else {
|
|
560
|
+
imageBytes = convertBase64ToUint8Array(part.data.data);
|
|
561
|
+
}
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
case "url": {
|
|
565
|
+
const fetchFn = (_a = this.config.fetch) != null ? _a : globalThis.fetch;
|
|
566
|
+
const response = await fetchFn(part.data.url.toString());
|
|
567
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
568
|
+
imageBytes = new Uint8Array(arrayBuffer);
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (isFullMediaType(part.mediaType)) {
|
|
573
|
+
imageMediaType = part.mediaType;
|
|
574
|
+
} else if (imageBytes !== void 0) {
|
|
575
|
+
const detected = detectMediaType({
|
|
576
|
+
data: imageBytes,
|
|
577
|
+
topLevelType: getTopLevelMediaType(part.mediaType)
|
|
578
|
+
});
|
|
579
|
+
if (detected !== void 0) {
|
|
580
|
+
imageMediaType = detected;
|
|
581
|
+
}
|
|
484
582
|
}
|
|
485
|
-
imageMediaType = part.mediaType;
|
|
486
583
|
break;
|
|
487
584
|
}
|
|
488
585
|
}
|
|
@@ -501,8 +598,8 @@ var ProdiaLanguageModel = class {
|
|
|
501
598
|
config: jobConfig
|
|
502
599
|
};
|
|
503
600
|
const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
|
|
504
|
-
const combinedHeaders = (
|
|
505
|
-
await (
|
|
601
|
+
const combinedHeaders = combineHeaders2(
|
|
602
|
+
this.config.headers ? await resolve2(this.config.headers) : void 0,
|
|
506
603
|
options.headers
|
|
507
604
|
);
|
|
508
605
|
const formData = new FormData();
|
|
@@ -512,14 +609,14 @@ var ProdiaLanguageModel = class {
|
|
|
512
609
|
"job.json"
|
|
513
610
|
);
|
|
514
611
|
if (imageBytes) {
|
|
515
|
-
const
|
|
612
|
+
const fileExtension = imageMediaType === "image/png" ? ".png" : imageMediaType === "image/jpeg" ? ".jpg" : imageMediaType === "image/webp" ? ".webp" : "";
|
|
516
613
|
formData.append(
|
|
517
614
|
"input",
|
|
518
615
|
new Blob([imageBytes], { type: imageMediaType }),
|
|
519
|
-
"input" +
|
|
616
|
+
"input" + fileExtension
|
|
520
617
|
);
|
|
521
618
|
}
|
|
522
|
-
const { value: multipartResult, responseHeaders } = await
|
|
619
|
+
const { value: multipartResult, responseHeaders } = await postFormDataToApi(
|
|
523
620
|
{
|
|
524
621
|
url: `${this.config.baseURL}/job?price=true`,
|
|
525
622
|
headers: {
|
|
@@ -542,7 +639,7 @@ var ProdiaLanguageModel = class {
|
|
|
542
639
|
content.push({
|
|
543
640
|
type: "file",
|
|
544
641
|
mediaType: file.mediaType,
|
|
545
|
-
data: file.data
|
|
642
|
+
data: { type: "data", data: file.data }
|
|
546
643
|
});
|
|
547
644
|
}
|
|
548
645
|
return {
|
|
@@ -589,7 +686,7 @@ var ProdiaLanguageModel = class {
|
|
|
589
686
|
});
|
|
590
687
|
for (const part of result.content) {
|
|
591
688
|
if (part.type === "text") {
|
|
592
|
-
const id =
|
|
689
|
+
const id = generateId();
|
|
593
690
|
controller.enqueue({ type: "text-start", id });
|
|
594
691
|
controller.enqueue({
|
|
595
692
|
type: "text-delta",
|
|
@@ -622,28 +719,6 @@ var ProdiaLanguageModel = class {
|
|
|
622
719
|
};
|
|
623
720
|
}
|
|
624
721
|
};
|
|
625
|
-
var prodiaLanguageModelOptionsSchema = (0, import_provider_utils3.lazySchema)(
|
|
626
|
-
() => (0, import_provider_utils3.zodSchema)(
|
|
627
|
-
import_v43.z.object({
|
|
628
|
-
/**
|
|
629
|
-
* Aspect ratio for the output image.
|
|
630
|
-
*/
|
|
631
|
-
aspectRatio: import_v43.z.enum([
|
|
632
|
-
"1:1",
|
|
633
|
-
"2:3",
|
|
634
|
-
"3:2",
|
|
635
|
-
"4:5",
|
|
636
|
-
"5:4",
|
|
637
|
-
"4:7",
|
|
638
|
-
"7:4",
|
|
639
|
-
"9:16",
|
|
640
|
-
"16:9",
|
|
641
|
-
"9:21",
|
|
642
|
-
"21:9"
|
|
643
|
-
]).optional()
|
|
644
|
-
})
|
|
645
|
-
)
|
|
646
|
-
);
|
|
647
722
|
function createLanguageMultipartResponseHandler() {
|
|
648
723
|
return async ({
|
|
649
724
|
response
|
|
@@ -672,9 +747,9 @@ function createLanguageMultipartResponseHandler() {
|
|
|
672
747
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
673
748
|
if (contentDisposition.includes('name="job"')) {
|
|
674
749
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
675
|
-
jobResult = await (
|
|
750
|
+
jobResult = await parseJSON2({
|
|
676
751
|
text: jsonStr,
|
|
677
|
-
schema: (
|
|
752
|
+
schema: zodSchema4(prodiaJobResultSchema)
|
|
678
753
|
});
|
|
679
754
|
} else if (contentDisposition.includes('name="output"')) {
|
|
680
755
|
if (partContentType.startsWith("text/") || contentDisposition.includes(".txt")) {
|
|
@@ -698,8 +773,36 @@ function createLanguageMultipartResponseHandler() {
|
|
|
698
773
|
}
|
|
699
774
|
|
|
700
775
|
// src/prodia-video-model.ts
|
|
701
|
-
|
|
702
|
-
|
|
776
|
+
import {
|
|
777
|
+
combineHeaders as combineHeaders3,
|
|
778
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
779
|
+
downloadBlob,
|
|
780
|
+
parseJSON as parseJSON3,
|
|
781
|
+
parseProviderOptions as parseProviderOptions3,
|
|
782
|
+
postFormDataToApi as postFormDataToApi2,
|
|
783
|
+
postToApi as postToApi2,
|
|
784
|
+
resolve as resolve3,
|
|
785
|
+
zodSchema as zodSchema6
|
|
786
|
+
} from "@ai-sdk/provider-utils";
|
|
787
|
+
|
|
788
|
+
// src/prodia-video-model-options.ts
|
|
789
|
+
import {
|
|
790
|
+
lazySchema as lazySchema3,
|
|
791
|
+
zodSchema as zodSchema5
|
|
792
|
+
} from "@ai-sdk/provider-utils";
|
|
793
|
+
import { z as z4 } from "zod/v4";
|
|
794
|
+
var prodiaVideoModelOptionsSchema = lazySchema3(
|
|
795
|
+
() => zodSchema5(
|
|
796
|
+
z4.object({
|
|
797
|
+
/**
|
|
798
|
+
* Video resolution (e.g. "480p", "720p").
|
|
799
|
+
*/
|
|
800
|
+
resolution: z4.string().optional()
|
|
801
|
+
})
|
|
802
|
+
)
|
|
803
|
+
);
|
|
804
|
+
|
|
805
|
+
// src/prodia-video-model.ts
|
|
703
806
|
var ProdiaVideoModel = class {
|
|
704
807
|
constructor(modelId, config) {
|
|
705
808
|
this.modelId = modelId;
|
|
@@ -713,7 +816,7 @@ var ProdiaVideoModel = class {
|
|
|
713
816
|
async doGenerate(options) {
|
|
714
817
|
var _a, _b, _c;
|
|
715
818
|
const warnings = [];
|
|
716
|
-
const prodiaOptions = await (
|
|
819
|
+
const prodiaOptions = await parseProviderOptions3({
|
|
717
820
|
provider: "prodia",
|
|
718
821
|
providerOptions: options.providerOptions,
|
|
719
822
|
schema: prodiaVideoModelOptionsSchema
|
|
@@ -733,8 +836,8 @@ var ProdiaVideoModel = class {
|
|
|
733
836
|
config: jobConfig
|
|
734
837
|
};
|
|
735
838
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
736
|
-
const combinedHeaders = (
|
|
737
|
-
await (
|
|
839
|
+
const combinedHeaders = combineHeaders3(
|
|
840
|
+
await resolve3(this.config.headers),
|
|
738
841
|
options.headers
|
|
739
842
|
);
|
|
740
843
|
let multipartResult;
|
|
@@ -742,7 +845,7 @@ var ProdiaVideoModel = class {
|
|
|
742
845
|
if (options.image) {
|
|
743
846
|
const imageData = await resolveVideoFileData(
|
|
744
847
|
options.image,
|
|
745
|
-
|
|
848
|
+
options.abortSignal
|
|
746
849
|
);
|
|
747
850
|
const formData = new FormData();
|
|
748
851
|
formData.append(
|
|
@@ -755,7 +858,7 @@ var ProdiaVideoModel = class {
|
|
|
755
858
|
new Blob([imageData.bytes], { type: imageData.mediaType }),
|
|
756
859
|
"input" + getExtension(imageData.mediaType)
|
|
757
860
|
);
|
|
758
|
-
const result = await (
|
|
861
|
+
const result = await postFormDataToApi2({
|
|
759
862
|
url: `${this.config.baseURL}/job?price=true`,
|
|
760
863
|
headers: {
|
|
761
864
|
...combinedHeaders,
|
|
@@ -770,7 +873,7 @@ var ProdiaVideoModel = class {
|
|
|
770
873
|
multipartResult = result.value;
|
|
771
874
|
responseHeaders = result.responseHeaders;
|
|
772
875
|
} else {
|
|
773
|
-
const result = await (
|
|
876
|
+
const result = await postToApi2({
|
|
774
877
|
url: `${this.config.baseURL}/job?price=true`,
|
|
775
878
|
headers: {
|
|
776
879
|
...combinedHeaders,
|
|
@@ -812,16 +915,6 @@ var ProdiaVideoModel = class {
|
|
|
812
915
|
};
|
|
813
916
|
}
|
|
814
917
|
};
|
|
815
|
-
var prodiaVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
|
|
816
|
-
() => (0, import_provider_utils4.zodSchema)(
|
|
817
|
-
import_v44.z.object({
|
|
818
|
-
/**
|
|
819
|
-
* Video resolution (e.g. "480p", "720p").
|
|
820
|
-
*/
|
|
821
|
-
resolution: import_v44.z.string().optional()
|
|
822
|
-
})
|
|
823
|
-
)
|
|
824
|
-
);
|
|
825
918
|
function createVideoMultipartResponseHandler() {
|
|
826
919
|
return async ({
|
|
827
920
|
response
|
|
@@ -850,9 +943,9 @@ function createVideoMultipartResponseHandler() {
|
|
|
850
943
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
851
944
|
if (contentDisposition.includes('name="job"')) {
|
|
852
945
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
853
|
-
jobResult = await (
|
|
946
|
+
jobResult = await parseJSON3({
|
|
854
947
|
text: jsonStr,
|
|
855
|
-
schema: (
|
|
948
|
+
schema: zodSchema6(prodiaJobResultSchema)
|
|
856
949
|
});
|
|
857
950
|
} else if (contentDisposition.includes('name="output"')) {
|
|
858
951
|
videoBytes = part.body;
|
|
@@ -876,15 +969,14 @@ function createVideoMultipartResponseHandler() {
|
|
|
876
969
|
};
|
|
877
970
|
};
|
|
878
971
|
}
|
|
879
|
-
async function resolveVideoFileData(file,
|
|
880
|
-
var _a;
|
|
972
|
+
async function resolveVideoFileData(file, abortSignal) {
|
|
881
973
|
if (file.type === "file") {
|
|
882
|
-
const data = typeof file.data === "string" ? (
|
|
974
|
+
const data = typeof file.data === "string" ? convertBase64ToUint8Array2(file.data) : file.data;
|
|
883
975
|
return { bytes: data, mediaType: file.mediaType };
|
|
884
976
|
}
|
|
885
|
-
const
|
|
886
|
-
const arrayBuffer = await
|
|
887
|
-
const mediaType =
|
|
977
|
+
const blob = await downloadBlob(file.url, { abortSignal });
|
|
978
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
979
|
+
const mediaType = blob.type || "application/octet-stream";
|
|
888
980
|
return { bytes: new Uint8Array(arrayBuffer), mediaType };
|
|
889
981
|
}
|
|
890
982
|
function getExtension(mediaType) {
|
|
@@ -900,16 +992,16 @@ function getExtension(mediaType) {
|
|
|
900
992
|
}
|
|
901
993
|
|
|
902
994
|
// src/version.ts
|
|
903
|
-
var VERSION = true ? "2.0.0-beta.
|
|
995
|
+
var VERSION = true ? "2.0.0-beta.53" : "0.0.0-test";
|
|
904
996
|
|
|
905
997
|
// src/prodia-provider.ts
|
|
906
998
|
var defaultBaseURL = "https://inference.prodia.com/v2";
|
|
907
999
|
function createProdia(options = {}) {
|
|
908
1000
|
var _a;
|
|
909
|
-
const baseURL =
|
|
910
|
-
const getHeaders = () =>
|
|
1001
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
1002
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
911
1003
|
{
|
|
912
|
-
Authorization: `Bearer ${
|
|
1004
|
+
Authorization: `Bearer ${loadApiKey({
|
|
913
1005
|
apiKey: options.apiKey,
|
|
914
1006
|
environmentVariableName: "PRODIA_TOKEN",
|
|
915
1007
|
description: "Prodia"
|
|
@@ -937,7 +1029,7 @@ function createProdia(options = {}) {
|
|
|
937
1029
|
fetch: options.fetch
|
|
938
1030
|
});
|
|
939
1031
|
const embeddingModel = (modelId) => {
|
|
940
|
-
throw new
|
|
1032
|
+
throw new NoSuchModelError({
|
|
941
1033
|
modelId,
|
|
942
1034
|
modelType: "embeddingModel"
|
|
943
1035
|
});
|
|
@@ -954,10 +1046,9 @@ function createProdia(options = {}) {
|
|
|
954
1046
|
};
|
|
955
1047
|
}
|
|
956
1048
|
var prodia = createProdia();
|
|
957
|
-
|
|
958
|
-
0 && (module.exports = {
|
|
1049
|
+
export {
|
|
959
1050
|
VERSION,
|
|
960
1051
|
createProdia,
|
|
961
1052
|
prodia
|
|
962
|
-
}
|
|
1053
|
+
};
|
|
963
1054
|
//# sourceMappingURL=index.js.map
|