pareta 1.2.0 → 1.3.0
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/dist/index.cjs +54 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -174,7 +174,7 @@ function parseSSE(reader, opts) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
// src/version.ts
|
|
177
|
-
var VERSION = "1.
|
|
177
|
+
var VERSION = "1.3.0";
|
|
178
178
|
|
|
179
179
|
// src/money.ts
|
|
180
180
|
var MICRO_PER_CENT = 10000n;
|
|
@@ -533,6 +533,32 @@ var Speech = class extends BaseModel {
|
|
|
533
533
|
return this;
|
|
534
534
|
}
|
|
535
535
|
};
|
|
536
|
+
var ImageGeneration = class extends BaseModel {
|
|
537
|
+
/** The generated image, base64-decoded to raw PNG bytes. */
|
|
538
|
+
get image() {
|
|
539
|
+
const b64 = this.b64Json ?? "";
|
|
540
|
+
return b64 ? base64ToBytes(b64) : new Uint8Array(0);
|
|
541
|
+
}
|
|
542
|
+
get b64Json() {
|
|
543
|
+
const data = this.raw.data ?? [];
|
|
544
|
+
return data[0]?.b64_json ?? null;
|
|
545
|
+
}
|
|
546
|
+
get size() {
|
|
547
|
+
return this.raw.size ?? null;
|
|
548
|
+
}
|
|
549
|
+
get model() {
|
|
550
|
+
return this.raw.model ?? null;
|
|
551
|
+
}
|
|
552
|
+
get created() {
|
|
553
|
+
return this.raw.created ?? null;
|
|
554
|
+
}
|
|
555
|
+
/** Write the decoded PNG to `path` (Node only — lazy node:fs). */
|
|
556
|
+
async save(path) {
|
|
557
|
+
const { writeFile } = await import('fs/promises');
|
|
558
|
+
await writeFile(path, this.image);
|
|
559
|
+
return this;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
536
562
|
|
|
537
563
|
// src/resources/chat.ts
|
|
538
564
|
var PATH = "/v1/chat/completions";
|
|
@@ -889,6 +915,28 @@ var Audio = class {
|
|
|
889
915
|
}
|
|
890
916
|
};
|
|
891
917
|
|
|
918
|
+
// src/resources/images.ts
|
|
919
|
+
var PATH3 = "/v1/images/generations";
|
|
920
|
+
var Images = class {
|
|
921
|
+
constructor(client) {
|
|
922
|
+
this.client = client;
|
|
923
|
+
}
|
|
924
|
+
client;
|
|
925
|
+
/** Generate one image from a text prompt. Returns an `ImageGeneration`
|
|
926
|
+
* whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
|
|
927
|
+
* Node). Billed flat per image. */
|
|
928
|
+
generate(prompt, opts = {}) {
|
|
929
|
+
if (!prompt || !prompt.trim()) throw new ParetaError("prompt is required");
|
|
930
|
+
const body = { prompt };
|
|
931
|
+
if (opts.size) body.size = opts.size;
|
|
932
|
+
if (opts.seed !== void 0) body.seed = opts.seed;
|
|
933
|
+
return this.client.request("POST", PATH3, {
|
|
934
|
+
body,
|
|
935
|
+
cast: (raw) => new ImageGeneration(raw)
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
|
|
892
940
|
// src/resources/retrieval.ts
|
|
893
941
|
function makeRerank(client) {
|
|
894
942
|
return (query, documents, opts = {}) => {
|
|
@@ -955,6 +1003,8 @@ var Pareta = class _Pareta {
|
|
|
955
1003
|
rerank;
|
|
956
1004
|
/** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
|
|
957
1005
|
embeddings;
|
|
1006
|
+
/** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
|
|
1007
|
+
images;
|
|
958
1008
|
constructor(options = {}) {
|
|
959
1009
|
if (!options.apiKey) {
|
|
960
1010
|
throw new ParetaError(
|
|
@@ -978,6 +1028,7 @@ var Pareta = class _Pareta {
|
|
|
978
1028
|
this.audio = new Audio(this);
|
|
979
1029
|
this.rerank = makeRerank(this);
|
|
980
1030
|
this.embeddings = makeEmbeddings(this);
|
|
1031
|
+
this.images = new Images(this);
|
|
981
1032
|
}
|
|
982
1033
|
/** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
|
|
983
1034
|
static fromEnv(options = {}) {
|
|
@@ -1178,6 +1229,8 @@ exports.EvalRuns = EvalRuns;
|
|
|
1178
1229
|
exports.EvalSet = EvalSet;
|
|
1179
1230
|
exports.EvalSets = EvalSets;
|
|
1180
1231
|
exports.FrontierModel = FrontierModel;
|
|
1232
|
+
exports.ImageGeneration = ImageGeneration;
|
|
1233
|
+
exports.Images = Images;
|
|
1181
1234
|
exports.InsufficientCreditsError = InsufficientCreditsError;
|
|
1182
1235
|
exports.Message = Message;
|
|
1183
1236
|
exports.Model = Model;
|