pareta 1.1.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 +161 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -5
- package/dist/index.d.ts +117 -5
- package/dist/index.mjs +157 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -166,6 +166,40 @@ declare class Embeddings extends BaseModel {
|
|
|
166
166
|
get promptTokens(): number | null;
|
|
167
167
|
get length(): number;
|
|
168
168
|
}
|
|
169
|
+
/** Speech-to-text result from `audio.transcriptions(...)`. `.durationS` is
|
|
170
|
+
* the metered input audio length (per minute). */
|
|
171
|
+
declare class Transcription extends BaseModel {
|
|
172
|
+
get text(): string | null;
|
|
173
|
+
get language(): string | null;
|
|
174
|
+
get durationS(): number | null;
|
|
175
|
+
toString(): string;
|
|
176
|
+
}
|
|
177
|
+
/** Text-to-speech result from `audio.speech(...)`. `.audio` is decoded
|
|
178
|
+
* bytes; `.durationS` is the metered output audio length (per minute). */
|
|
179
|
+
declare class Speech extends BaseModel {
|
|
180
|
+
/** The synthesized audio, base64-decoded to raw bytes. */
|
|
181
|
+
get audio(): Uint8Array;
|
|
182
|
+
get audioBase64(): string | null;
|
|
183
|
+
get sampleRate(): number | null;
|
|
184
|
+
get durationS(): number | null;
|
|
185
|
+
/** Container/codec of the returned audio (e.g. "wav"). */
|
|
186
|
+
get format(): string | null;
|
|
187
|
+
/** Write the decoded audio to `path` (Node only — lazy node:fs). */
|
|
188
|
+
save(path: string): Promise<this>;
|
|
189
|
+
}
|
|
190
|
+
/** Image result from `images.generate(...)`. `.image` is decoded PNG bytes;
|
|
191
|
+
* `.size` is the ACTUAL delivered size. Billed flat per image (the
|
|
192
|
+
* `X-Pareta-Billed` response header carries the receipt). */
|
|
193
|
+
declare class ImageGeneration extends BaseModel {
|
|
194
|
+
/** The generated image, base64-decoded to raw PNG bytes. */
|
|
195
|
+
get image(): Uint8Array;
|
|
196
|
+
get b64Json(): string | null;
|
|
197
|
+
get size(): string | null;
|
|
198
|
+
get model(): string | null;
|
|
199
|
+
get created(): number | null;
|
|
200
|
+
/** Write the decoded PNG to `path` (Node only — lazy node:fs). */
|
|
201
|
+
save(path: string): Promise<this>;
|
|
202
|
+
}
|
|
169
203
|
|
|
170
204
|
/**
|
|
171
205
|
* `client.chat.completions` — OpenAI-compatible chat completions.
|
|
@@ -225,8 +259,10 @@ declare class Models {
|
|
|
225
259
|
}
|
|
226
260
|
|
|
227
261
|
/**
|
|
228
|
-
* `client.tasks` —
|
|
229
|
-
* a
|
|
262
|
+
* `client.tasks` — the grading-contract directory for evals. A task names how
|
|
263
|
+
* a dataset is scored (row shape + scorer); inference never takes one. `match`
|
|
264
|
+
* maps a plain-English description of your dataset to the contract that
|
|
265
|
+
* grades it — feed the matched task id into `evals.runs.create(task=...)`.
|
|
230
266
|
*/
|
|
231
267
|
|
|
232
268
|
declare class Tasks {
|
|
@@ -390,6 +426,78 @@ declare class Auto {
|
|
|
390
426
|
}): Promise<FrontierComparison>;
|
|
391
427
|
}
|
|
392
428
|
|
|
429
|
+
/**
|
|
430
|
+
* `pa.audio` — the Speech capability lanes (ASR + TTS), TS parity with the
|
|
431
|
+
* Python SDK's `client.audio`.
|
|
432
|
+
*
|
|
433
|
+
* Dedicated routes, not `chat.completions`:
|
|
434
|
+
* POST /v1/audio/transcriptions {audio_base64, language?} -> {text, language, duration_s}
|
|
435
|
+
* POST /v1/audio/speech {text, voice?} -> {audio_base64, sample_rate, duration_s, format}
|
|
436
|
+
*
|
|
437
|
+
* Both are metered PER MINUTE of audio (input duration for ASR, output
|
|
438
|
+
* duration for TTS). You never pick a serving model — Pareta resolves the
|
|
439
|
+
* lane, exactly as `model:"auto"` does for chat.
|
|
440
|
+
*
|
|
441
|
+
* Audio input follows the evals FileInput convention: a string is a FILE
|
|
442
|
+
* PATH (read via lazy node:fs — browser/edge bundles stay clean);
|
|
443
|
+
* Blob/ArrayBuffer/Uint8Array are raw bytes; `{ base64 }` passes
|
|
444
|
+
* pre-encoded audio through untouched.
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
type AudioInput = string | Blob | ArrayBuffer | Uint8Array | {
|
|
448
|
+
base64: string;
|
|
449
|
+
};
|
|
450
|
+
interface TranscriptionOptions {
|
|
451
|
+
/** Optional ISO language hint (omit to auto-detect). */
|
|
452
|
+
language?: string;
|
|
453
|
+
}
|
|
454
|
+
interface SpeechOptions {
|
|
455
|
+
/** Optional voice id (omit for the default voice). */
|
|
456
|
+
voice?: string;
|
|
457
|
+
}
|
|
458
|
+
declare class Audio {
|
|
459
|
+
private readonly client;
|
|
460
|
+
constructor(client: Transport);
|
|
461
|
+
/** Speech-to-text (the `asr` lane). `audio` is a file path, raw bytes, a
|
|
462
|
+
* Blob, or `{ base64 }`. Metered per minute of input audio. */
|
|
463
|
+
transcriptions(audio: AudioInput, opts?: TranscriptionOptions): Promise<Transcription>;
|
|
464
|
+
/** Text-to-speech (the `tts` lane). Returns a `Speech` whose `.audio` is
|
|
465
|
+
* decoded bytes (`.save(path)` writes a file in Node). Metered per minute
|
|
466
|
+
* of output audio. */
|
|
467
|
+
speech(text: string, opts?: SpeechOptions): Promise<Speech>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* `pa.images` — the image-generation capability lane, TS parity with the
|
|
472
|
+
* Python SDK's `client.images`.
|
|
473
|
+
*
|
|
474
|
+
* Dedicated route, not `chat.completions`:
|
|
475
|
+
* POST /v1/images/generations {prompt, size?, seed?} -> {created, model,
|
|
476
|
+
* data: [{b64_json}], size}
|
|
477
|
+
*
|
|
478
|
+
* Generation runs on Pareta's open image model (`hidream-1`) and is metered
|
|
479
|
+
* at a FLAT price per image — every size costs the same (the model renders
|
|
480
|
+
* at full 2K quality internally regardless of the delivery size). The
|
|
481
|
+
* `X-Pareta-Billed` response header carries the per-request receipt in
|
|
482
|
+
* micro-USD. Delivery sizes today (server-authoritative): 1024x1024
|
|
483
|
+
* (default), 2048x2048, 2304x1728, 1728x2304, 2560x1440, 1440x2560.
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
interface ImageGenerateOptions {
|
|
487
|
+
/** Delivery size, e.g. "2560x1440" (omit for 1024x1024). Flat price. */
|
|
488
|
+
size?: string;
|
|
489
|
+
/** Pin the noise seed for reproducibility. */
|
|
490
|
+
seed?: number;
|
|
491
|
+
}
|
|
492
|
+
declare class Images {
|
|
493
|
+
private readonly client;
|
|
494
|
+
constructor(client: Transport);
|
|
495
|
+
/** Generate one image from a text prompt. Returns an `ImageGeneration`
|
|
496
|
+
* whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
|
|
497
|
+
* Node). Billed flat per image. */
|
|
498
|
+
generate(prompt: string, opts?: ImageGenerateOptions): Promise<ImageGeneration>;
|
|
499
|
+
}
|
|
500
|
+
|
|
393
501
|
/**
|
|
394
502
|
* `pa.rerank(...)` + `pa.embeddings(...)` — the Retrieval capability lanes
|
|
395
503
|
* (the RAG stack: embeddings for recall, reranking for precision).
|
|
@@ -400,7 +508,7 @@ declare class Auto {
|
|
|
400
508
|
* POST /v1/embeddings {input[], input_type?} -> unit-normalized vectors
|
|
401
509
|
*
|
|
402
510
|
* Rerank is metered per document scored; embeddings per input token. You never
|
|
403
|
-
* pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `
|
|
511
|
+
* pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `qwen-embed-1`),
|
|
404
512
|
* exactly as `model:"auto"` does for chat.
|
|
405
513
|
*
|
|
406
514
|
* Exposed as callable client fields (`pa.rerank(...)`) rather than resource
|
|
@@ -472,10 +580,14 @@ declare class Pareta implements Transport {
|
|
|
472
580
|
readonly tasks: Tasks;
|
|
473
581
|
readonly evals: Evals;
|
|
474
582
|
readonly auto: Auto;
|
|
583
|
+
/** The Speech lanes — `pa.audio.transcriptions(...)` (ASR) + `pa.audio.speech(...)` (TTS). */
|
|
584
|
+
readonly audio: Audio;
|
|
475
585
|
/** Document reranking (the Retrieval precision lane) — `pa.rerank(query, docs, {topN})`. */
|
|
476
586
|
readonly rerank: RerankFn;
|
|
477
587
|
/** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
|
|
478
588
|
readonly embeddings: EmbeddingsFn;
|
|
589
|
+
/** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
|
|
590
|
+
readonly images: Images;
|
|
479
591
|
constructor(options?: ParetaOptions);
|
|
480
592
|
/** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
|
|
481
593
|
static fromEnv(options?: ParetaOptions): Pareta;
|
|
@@ -499,7 +611,7 @@ declare class Pareta implements Transport {
|
|
|
499
611
|
stream<T = unknown>(method: string, path: string, opts?: StreamOptions): AsyncGenerator<T>;
|
|
500
612
|
}
|
|
501
613
|
|
|
502
|
-
declare const VERSION = "1.
|
|
614
|
+
declare const VERSION = "1.3.0";
|
|
503
615
|
|
|
504
616
|
/**
|
|
505
617
|
* Typed error hierarchy for the Pareta SDK — a faithful port of the Python
|
|
@@ -591,4 +703,4 @@ declare class EndpointNotReadyError extends APIStatusError {
|
|
|
591
703
|
constructor(message: string, init: APIStatusErrorInit);
|
|
592
704
|
}
|
|
593
705
|
|
|
594
|
-
export { APIConnectionError, APIStatusError, APITimeoutError, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Task, TaskMatch, TaskMatchCandidate, type Transport, Usage, VERSION, type ValidationErrorItem };
|
|
706
|
+
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, type AudioInput, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, type ImageGenerateOptions, ImageGeneration, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Speech, type SpeechOptions, Task, TaskMatch, TaskMatchCandidate, Transcription, type TranscriptionOptions, type Transport, Usage, VERSION, type ValidationErrorItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -166,6 +166,40 @@ declare class Embeddings extends BaseModel {
|
|
|
166
166
|
get promptTokens(): number | null;
|
|
167
167
|
get length(): number;
|
|
168
168
|
}
|
|
169
|
+
/** Speech-to-text result from `audio.transcriptions(...)`. `.durationS` is
|
|
170
|
+
* the metered input audio length (per minute). */
|
|
171
|
+
declare class Transcription extends BaseModel {
|
|
172
|
+
get text(): string | null;
|
|
173
|
+
get language(): string | null;
|
|
174
|
+
get durationS(): number | null;
|
|
175
|
+
toString(): string;
|
|
176
|
+
}
|
|
177
|
+
/** Text-to-speech result from `audio.speech(...)`. `.audio` is decoded
|
|
178
|
+
* bytes; `.durationS` is the metered output audio length (per minute). */
|
|
179
|
+
declare class Speech extends BaseModel {
|
|
180
|
+
/** The synthesized audio, base64-decoded to raw bytes. */
|
|
181
|
+
get audio(): Uint8Array;
|
|
182
|
+
get audioBase64(): string | null;
|
|
183
|
+
get sampleRate(): number | null;
|
|
184
|
+
get durationS(): number | null;
|
|
185
|
+
/** Container/codec of the returned audio (e.g. "wav"). */
|
|
186
|
+
get format(): string | null;
|
|
187
|
+
/** Write the decoded audio to `path` (Node only — lazy node:fs). */
|
|
188
|
+
save(path: string): Promise<this>;
|
|
189
|
+
}
|
|
190
|
+
/** Image result from `images.generate(...)`. `.image` is decoded PNG bytes;
|
|
191
|
+
* `.size` is the ACTUAL delivered size. Billed flat per image (the
|
|
192
|
+
* `X-Pareta-Billed` response header carries the receipt). */
|
|
193
|
+
declare class ImageGeneration extends BaseModel {
|
|
194
|
+
/** The generated image, base64-decoded to raw PNG bytes. */
|
|
195
|
+
get image(): Uint8Array;
|
|
196
|
+
get b64Json(): string | null;
|
|
197
|
+
get size(): string | null;
|
|
198
|
+
get model(): string | null;
|
|
199
|
+
get created(): number | null;
|
|
200
|
+
/** Write the decoded PNG to `path` (Node only — lazy node:fs). */
|
|
201
|
+
save(path: string): Promise<this>;
|
|
202
|
+
}
|
|
169
203
|
|
|
170
204
|
/**
|
|
171
205
|
* `client.chat.completions` — OpenAI-compatible chat completions.
|
|
@@ -225,8 +259,10 @@ declare class Models {
|
|
|
225
259
|
}
|
|
226
260
|
|
|
227
261
|
/**
|
|
228
|
-
* `client.tasks` —
|
|
229
|
-
* a
|
|
262
|
+
* `client.tasks` — the grading-contract directory for evals. A task names how
|
|
263
|
+
* a dataset is scored (row shape + scorer); inference never takes one. `match`
|
|
264
|
+
* maps a plain-English description of your dataset to the contract that
|
|
265
|
+
* grades it — feed the matched task id into `evals.runs.create(task=...)`.
|
|
230
266
|
*/
|
|
231
267
|
|
|
232
268
|
declare class Tasks {
|
|
@@ -390,6 +426,78 @@ declare class Auto {
|
|
|
390
426
|
}): Promise<FrontierComparison>;
|
|
391
427
|
}
|
|
392
428
|
|
|
429
|
+
/**
|
|
430
|
+
* `pa.audio` — the Speech capability lanes (ASR + TTS), TS parity with the
|
|
431
|
+
* Python SDK's `client.audio`.
|
|
432
|
+
*
|
|
433
|
+
* Dedicated routes, not `chat.completions`:
|
|
434
|
+
* POST /v1/audio/transcriptions {audio_base64, language?} -> {text, language, duration_s}
|
|
435
|
+
* POST /v1/audio/speech {text, voice?} -> {audio_base64, sample_rate, duration_s, format}
|
|
436
|
+
*
|
|
437
|
+
* Both are metered PER MINUTE of audio (input duration for ASR, output
|
|
438
|
+
* duration for TTS). You never pick a serving model — Pareta resolves the
|
|
439
|
+
* lane, exactly as `model:"auto"` does for chat.
|
|
440
|
+
*
|
|
441
|
+
* Audio input follows the evals FileInput convention: a string is a FILE
|
|
442
|
+
* PATH (read via lazy node:fs — browser/edge bundles stay clean);
|
|
443
|
+
* Blob/ArrayBuffer/Uint8Array are raw bytes; `{ base64 }` passes
|
|
444
|
+
* pre-encoded audio through untouched.
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
type AudioInput = string | Blob | ArrayBuffer | Uint8Array | {
|
|
448
|
+
base64: string;
|
|
449
|
+
};
|
|
450
|
+
interface TranscriptionOptions {
|
|
451
|
+
/** Optional ISO language hint (omit to auto-detect). */
|
|
452
|
+
language?: string;
|
|
453
|
+
}
|
|
454
|
+
interface SpeechOptions {
|
|
455
|
+
/** Optional voice id (omit for the default voice). */
|
|
456
|
+
voice?: string;
|
|
457
|
+
}
|
|
458
|
+
declare class Audio {
|
|
459
|
+
private readonly client;
|
|
460
|
+
constructor(client: Transport);
|
|
461
|
+
/** Speech-to-text (the `asr` lane). `audio` is a file path, raw bytes, a
|
|
462
|
+
* Blob, or `{ base64 }`. Metered per minute of input audio. */
|
|
463
|
+
transcriptions(audio: AudioInput, opts?: TranscriptionOptions): Promise<Transcription>;
|
|
464
|
+
/** Text-to-speech (the `tts` lane). Returns a `Speech` whose `.audio` is
|
|
465
|
+
* decoded bytes (`.save(path)` writes a file in Node). Metered per minute
|
|
466
|
+
* of output audio. */
|
|
467
|
+
speech(text: string, opts?: SpeechOptions): Promise<Speech>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* `pa.images` — the image-generation capability lane, TS parity with the
|
|
472
|
+
* Python SDK's `client.images`.
|
|
473
|
+
*
|
|
474
|
+
* Dedicated route, not `chat.completions`:
|
|
475
|
+
* POST /v1/images/generations {prompt, size?, seed?} -> {created, model,
|
|
476
|
+
* data: [{b64_json}], size}
|
|
477
|
+
*
|
|
478
|
+
* Generation runs on Pareta's open image model (`hidream-1`) and is metered
|
|
479
|
+
* at a FLAT price per image — every size costs the same (the model renders
|
|
480
|
+
* at full 2K quality internally regardless of the delivery size). The
|
|
481
|
+
* `X-Pareta-Billed` response header carries the per-request receipt in
|
|
482
|
+
* micro-USD. Delivery sizes today (server-authoritative): 1024x1024
|
|
483
|
+
* (default), 2048x2048, 2304x1728, 1728x2304, 2560x1440, 1440x2560.
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
interface ImageGenerateOptions {
|
|
487
|
+
/** Delivery size, e.g. "2560x1440" (omit for 1024x1024). Flat price. */
|
|
488
|
+
size?: string;
|
|
489
|
+
/** Pin the noise seed for reproducibility. */
|
|
490
|
+
seed?: number;
|
|
491
|
+
}
|
|
492
|
+
declare class Images {
|
|
493
|
+
private readonly client;
|
|
494
|
+
constructor(client: Transport);
|
|
495
|
+
/** Generate one image from a text prompt. Returns an `ImageGeneration`
|
|
496
|
+
* whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
|
|
497
|
+
* Node). Billed flat per image. */
|
|
498
|
+
generate(prompt: string, opts?: ImageGenerateOptions): Promise<ImageGeneration>;
|
|
499
|
+
}
|
|
500
|
+
|
|
393
501
|
/**
|
|
394
502
|
* `pa.rerank(...)` + `pa.embeddings(...)` — the Retrieval capability lanes
|
|
395
503
|
* (the RAG stack: embeddings for recall, reranking for precision).
|
|
@@ -400,7 +508,7 @@ declare class Auto {
|
|
|
400
508
|
* POST /v1/embeddings {input[], input_type?} -> unit-normalized vectors
|
|
401
509
|
*
|
|
402
510
|
* Rerank is metered per document scored; embeddings per input token. You never
|
|
403
|
-
* pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `
|
|
511
|
+
* pick a serving model — Pareta resolves the lane (`pareta-rerank-1` / `qwen-embed-1`),
|
|
404
512
|
* exactly as `model:"auto"` does for chat.
|
|
405
513
|
*
|
|
406
514
|
* Exposed as callable client fields (`pa.rerank(...)`) rather than resource
|
|
@@ -472,10 +580,14 @@ declare class Pareta implements Transport {
|
|
|
472
580
|
readonly tasks: Tasks;
|
|
473
581
|
readonly evals: Evals;
|
|
474
582
|
readonly auto: Auto;
|
|
583
|
+
/** The Speech lanes — `pa.audio.transcriptions(...)` (ASR) + `pa.audio.speech(...)` (TTS). */
|
|
584
|
+
readonly audio: Audio;
|
|
475
585
|
/** Document reranking (the Retrieval precision lane) — `pa.rerank(query, docs, {topN})`. */
|
|
476
586
|
readonly rerank: RerankFn;
|
|
477
587
|
/** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
|
|
478
588
|
readonly embeddings: EmbeddingsFn;
|
|
589
|
+
/** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
|
|
590
|
+
readonly images: Images;
|
|
479
591
|
constructor(options?: ParetaOptions);
|
|
480
592
|
/** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
|
|
481
593
|
static fromEnv(options?: ParetaOptions): Pareta;
|
|
@@ -499,7 +611,7 @@ declare class Pareta implements Transport {
|
|
|
499
611
|
stream<T = unknown>(method: string, path: string, opts?: StreamOptions): AsyncGenerator<T>;
|
|
500
612
|
}
|
|
501
613
|
|
|
502
|
-
declare const VERSION = "1.
|
|
614
|
+
declare const VERSION = "1.3.0";
|
|
503
615
|
|
|
504
616
|
/**
|
|
505
617
|
* Typed error hierarchy for the Pareta SDK — a faithful port of the Python
|
|
@@ -591,4 +703,4 @@ declare class EndpointNotReadyError extends APIStatusError {
|
|
|
591
703
|
constructor(message: string, init: APIStatusErrorInit);
|
|
592
704
|
}
|
|
593
705
|
|
|
594
|
-
export { APIConnectionError, APIStatusError, APITimeoutError, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Task, TaskMatch, TaskMatchCandidate, type Transport, Usage, VERSION, type ValidationErrorItem };
|
|
706
|
+
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, type AudioInput, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, type ChatCompletionCreateParams, type ChatMessage, Choice, ConflictError, Embeddings, type EmbeddingsFn, type EmbeddingsOptions, EndpointNotReadyError, type ErrorDetail, EvalItemResult, EvalResult, EvalRun, type EvalRunCreateParams, EvalRuns, EvalSet, EvalSets, type FileInput, type FilePart, FrontierModel, type FrontierSpec, type ImageGenerateOptions, ImageGeneration, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, type ParetaOptions, PermissionDeniedError, RateLimitError, Rerank, type RerankFn, type RerankOptions, RerankResult, type SSEEvent, Speech, type SpeechOptions, Task, TaskMatch, TaskMatchCandidate, Transcription, type TranscriptionOptions, type Transport, Usage, VERSION, type ValidationErrorItem };
|
package/dist/index.mjs
CHANGED
|
@@ -172,7 +172,7 @@ function parseSSE(reader, opts) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// src/version.ts
|
|
175
|
-
var VERSION = "1.
|
|
175
|
+
var VERSION = "1.3.0";
|
|
176
176
|
|
|
177
177
|
// src/money.ts
|
|
178
178
|
var MICRO_PER_CENT = 10000n;
|
|
@@ -484,6 +484,79 @@ var Embeddings = class extends BaseModel {
|
|
|
484
484
|
return (this.raw.data ?? []).length;
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
|
+
function base64ToBytes(b64) {
|
|
488
|
+
if (typeof Buffer !== "undefined") return new Uint8Array(Buffer.from(b64, "base64"));
|
|
489
|
+
const bin = atob(b64);
|
|
490
|
+
const bytes = new Uint8Array(bin.length);
|
|
491
|
+
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
|
|
492
|
+
return bytes;
|
|
493
|
+
}
|
|
494
|
+
var Transcription = class extends BaseModel {
|
|
495
|
+
get text() {
|
|
496
|
+
return this.raw.text ?? null;
|
|
497
|
+
}
|
|
498
|
+
get language() {
|
|
499
|
+
return this.raw.language ?? null;
|
|
500
|
+
}
|
|
501
|
+
get durationS() {
|
|
502
|
+
return this.raw.duration_s ?? null;
|
|
503
|
+
}
|
|
504
|
+
toString() {
|
|
505
|
+
return this.text ?? "";
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
var Speech = class extends BaseModel {
|
|
509
|
+
/** The synthesized audio, base64-decoded to raw bytes. */
|
|
510
|
+
get audio() {
|
|
511
|
+
const b64 = this.raw.audio_base64 || "";
|
|
512
|
+
return b64 ? base64ToBytes(b64) : new Uint8Array(0);
|
|
513
|
+
}
|
|
514
|
+
get audioBase64() {
|
|
515
|
+
return this.raw.audio_base64 ?? null;
|
|
516
|
+
}
|
|
517
|
+
get sampleRate() {
|
|
518
|
+
return this.raw.sample_rate ?? null;
|
|
519
|
+
}
|
|
520
|
+
get durationS() {
|
|
521
|
+
return this.raw.duration_s ?? null;
|
|
522
|
+
}
|
|
523
|
+
/** Container/codec of the returned audio (e.g. "wav"). */
|
|
524
|
+
get format() {
|
|
525
|
+
return this.raw.format ?? null;
|
|
526
|
+
}
|
|
527
|
+
/** Write the decoded audio to `path` (Node only — lazy node:fs). */
|
|
528
|
+
async save(path) {
|
|
529
|
+
const { writeFile } = await import('fs/promises');
|
|
530
|
+
await writeFile(path, this.audio);
|
|
531
|
+
return this;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
var ImageGeneration = class extends BaseModel {
|
|
535
|
+
/** The generated image, base64-decoded to raw PNG bytes. */
|
|
536
|
+
get image() {
|
|
537
|
+
const b64 = this.b64Json ?? "";
|
|
538
|
+
return b64 ? base64ToBytes(b64) : new Uint8Array(0);
|
|
539
|
+
}
|
|
540
|
+
get b64Json() {
|
|
541
|
+
const data = this.raw.data ?? [];
|
|
542
|
+
return data[0]?.b64_json ?? null;
|
|
543
|
+
}
|
|
544
|
+
get size() {
|
|
545
|
+
return this.raw.size ?? null;
|
|
546
|
+
}
|
|
547
|
+
get model() {
|
|
548
|
+
return this.raw.model ?? null;
|
|
549
|
+
}
|
|
550
|
+
get created() {
|
|
551
|
+
return this.raw.created ?? null;
|
|
552
|
+
}
|
|
553
|
+
/** Write the decoded PNG to `path` (Node only — lazy node:fs). */
|
|
554
|
+
async save(path) {
|
|
555
|
+
const { writeFile } = await import('fs/promises');
|
|
556
|
+
await writeFile(path, this.image);
|
|
557
|
+
return this;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
487
560
|
|
|
488
561
|
// src/resources/chat.ts
|
|
489
562
|
var PATH = "/v1/chat/completions";
|
|
@@ -786,6 +859,82 @@ var Auto = class {
|
|
|
786
859
|
}
|
|
787
860
|
};
|
|
788
861
|
|
|
862
|
+
// src/resources/audio.ts
|
|
863
|
+
var BASE3 = "/v1/audio";
|
|
864
|
+
function bytesToBase64(bytes) {
|
|
865
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString("base64");
|
|
866
|
+
let bin = "";
|
|
867
|
+
const CHUNK = 32768;
|
|
868
|
+
for (let i = 0; i < bytes.length; i += CHUNK) {
|
|
869
|
+
bin += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
|
|
870
|
+
}
|
|
871
|
+
return btoa(bin);
|
|
872
|
+
}
|
|
873
|
+
async function toBase64(audio) {
|
|
874
|
+
if (typeof audio === "string") {
|
|
875
|
+
const { readFile } = await import('fs/promises');
|
|
876
|
+
return bytesToBase64(new Uint8Array(await readFile(audio)));
|
|
877
|
+
}
|
|
878
|
+
if (typeof audio === "object" && audio !== null && "base64" in audio) {
|
|
879
|
+
if (!audio.base64 || !audio.base64.trim()) throw new ParetaError("audio.base64 is empty");
|
|
880
|
+
return audio.base64;
|
|
881
|
+
}
|
|
882
|
+
if (audio instanceof Blob) return bytesToBase64(new Uint8Array(await audio.arrayBuffer()));
|
|
883
|
+
const bytes = audio instanceof Uint8Array ? audio : new Uint8Array(audio);
|
|
884
|
+
if (bytes.byteLength === 0) throw new ParetaError("audio is empty");
|
|
885
|
+
return bytesToBase64(bytes);
|
|
886
|
+
}
|
|
887
|
+
var Audio = class {
|
|
888
|
+
constructor(client) {
|
|
889
|
+
this.client = client;
|
|
890
|
+
}
|
|
891
|
+
client;
|
|
892
|
+
/** Speech-to-text (the `asr` lane). `audio` is a file path, raw bytes, a
|
|
893
|
+
* Blob, or `{ base64 }`. Metered per minute of input audio. */
|
|
894
|
+
async transcriptions(audio, opts = {}) {
|
|
895
|
+
const body = { audio_base64: await toBase64(audio) };
|
|
896
|
+
if (opts.language) body.language = opts.language;
|
|
897
|
+
return this.client.request("POST", `${BASE3}/transcriptions`, {
|
|
898
|
+
body,
|
|
899
|
+
cast: (raw) => new Transcription(raw)
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
/** Text-to-speech (the `tts` lane). Returns a `Speech` whose `.audio` is
|
|
903
|
+
* decoded bytes (`.save(path)` writes a file in Node). Metered per minute
|
|
904
|
+
* of output audio. */
|
|
905
|
+
speech(text, opts = {}) {
|
|
906
|
+
if (!text || !text.trim()) throw new ParetaError("text is required");
|
|
907
|
+
const body = { text };
|
|
908
|
+
if (opts.voice) body.voice = opts.voice;
|
|
909
|
+
return this.client.request("POST", `${BASE3}/speech`, {
|
|
910
|
+
body,
|
|
911
|
+
cast: (raw) => new Speech(raw)
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
// src/resources/images.ts
|
|
917
|
+
var PATH3 = "/v1/images/generations";
|
|
918
|
+
var Images = class {
|
|
919
|
+
constructor(client) {
|
|
920
|
+
this.client = client;
|
|
921
|
+
}
|
|
922
|
+
client;
|
|
923
|
+
/** Generate one image from a text prompt. Returns an `ImageGeneration`
|
|
924
|
+
* whose `.image` is decoded PNG bytes (`.save(path)` writes a file in
|
|
925
|
+
* Node). Billed flat per image. */
|
|
926
|
+
generate(prompt, opts = {}) {
|
|
927
|
+
if (!prompt || !prompt.trim()) throw new ParetaError("prompt is required");
|
|
928
|
+
const body = { prompt };
|
|
929
|
+
if (opts.size) body.size = opts.size;
|
|
930
|
+
if (opts.seed !== void 0) body.seed = opts.seed;
|
|
931
|
+
return this.client.request("POST", PATH3, {
|
|
932
|
+
body,
|
|
933
|
+
cast: (raw) => new ImageGeneration(raw)
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
|
|
789
938
|
// src/resources/retrieval.ts
|
|
790
939
|
function makeRerank(client) {
|
|
791
940
|
return (query, documents, opts = {}) => {
|
|
@@ -846,10 +995,14 @@ var Pareta = class _Pareta {
|
|
|
846
995
|
tasks;
|
|
847
996
|
evals;
|
|
848
997
|
auto;
|
|
998
|
+
/** The Speech lanes — `pa.audio.transcriptions(...)` (ASR) + `pa.audio.speech(...)` (TTS). */
|
|
999
|
+
audio;
|
|
849
1000
|
/** Document reranking (the Retrieval precision lane) — `pa.rerank(query, docs, {topN})`. */
|
|
850
1001
|
rerank;
|
|
851
1002
|
/** Text embeddings (the Retrieval recall lane) — `pa.embeddings(input, {inputType})`. */
|
|
852
1003
|
embeddings;
|
|
1004
|
+
/** Image generation — `pa.images.generate(prompt, {size, seed})`, flat price per image. */
|
|
1005
|
+
images;
|
|
853
1006
|
constructor(options = {}) {
|
|
854
1007
|
if (!options.apiKey) {
|
|
855
1008
|
throw new ParetaError(
|
|
@@ -870,8 +1023,10 @@ var Pareta = class _Pareta {
|
|
|
870
1023
|
this.tasks = new Tasks(this);
|
|
871
1024
|
this.evals = new Evals(this);
|
|
872
1025
|
this.auto = new Auto(this);
|
|
1026
|
+
this.audio = new Audio(this);
|
|
873
1027
|
this.rerank = makeRerank(this);
|
|
874
1028
|
this.embeddings = makeEmbeddings(this);
|
|
1029
|
+
this.images = new Images(this);
|
|
875
1030
|
}
|
|
876
1031
|
/** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
|
|
877
1032
|
static fromEnv(options = {}) {
|
|
@@ -1052,6 +1207,6 @@ var Pareta = class _Pareta {
|
|
|
1052
1207
|
}
|
|
1053
1208
|
};
|
|
1054
1209
|
|
|
1055
|
-
export { APIConnectionError, APIStatusError, APITimeoutError, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, Choice, ConflictError, Embeddings, EndpointNotReadyError, EvalItemResult, EvalResult, EvalRun, EvalRuns, EvalSet, EvalSets, FrontierModel, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, PermissionDeniedError, RateLimitError, Rerank, RerankResult, Task, TaskMatch, TaskMatchCandidate, Usage, VERSION };
|
|
1210
|
+
export { APIConnectionError, APIStatusError, APITimeoutError, Audio, AuthenticationError, BadRequestError, BaseModel, ChatCompletion, ChatCompletionChunk, Choice, ConflictError, Embeddings, EndpointNotReadyError, EvalItemResult, EvalResult, EvalRun, EvalRuns, EvalSet, EvalSets, FrontierModel, ImageGeneration, Images, InsufficientCreditsError, Message, Model, ModelList, NotFoundError, Pareta, ParetaError, PermissionDeniedError, RateLimitError, Rerank, RerankResult, Speech, Task, TaskMatch, TaskMatchCandidate, Transcription, Usage, VERSION };
|
|
1056
1211
|
//# sourceMappingURL=index.mjs.map
|
|
1057
1212
|
//# sourceMappingURL=index.mjs.map
|