pendra 0.18.1 → 0.20.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 CHANGED
@@ -138,7 +138,7 @@ Embeddings, reranking, image generation, transcriptions and speech carry the
138
138
  same field:
139
139
 
140
140
  ```typescript
141
- const embeddings = await client.embeddings.create({ model: 'nomic-embed-text:latest', input: 'hi' });
141
+ const embeddings = await client.embeddings.create({ model: 'embeddinggemma:300m', input: 'hi' });
142
142
  console.log(embeddings.pendra?.worker?.id);
143
143
  ```
144
144
 
package/dist/index.d.mts CHANGED
@@ -19,6 +19,10 @@ interface Usage {
19
19
  * on {@link ChatCompletion.pendra} as a `truncated_during_reasoning` notice.
20
20
  */
21
21
  completion_tokens_details?: CompletionTokensDetails | null;
22
+ /** Breakdown of `prompt_tokens`. */
23
+ prompt_tokens_details?: {
24
+ cached_tokens?: number;
25
+ } | null;
22
26
  }
23
27
  interface ChatCompletionMessageToolCall {
24
28
  /**
@@ -116,10 +120,11 @@ interface PendraNotice {
116
120
  message: string;
117
121
  }
118
122
  /**
119
- * Per-request performance for a streaming completion, on the last chunk before
120
- * `[DONE]`. Non-streaming replies get the same figures in the `Server-Timing`
121
- * response header instead — headers flush before the first token, so a stream
122
- * cannot use them.
123
+ * Per-request performance for a completion. A stream carries it on the last
124
+ * chunk before `[DONE]`. A non-streaming reply carries the same figures as
125
+ * `pendra.timing` in the response body, and also in the `Server-Timing` header,
126
+ * which a slow request may not get because its headers flush before the result
127
+ * exists.
123
128
  *
124
129
  * Every field is present only when it was measured, and the whole block is
125
130
  * omitted when nothing was (an older worker reports no timings at all).
@@ -142,6 +147,8 @@ interface PendraTiming {
142
147
  model_load_ms?: number;
143
148
  /** `true` when the model had to be loaded for this request. */
144
149
  cold_start?: boolean;
150
+ /** Share of draft tokens the model kept, 0-1. Present only when the request speculated. */
151
+ draft_acceptance_rate?: number;
145
152
  }
146
153
  /**
147
154
  * One web-tool step a model ran while answering — reported only when the
@@ -539,6 +546,12 @@ interface EmbeddingCreateParams {
539
546
  input: string | string[];
540
547
  encoding_format?: "float" | "base64";
541
548
  dimensions?: number;
549
+ /**
550
+ * What the text is for: `"document"` (the default) for text you store and
551
+ * search over, `"query"` for a search against it, `"none"` to embed the text
552
+ * exactly as sent. Pendra formats the input the way the model expects.
553
+ */
554
+ input_type?: "query" | "document" | "none";
542
555
  user?: string;
543
556
  /** Pin to a specific worker (sent as the `X-Pendra-Worker-Id` header). */
544
557
  worker_id?: string | null;
@@ -1028,4 +1041,5 @@ declare class APIStreamError extends APIError {
1028
1041
  });
1029
1042
  }
1030
1043
 
1031
- export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, type APIStatusErrorOptions, APIStreamError, type AudioFileInput, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionContentPart, type ChatCompletionCreateParams, type ChatCompletionMessage, type ChatCompletionMessageParam, type ChatCompletionMessageToolCall, type Choice, type ChoiceDelta, type CompletionTokensDetails, type CreateEmbeddingResponse, type Embedding, type EmbeddingCreateParams, type EmbeddingUsage, type ImageData, type ImageGenerationCreateParams, type ImageResponse, type Model, type ModerationCreateParams, type ModerationImageURLInput, type ModerationInput, type ModerationInputPart, type ModerationResponse, type ModerationResult, type ModerationTextInput, Pendra, type PendraExtension, type PendraNotice, type PendraOptions, type PendraTiming, type PendraWebToolStep, type PendraWorker, PrivateInferenceError, RateLimitError, type RerankCreateParams, type RerankResponse, type RerankResult, type RerankResultDocument, type SpeechCreateParams, type SpeechResponse, Stream, type StreamChoice, type TranscriptionCreateParams, type TranscriptionResponse, type TranscriptionSegment, type Usage, Pendra as default };
1044
+ export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APIStreamError, AuthenticationError, Pendra, PrivateInferenceError, RateLimitError, Stream, Pendra as default };
1045
+ 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 };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,10 @@ interface Usage {
19
19
  * on {@link ChatCompletion.pendra} as a `truncated_during_reasoning` notice.
20
20
  */
21
21
  completion_tokens_details?: CompletionTokensDetails | null;
22
+ /** Breakdown of `prompt_tokens`. */
23
+ prompt_tokens_details?: {
24
+ cached_tokens?: number;
25
+ } | null;
22
26
  }
23
27
  interface ChatCompletionMessageToolCall {
24
28
  /**
@@ -116,10 +120,11 @@ interface PendraNotice {
116
120
  message: string;
117
121
  }
118
122
  /**
119
- * Per-request performance for a streaming completion, on the last chunk before
120
- * `[DONE]`. Non-streaming replies get the same figures in the `Server-Timing`
121
- * response header instead — headers flush before the first token, so a stream
122
- * cannot use them.
123
+ * Per-request performance for a completion. A stream carries it on the last
124
+ * chunk before `[DONE]`. A non-streaming reply carries the same figures as
125
+ * `pendra.timing` in the response body, and also in the `Server-Timing` header,
126
+ * which a slow request may not get because its headers flush before the result
127
+ * exists.
123
128
  *
124
129
  * Every field is present only when it was measured, and the whole block is
125
130
  * omitted when nothing was (an older worker reports no timings at all).
@@ -142,6 +147,8 @@ interface PendraTiming {
142
147
  model_load_ms?: number;
143
148
  /** `true` when the model had to be loaded for this request. */
144
149
  cold_start?: boolean;
150
+ /** Share of draft tokens the model kept, 0-1. Present only when the request speculated. */
151
+ draft_acceptance_rate?: number;
145
152
  }
146
153
  /**
147
154
  * One web-tool step a model ran while answering — reported only when the
@@ -539,6 +546,12 @@ interface EmbeddingCreateParams {
539
546
  input: string | string[];
540
547
  encoding_format?: "float" | "base64";
541
548
  dimensions?: number;
549
+ /**
550
+ * What the text is for: `"document"` (the default) for text you store and
551
+ * search over, `"query"` for a search against it, `"none"` to embed the text
552
+ * exactly as sent. Pendra formats the input the way the model expects.
553
+ */
554
+ input_type?: "query" | "document" | "none";
542
555
  user?: string;
543
556
  /** Pin to a specific worker (sent as the `X-Pendra-Worker-Id` header). */
544
557
  worker_id?: string | null;
@@ -1028,4 +1041,5 @@ declare class APIStreamError extends APIError {
1028
1041
  });
1029
1042
  }
1030
1043
 
1031
- export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, type APIStatusErrorOptions, APIStreamError, type AudioFileInput, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionContentPart, type ChatCompletionCreateParams, type ChatCompletionMessage, type ChatCompletionMessageParam, type ChatCompletionMessageToolCall, type Choice, type ChoiceDelta, type CompletionTokensDetails, type CreateEmbeddingResponse, type Embedding, type EmbeddingCreateParams, type EmbeddingUsage, type ImageData, type ImageGenerationCreateParams, type ImageResponse, type Model, type ModerationCreateParams, type ModerationImageURLInput, type ModerationInput, type ModerationInputPart, type ModerationResponse, type ModerationResult, type ModerationTextInput, Pendra, type PendraExtension, type PendraNotice, type PendraOptions, type PendraTiming, type PendraWebToolStep, type PendraWorker, PrivateInferenceError, RateLimitError, type RerankCreateParams, type RerankResponse, type RerankResult, type RerankResultDocument, type SpeechCreateParams, type SpeechResponse, Stream, type StreamChoice, type TranscriptionCreateParams, type TranscriptionResponse, type TranscriptionSegment, type Usage, Pendra as default };
1044
+ export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APIStreamError, AuthenticationError, Pendra, PrivateInferenceError, RateLimitError, Stream, Pendra as default };
1045
+ 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 };
package/dist/index.js CHANGED
@@ -1640,6 +1640,7 @@ var Embeddings = class {
1640
1640
  };
1641
1641
  if (params.encoding_format != null) body.encoding_format = params.encoding_format;
1642
1642
  if (params.dimensions != null) body.dimensions = params.dimensions;
1643
+ if (params.input_type != null) body.input_type = params.input_type;
1643
1644
  if (params.user != null) body.user = params.user;
1644
1645
  const headers = params.worker_id ? { "X-Pendra-Worker-Id": params.worker_id } : void 0;
1645
1646
  if (this.client.privateInferenceEnabled) {
@@ -1956,7 +1957,7 @@ var Rerank = class {
1956
1957
  };
1957
1958
 
1958
1959
  // src/version.ts
1959
- var VERSION = "0.18.1";
1960
+ var VERSION = "0.20.0";
1960
1961
  var USER_AGENT = `pendra-node/${VERSION}`;
1961
1962
 
1962
1963
  // src/client.ts