@ai-sdk/prodia 2.0.0-beta.8 → 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 +232 -0
- package/README.md +2 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +273 -182
- 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 +82 -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 -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();
|
|
@@ -519,7 +616,7 @@ var ProdiaLanguageModel = class {
|
|
|
519
616
|
"input" + ext
|
|
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,35 @@ 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
|
+
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
|
|
703
805
|
var ProdiaVideoModel = class {
|
|
704
806
|
constructor(modelId, config) {
|
|
705
807
|
this.modelId = modelId;
|
|
@@ -713,7 +815,7 @@ var ProdiaVideoModel = class {
|
|
|
713
815
|
async doGenerate(options) {
|
|
714
816
|
var _a, _b, _c;
|
|
715
817
|
const warnings = [];
|
|
716
|
-
const prodiaOptions = await (
|
|
818
|
+
const prodiaOptions = await parseProviderOptions3({
|
|
717
819
|
provider: "prodia",
|
|
718
820
|
providerOptions: options.providerOptions,
|
|
719
821
|
schema: prodiaVideoModelOptionsSchema
|
|
@@ -733,8 +835,8 @@ var ProdiaVideoModel = class {
|
|
|
733
835
|
config: jobConfig
|
|
734
836
|
};
|
|
735
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();
|
|
736
|
-
const combinedHeaders = (
|
|
737
|
-
await (
|
|
838
|
+
const combinedHeaders = combineHeaders3(
|
|
839
|
+
await resolve3(this.config.headers),
|
|
738
840
|
options.headers
|
|
739
841
|
);
|
|
740
842
|
let multipartResult;
|
|
@@ -755,7 +857,7 @@ var ProdiaVideoModel = class {
|
|
|
755
857
|
new Blob([imageData.bytes], { type: imageData.mediaType }),
|
|
756
858
|
"input" + getExtension(imageData.mediaType)
|
|
757
859
|
);
|
|
758
|
-
const result = await (
|
|
860
|
+
const result = await postFormDataToApi2({
|
|
759
861
|
url: `${this.config.baseURL}/job?price=true`,
|
|
760
862
|
headers: {
|
|
761
863
|
...combinedHeaders,
|
|
@@ -770,7 +872,7 @@ var ProdiaVideoModel = class {
|
|
|
770
872
|
multipartResult = result.value;
|
|
771
873
|
responseHeaders = result.responseHeaders;
|
|
772
874
|
} else {
|
|
773
|
-
const result = await (
|
|
875
|
+
const result = await postToApi2({
|
|
774
876
|
url: `${this.config.baseURL}/job?price=true`,
|
|
775
877
|
headers: {
|
|
776
878
|
...combinedHeaders,
|
|
@@ -812,16 +914,6 @@ var ProdiaVideoModel = class {
|
|
|
812
914
|
};
|
|
813
915
|
}
|
|
814
916
|
};
|
|
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
917
|
function createVideoMultipartResponseHandler() {
|
|
826
918
|
return async ({
|
|
827
919
|
response
|
|
@@ -850,9 +942,9 @@ function createVideoMultipartResponseHandler() {
|
|
|
850
942
|
const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
|
|
851
943
|
if (contentDisposition.includes('name="job"')) {
|
|
852
944
|
const jsonStr = new TextDecoder().decode(part.body);
|
|
853
|
-
jobResult = await (
|
|
945
|
+
jobResult = await parseJSON3({
|
|
854
946
|
text: jsonStr,
|
|
855
|
-
schema: (
|
|
947
|
+
schema: zodSchema6(prodiaJobResultSchema)
|
|
856
948
|
});
|
|
857
949
|
} else if (contentDisposition.includes('name="output"')) {
|
|
858
950
|
videoBytes = part.body;
|
|
@@ -879,7 +971,7 @@ function createVideoMultipartResponseHandler() {
|
|
|
879
971
|
async function resolveVideoFileData(file, fetchFunction) {
|
|
880
972
|
var _a;
|
|
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
977
|
const response = await (fetchFunction != null ? fetchFunction : globalThis.fetch)(file.url);
|
|
@@ -900,16 +992,16 @@ function getExtension(mediaType) {
|
|
|
900
992
|
}
|
|
901
993
|
|
|
902
994
|
// src/version.ts
|
|
903
|
-
var VERSION = true ? "2.0.0-
|
|
995
|
+
var VERSION = true ? "2.0.0-canary.35" : "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
|