@ai-sdk/prodia 2.0.0-beta.9 → 2.0.0-canary.35
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 +226 -0
- package/README.md +2 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +267 -183
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- 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 +73 -54
- package/src/prodia-provider.ts +2 -2
- package/src/prodia-video-model-options.ts +21 -0
- package/src/prodia-video-model.ts +4 -21
- package/dist/index.d.mts +0 -90
- package/dist/index.mjs +0 -976
- 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,14 +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
|
-
if (
|
|
505
|
+
if (isCustomReasoning(options.reasoning)) {
|
|
443
506
|
warnings.push({
|
|
444
507
|
type: "unsupported",
|
|
445
508
|
feature: "reasoning",
|
|
446
509
|
details: "This provider does not support reasoning configuration."
|
|
447
510
|
});
|
|
448
511
|
}
|
|
449
|
-
const prodiaOptions = await (
|
|
512
|
+
const prodiaOptions = await parseProviderOptions2({
|
|
450
513
|
provider: "prodia",
|
|
451
514
|
providerOptions: options.providerOptions,
|
|
452
515
|
schema: prodiaLanguageModelOptionsSchema
|
|
@@ -478,18 +541,45 @@ var ProdiaLanguageModel = class {
|
|
|
478
541
|
const message = options.prompt[i];
|
|
479
542
|
if (message.role === "user") {
|
|
480
543
|
for (const part of message.content) {
|
|
481
|
-
if (part.type === "file" && part.mediaType
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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
|
+
}
|
|
491
582
|
}
|
|
492
|
-
imageMediaType = part.mediaType;
|
|
493
583
|
break;
|
|
494
584
|
}
|
|
495
585
|
}
|
|
@@ -508,8 +598,8 @@ var ProdiaLanguageModel = class {
|
|
|
508
598
|
config: jobConfig
|
|
509
599
|
};
|
|
510
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();
|
|
511
|
-
const combinedHeaders = (
|
|
512
|
-
await (
|
|
601
|
+
const combinedHeaders = combineHeaders2(
|
|
602
|
+
this.config.headers ? await resolve2(this.config.headers) : void 0,
|
|
513
603
|
options.headers
|
|
514
604
|
);
|
|
515
605
|
const formData = new FormData();
|
|
@@ -526,7 +616,7 @@ var ProdiaLanguageModel = class {
|
|
|
526
616
|
"input" + ext
|
|
527
617
|
);
|
|
528
618
|
}
|
|
529
|
-
const { value: multipartResult, responseHeaders } = await
|
|
619
|
+
const { value: multipartResult, responseHeaders } = await postFormDataToApi(
|
|
530
620
|
{
|
|
531
621
|
url: `${this.config.baseURL}/job?price=true`,
|
|
532
622
|
headers: {
|
|
@@ -549,7 +639,7 @@ var ProdiaLanguageModel = class {
|
|
|
549
639
|
content.push({
|
|
550
640
|
type: "file",
|
|
551
641
|
mediaType: file.mediaType,
|
|
552
|
-
data: file.data
|
|
642
|
+
data: { type: "data", data: file.data }
|
|
553
643
|
});
|
|
554
644
|
}
|
|
555
645
|
return {
|
|
@@ -596,7 +686,7 @@ var ProdiaLanguageModel = class {
|
|
|
596
686
|
});
|
|
597
687
|
for (const part of result.content) {
|
|
598
688
|
if (part.type === "text") {
|
|
599
|
-
const id =
|
|
689
|
+
const id = generateId();
|
|
600
690
|
controller.enqueue({ type: "text-start", id });
|
|
601
691
|
controller.enqueue({
|
|
602
692
|
type: "text-delta",
|
|
@@ -629,28 +719,6 @@ var ProdiaLanguageModel = class {
|
|
|
629
719
|
};
|
|
630
720
|
}
|
|
631
721
|
};
|
|
632
|
-
var prodiaLanguageModelOptionsSchema = (0, import_provider_utils3.lazySchema)(
|
|
633
|
-
() => (0, import_provider_utils3.zodSchema)(
|
|
634
|
-
import_v43.z.object({
|
|
635
|
-
/**
|
|
636
|
-
* Aspect ratio for the output image.
|
|
637
|
-
*/
|
|
638
|
-
aspectRatio: import_v43.z.enum([
|
|
639
|
-
"1:1",
|
|
640
|
-
"2:3",
|
|
641
|
-
"3:2",
|
|
642
|
-
"4:5",
|
|
643
|
-
"5:4",
|
|
644
|
-
"4:7",
|
|
645
|
-
"7:4",
|
|
646
|
-
"9:16",
|
|
647
|
-
"16:9",
|
|
648
|
-
"9:21",
|
|
649
|
-
"21:9"
|
|
650
|
-
]).optional()
|
|
651
|
-
})
|
|
652
|
-
)
|
|
653
|
-
);
|
|
654
722
|
function createLanguageMultipartResponseHandler() {
|
|
655
723
|
return async ({
|
|
656
724
|
response
|
|
@@ -679,9 +747,9 @@ function createLanguageMultipartResponseHandler() {
|
|
|
679
747
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
680
748
|
if (contentDisposition.includes('name="job"')) {
|
|
681
749
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
682
|
-
jobResult = await (
|
|
750
|
+
jobResult = await parseJSON2({
|
|
683
751
|
text: jsonStr,
|
|
684
|
-
schema: (
|
|
752
|
+
schema: zodSchema4(prodiaJobResultSchema)
|
|
685
753
|
});
|
|
686
754
|
} else if (contentDisposition.includes('name="output"')) {
|
|
687
755
|
if (partContentType.startsWith("text/") || contentDisposition.includes(".txt")) {
|
|
@@ -705,8 +773,35 @@ function createLanguageMultipartResponseHandler() {
|
|
|
705
773
|
}
|
|
706
774
|
|
|
707
775
|
// src/prodia-video-model.ts
|
|
708
|
-
|
|
709
|
-
|
|
776
|
+
import {
|
|
777
|
+
combineHeaders as combineHeaders3,
|
|
778
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
779
|
+
parseJSON as parseJSON3,
|
|
780
|
+
parseProviderOptions as parseProviderOptions3,
|
|
781
|
+
postFormDataToApi as postFormDataToApi2,
|
|
782
|
+
postToApi as postToApi2,
|
|
783
|
+
resolve as resolve3,
|
|
784
|
+
zodSchema as zodSchema6
|
|
785
|
+
} from "@ai-sdk/provider-utils";
|
|
786
|
+
|
|
787
|
+
// src/prodia-video-model-options.ts
|
|
788
|
+
import {
|
|
789
|
+
lazySchema as lazySchema3,
|
|
790
|
+
zodSchema as zodSchema5
|
|
791
|
+
} from "@ai-sdk/provider-utils";
|
|
792
|
+
import { z as z4 } from "zod/v4";
|
|
793
|
+
var prodiaVideoModelOptionsSchema = lazySchema3(
|
|
794
|
+
() => zodSchema5(
|
|
795
|
+
z4.object({
|
|
796
|
+
/**
|
|
797
|
+
* Video resolution (e.g. "480p", "720p").
|
|
798
|
+
*/
|
|
799
|
+
resolution: z4.string().optional()
|
|
800
|
+
})
|
|
801
|
+
)
|
|
802
|
+
);
|
|
803
|
+
|
|
804
|
+
// src/prodia-video-model.ts
|
|
710
805
|
var ProdiaVideoModel = class {
|
|
711
806
|
constructor(modelId, config) {
|
|
712
807
|
this.modelId = modelId;
|
|
@@ -720,7 +815,7 @@ var ProdiaVideoModel = class {
|
|
|
720
815
|
async doGenerate(options) {
|
|
721
816
|
var _a, _b, _c;
|
|
722
817
|
const warnings = [];
|
|
723
|
-
const prodiaOptions = await (
|
|
818
|
+
const prodiaOptions = await parseProviderOptions3({
|
|
724
819
|
provider: "prodia",
|
|
725
820
|
providerOptions: options.providerOptions,
|
|
726
821
|
schema: prodiaVideoModelOptionsSchema
|
|
@@ -740,8 +835,8 @@ var ProdiaVideoModel = class {
|
|
|
740
835
|
config: jobConfig
|
|
741
836
|
};
|
|
742
837
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
743
|
-
const combinedHeaders = (
|
|
744
|
-
await (
|
|
838
|
+
const combinedHeaders = combineHeaders3(
|
|
839
|
+
await resolve3(this.config.headers),
|
|
745
840
|
options.headers
|
|
746
841
|
);
|
|
747
842
|
let multipartResult;
|
|
@@ -762,7 +857,7 @@ var ProdiaVideoModel = class {
|
|
|
762
857
|
new Blob([imageData.bytes], { type: imageData.mediaType }),
|
|
763
858
|
"input" + getExtension(imageData.mediaType)
|
|
764
859
|
);
|
|
765
|
-
const result = await (
|
|
860
|
+
const result = await postFormDataToApi2({
|
|
766
861
|
url: `${this.config.baseURL}/job?price=true`,
|
|
767
862
|
headers: {
|
|
768
863
|
...combinedHeaders,
|
|
@@ -777,7 +872,7 @@ var ProdiaVideoModel = class {
|
|
|
777
872
|
multipartResult = result.value;
|
|
778
873
|
responseHeaders = result.responseHeaders;
|
|
779
874
|
} else {
|
|
780
|
-
const result = await (
|
|
875
|
+
const result = await postToApi2({
|
|
781
876
|
url: `${this.config.baseURL}/job?price=true`,
|
|
782
877
|
headers: {
|
|
783
878
|
...combinedHeaders,
|
|
@@ -819,16 +914,6 @@ var ProdiaVideoModel = class {
|
|
|
819
914
|
};
|
|
820
915
|
}
|
|
821
916
|
};
|
|
822
|
-
var prodiaVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
|
|
823
|
-
() => (0, import_provider_utils4.zodSchema)(
|
|
824
|
-
import_v44.z.object({
|
|
825
|
-
/**
|
|
826
|
-
* Video resolution (e.g. "480p", "720p").
|
|
827
|
-
*/
|
|
828
|
-
resolution: import_v44.z.string().optional()
|
|
829
|
-
})
|
|
830
|
-
)
|
|
831
|
-
);
|
|
832
917
|
function createVideoMultipartResponseHandler() {
|
|
833
918
|
return async ({
|
|
834
919
|
response
|
|
@@ -857,9 +942,9 @@ function createVideoMultipartResponseHandler() {
|
|
|
857
942
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
858
943
|
if (contentDisposition.includes('name="job"')) {
|
|
859
944
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
860
|
-
jobResult = await (
|
|
945
|
+
jobResult = await parseJSON3({
|
|
861
946
|
text: jsonStr,
|
|
862
|
-
schema: (
|
|
947
|
+
schema: zodSchema6(prodiaJobResultSchema)
|
|
863
948
|
});
|
|
864
949
|
} else if (contentDisposition.includes('name="output"')) {
|
|
865
950
|
videoBytes = part.body;
|
|
@@ -886,7 +971,7 @@ function createVideoMultipartResponseHandler() {
|
|
|
886
971
|
async function resolveVideoFileData(file, fetchFunction) {
|
|
887
972
|
var _a;
|
|
888
973
|
if (file.type === "file") {
|
|
889
|
-
const data = typeof file.data === "string" ? (
|
|
974
|
+
const data = typeof file.data === "string" ? convertBase64ToUint8Array2(file.data) : file.data;
|
|
890
975
|
return { bytes: data, mediaType: file.mediaType };
|
|
891
976
|
}
|
|
892
977
|
const response = await (fetchFunction != null ? fetchFunction : globalThis.fetch)(file.url);
|
|
@@ -907,16 +992,16 @@ function getExtension(mediaType) {
|
|
|
907
992
|
}
|
|
908
993
|
|
|
909
994
|
// src/version.ts
|
|
910
|
-
var VERSION = true ? "2.0.0-
|
|
995
|
+
var VERSION = true ? "2.0.0-canary.35" : "0.0.0-test";
|
|
911
996
|
|
|
912
997
|
// src/prodia-provider.ts
|
|
913
998
|
var defaultBaseURL = "https://inference.prodia.com/v2";
|
|
914
999
|
function createProdia(options = {}) {
|
|
915
1000
|
var _a;
|
|
916
|
-
const baseURL =
|
|
917
|
-
const getHeaders = () =>
|
|
1001
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
1002
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
918
1003
|
{
|
|
919
|
-
Authorization: `Bearer ${
|
|
1004
|
+
Authorization: `Bearer ${loadApiKey({
|
|
920
1005
|
apiKey: options.apiKey,
|
|
921
1006
|
environmentVariableName: "PRODIA_TOKEN",
|
|
922
1007
|
description: "Prodia"
|
|
@@ -944,7 +1029,7 @@ function createProdia(options = {}) {
|
|
|
944
1029
|
fetch: options.fetch
|
|
945
1030
|
});
|
|
946
1031
|
const embeddingModel = (modelId) => {
|
|
947
|
-
throw new
|
|
1032
|
+
throw new NoSuchModelError({
|
|
948
1033
|
modelId,
|
|
949
1034
|
modelType: "embeddingModel"
|
|
950
1035
|
});
|
|
@@ -961,10 +1046,9 @@ function createProdia(options = {}) {
|
|
|
961
1046
|
};
|
|
962
1047
|
}
|
|
963
1048
|
var prodia = createProdia();
|
|
964
|
-
|
|
965
|
-
0 && (module.exports = {
|
|
1049
|
+
export {
|
|
966
1050
|
VERSION,
|
|
967
1051
|
createProdia,
|
|
968
1052
|
prodia
|
|
969
|
-
}
|
|
1053
|
+
};
|
|
970
1054
|
//# sourceMappingURL=index.js.map
|