pendra 0.21.1 → 0.23.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/README.md +5 -3
- package/dist/index.d.mts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +318 -288
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -288
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -203,9 +203,11 @@ console.log(speech.pendra?.worker?.id); // the worker that generated it
|
|
|
203
203
|
Code written for the OpenAI SDK keeps working:
|
|
204
204
|
`Buffer.from(await speech.arrayBuffer())` returns the same bytes.
|
|
205
205
|
|
|
206
|
-
Speech
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
Speech works with private inference too. The text is encrypted before it
|
|
207
|
+
leaves your machine and the audio comes back encrypted, so `speech.create()`
|
|
208
|
+
returns the same result. If the workers serving the model are too old to answer
|
|
209
|
+
encrypted speech, the request fails with a 400 `speech_encryption_unsupported`
|
|
210
|
+
error until you update them.
|
|
209
211
|
|
|
210
212
|
## Configuration
|
|
211
213
|
|
package/dist/index.d.mts
CHANGED
|
@@ -87,10 +87,32 @@ interface ChatCompletionMessageParam {
|
|
|
87
87
|
/** Alias of {@link ChatCompletionMessageParam.reasoning_content}; that one wins if both are set. */
|
|
88
88
|
reasoning?: string | null;
|
|
89
89
|
}
|
|
90
|
+
/** One candidate token at a position, and its log probability. */
|
|
91
|
+
interface TopLogprob {
|
|
92
|
+
token: string;
|
|
93
|
+
logprob: number;
|
|
94
|
+
/**
|
|
95
|
+
* The token's UTF-8 bytes. A token can hold part of a character, so join the
|
|
96
|
+
* bytes of consecutive tokens, not their text, to rebuild exact output.
|
|
97
|
+
*/
|
|
98
|
+
bytes: number[] | null;
|
|
99
|
+
}
|
|
100
|
+
/** A token of the answer, its log probability and the likeliest alternatives. */
|
|
101
|
+
interface ChatCompletionTokenLogprob extends TopLogprob {
|
|
102
|
+
/** Empty unless `top_logprobs` was set. */
|
|
103
|
+
top_logprobs: TopLogprob[];
|
|
104
|
+
}
|
|
105
|
+
/** Log probabilities of a choice's answer tokens, present when `logprobs` is on. */
|
|
106
|
+
interface ChoiceLogprobs {
|
|
107
|
+
content: ChatCompletionTokenLogprob[] | null;
|
|
108
|
+
refusal: ChatCompletionTokenLogprob[] | null;
|
|
109
|
+
}
|
|
90
110
|
interface Choice {
|
|
91
111
|
index: number;
|
|
92
112
|
message: ChatCompletionMessage;
|
|
93
113
|
finish_reason: string | null;
|
|
114
|
+
/** Present when the request set `logprobs: true`. */
|
|
115
|
+
logprobs?: ChoiceLogprobs | null;
|
|
94
116
|
}
|
|
95
117
|
/**
|
|
96
118
|
* A machine-readable advisory about how a completion was produced. `code` is a
|
|
@@ -249,6 +271,8 @@ interface StreamChoice {
|
|
|
249
271
|
index: number;
|
|
250
272
|
delta: ChoiceDelta;
|
|
251
273
|
finish_reason: string | null;
|
|
274
|
+
/** The log probabilities of this chunk's content tokens, when `logprobs` is on. */
|
|
275
|
+
logprobs?: ChoiceLogprobs | null;
|
|
252
276
|
}
|
|
253
277
|
interface ChatCompletionChunk {
|
|
254
278
|
id: string;
|
|
@@ -340,9 +364,9 @@ interface ChatCompletionCreateParams {
|
|
|
340
364
|
reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | (string & {}) | null;
|
|
341
365
|
/** Bias specific tokens, keyed by token id (-100 to 100). */
|
|
342
366
|
logit_bias?: Record<string, number> | null;
|
|
343
|
-
/** Return log
|
|
367
|
+
/** Return the log probability of each answer token. */
|
|
344
368
|
logprobs?: boolean | null;
|
|
345
|
-
/** How many alternatives to report per
|
|
369
|
+
/** How many likely alternatives (0-20) to report per token. Needs `logprobs: true`. */
|
|
346
370
|
top_logprobs?: number | null;
|
|
347
371
|
/** OpenAI's newer spelling of `max_tokens`. */
|
|
348
372
|
max_completion_tokens?: number | null;
|
|
@@ -452,6 +476,13 @@ declare class Speech {
|
|
|
452
476
|
* ```
|
|
453
477
|
*/
|
|
454
478
|
create(params: SpeechCreateParams): Promise<SpeechResponse>;
|
|
479
|
+
/**
|
|
480
|
+
* Private-inference speech. The request options are the sealed JSON body;
|
|
481
|
+
* the worker seals the same `{ audio, format, duration_ms }` result a
|
|
482
|
+
* plaintext JSON reply carries, so the audio comes back exactly as it does
|
|
483
|
+
* without encryption.
|
|
484
|
+
*/
|
|
485
|
+
private createEncrypted;
|
|
455
486
|
}
|
|
456
487
|
|
|
457
488
|
declare class Transcriptions {
|
|
@@ -1063,4 +1094,4 @@ declare class APIStreamError extends APIError {
|
|
|
1063
1094
|
}
|
|
1064
1095
|
|
|
1065
1096
|
export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APIStreamError, AuthenticationError, Pendra, PrivateInferenceError, RateLimitError, Stream, Pendra as default };
|
|
1066
|
-
export type { APIStatusErrorOptions, AudioFileInput, ChatCompletion, ChatCompletionChunk, ChatCompletionContentPart, ChatCompletionCreateParams, ChatCompletionMessage, ChatCompletionMessageParam, ChatCompletionMessageToolCall, Choice, ChoiceDelta, CompletionTokensDetails, CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, EmbeddingUsage, ImageData, ImageGenerationCreateParams, ImageResponse, Model, ModerationCreateParams, ModerationImageURLInput, ModerationInput, ModerationInputPart, ModerationResponse, ModerationResult, ModerationTextInput, PendraExtension, PendraNotice, PendraOptions, PendraTiming, PendraWebToolStep, PendraWorker, RerankCreateParams, RerankResponse, RerankResult, RerankResultDocument, SpeechCreateParams, SpeechResponse, StreamChoice, TranscriptionCreateParams, TranscriptionResponse, TranscriptionSegment, Usage };
|
|
1097
|
+
export type { APIStatusErrorOptions, AudioFileInput, ChatCompletion, ChatCompletionChunk, ChatCompletionContentPart, ChatCompletionCreateParams, ChatCompletionMessage, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionTokenLogprob, Choice, ChoiceDelta, ChoiceLogprobs, CompletionTokensDetails, CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, EmbeddingUsage, ImageData, ImageGenerationCreateParams, ImageResponse, Model, ModerationCreateParams, ModerationImageURLInput, ModerationInput, ModerationInputPart, ModerationResponse, ModerationResult, ModerationTextInput, PendraExtension, PendraNotice, PendraOptions, PendraTiming, PendraWebToolStep, PendraWorker, RerankCreateParams, RerankResponse, RerankResult, RerankResultDocument, SpeechCreateParams, SpeechResponse, StreamChoice, TopLogprob, TranscriptionCreateParams, TranscriptionResponse, TranscriptionSegment, Usage };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,10 +87,32 @@ interface ChatCompletionMessageParam {
|
|
|
87
87
|
/** Alias of {@link ChatCompletionMessageParam.reasoning_content}; that one wins if both are set. */
|
|
88
88
|
reasoning?: string | null;
|
|
89
89
|
}
|
|
90
|
+
/** One candidate token at a position, and its log probability. */
|
|
91
|
+
interface TopLogprob {
|
|
92
|
+
token: string;
|
|
93
|
+
logprob: number;
|
|
94
|
+
/**
|
|
95
|
+
* The token's UTF-8 bytes. A token can hold part of a character, so join the
|
|
96
|
+
* bytes of consecutive tokens, not their text, to rebuild exact output.
|
|
97
|
+
*/
|
|
98
|
+
bytes: number[] | null;
|
|
99
|
+
}
|
|
100
|
+
/** A token of the answer, its log probability and the likeliest alternatives. */
|
|
101
|
+
interface ChatCompletionTokenLogprob extends TopLogprob {
|
|
102
|
+
/** Empty unless `top_logprobs` was set. */
|
|
103
|
+
top_logprobs: TopLogprob[];
|
|
104
|
+
}
|
|
105
|
+
/** Log probabilities of a choice's answer tokens, present when `logprobs` is on. */
|
|
106
|
+
interface ChoiceLogprobs {
|
|
107
|
+
content: ChatCompletionTokenLogprob[] | null;
|
|
108
|
+
refusal: ChatCompletionTokenLogprob[] | null;
|
|
109
|
+
}
|
|
90
110
|
interface Choice {
|
|
91
111
|
index: number;
|
|
92
112
|
message: ChatCompletionMessage;
|
|
93
113
|
finish_reason: string | null;
|
|
114
|
+
/** Present when the request set `logprobs: true`. */
|
|
115
|
+
logprobs?: ChoiceLogprobs | null;
|
|
94
116
|
}
|
|
95
117
|
/**
|
|
96
118
|
* A machine-readable advisory about how a completion was produced. `code` is a
|
|
@@ -249,6 +271,8 @@ interface StreamChoice {
|
|
|
249
271
|
index: number;
|
|
250
272
|
delta: ChoiceDelta;
|
|
251
273
|
finish_reason: string | null;
|
|
274
|
+
/** The log probabilities of this chunk's content tokens, when `logprobs` is on. */
|
|
275
|
+
logprobs?: ChoiceLogprobs | null;
|
|
252
276
|
}
|
|
253
277
|
interface ChatCompletionChunk {
|
|
254
278
|
id: string;
|
|
@@ -340,9 +364,9 @@ interface ChatCompletionCreateParams {
|
|
|
340
364
|
reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | (string & {}) | null;
|
|
341
365
|
/** Bias specific tokens, keyed by token id (-100 to 100). */
|
|
342
366
|
logit_bias?: Record<string, number> | null;
|
|
343
|
-
/** Return log
|
|
367
|
+
/** Return the log probability of each answer token. */
|
|
344
368
|
logprobs?: boolean | null;
|
|
345
|
-
/** How many alternatives to report per
|
|
369
|
+
/** How many likely alternatives (0-20) to report per token. Needs `logprobs: true`. */
|
|
346
370
|
top_logprobs?: number | null;
|
|
347
371
|
/** OpenAI's newer spelling of `max_tokens`. */
|
|
348
372
|
max_completion_tokens?: number | null;
|
|
@@ -452,6 +476,13 @@ declare class Speech {
|
|
|
452
476
|
* ```
|
|
453
477
|
*/
|
|
454
478
|
create(params: SpeechCreateParams): Promise<SpeechResponse>;
|
|
479
|
+
/**
|
|
480
|
+
* Private-inference speech. The request options are the sealed JSON body;
|
|
481
|
+
* the worker seals the same `{ audio, format, duration_ms }` result a
|
|
482
|
+
* plaintext JSON reply carries, so the audio comes back exactly as it does
|
|
483
|
+
* without encryption.
|
|
484
|
+
*/
|
|
485
|
+
private createEncrypted;
|
|
455
486
|
}
|
|
456
487
|
|
|
457
488
|
declare class Transcriptions {
|
|
@@ -1063,4 +1094,4 @@ declare class APIStreamError extends APIError {
|
|
|
1063
1094
|
}
|
|
1064
1095
|
|
|
1065
1096
|
export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APIStreamError, AuthenticationError, Pendra, PrivateInferenceError, RateLimitError, Stream, Pendra as default };
|
|
1066
|
-
export type { APIStatusErrorOptions, AudioFileInput, ChatCompletion, ChatCompletionChunk, ChatCompletionContentPart, ChatCompletionCreateParams, ChatCompletionMessage, ChatCompletionMessageParam, ChatCompletionMessageToolCall, Choice, ChoiceDelta, CompletionTokensDetails, CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, EmbeddingUsage, ImageData, ImageGenerationCreateParams, ImageResponse, Model, ModerationCreateParams, ModerationImageURLInput, ModerationInput, ModerationInputPart, ModerationResponse, ModerationResult, ModerationTextInput, PendraExtension, PendraNotice, PendraOptions, PendraTiming, PendraWebToolStep, PendraWorker, RerankCreateParams, RerankResponse, RerankResult, RerankResultDocument, SpeechCreateParams, SpeechResponse, StreamChoice, TranscriptionCreateParams, TranscriptionResponse, TranscriptionSegment, Usage };
|
|
1097
|
+
export type { APIStatusErrorOptions, AudioFileInput, ChatCompletion, ChatCompletionChunk, ChatCompletionContentPart, ChatCompletionCreateParams, ChatCompletionMessage, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionTokenLogprob, Choice, ChoiceDelta, ChoiceLogprobs, CompletionTokensDetails, CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, EmbeddingUsage, ImageData, ImageGenerationCreateParams, ImageResponse, Model, ModerationCreateParams, ModerationImageURLInput, ModerationInput, ModerationInputPart, ModerationResponse, ModerationResult, ModerationTextInput, PendraExtension, PendraNotice, PendraOptions, PendraTiming, PendraWebToolStep, PendraWorker, RerankCreateParams, RerankResponse, RerankResult, RerankResultDocument, SpeechCreateParams, SpeechResponse, StreamChoice, TopLogprob, TranscriptionCreateParams, TranscriptionResponse, TranscriptionSegment, Usage };
|