pendra 0.6.1 → 0.9.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.d.mts +60 -9
- package/dist/index.d.ts +60 -9
- package/dist/index.js +185 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +179 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -49,9 +49,24 @@ interface Usage {
|
|
|
49
49
|
completion_tokens: number;
|
|
50
50
|
total_tokens: number;
|
|
51
51
|
}
|
|
52
|
+
interface ChatCompletionMessageToolCall {
|
|
53
|
+
/**
|
|
54
|
+
* Streaming only. A streamed tool call arrives as fragments, and `index` is
|
|
55
|
+
* what says which call each fragment belongs to. Absent on a non-streaming
|
|
56
|
+
* message, where every call arrives complete in one piece.
|
|
57
|
+
*/
|
|
58
|
+
index?: number;
|
|
59
|
+
id: string;
|
|
60
|
+
type: string;
|
|
61
|
+
function: {
|
|
62
|
+
name: string;
|
|
63
|
+
arguments: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
52
66
|
interface ChatCompletionMessage {
|
|
53
67
|
role: string;
|
|
54
68
|
content: string | null;
|
|
69
|
+
tool_calls?: ChatCompletionMessageToolCall[];
|
|
55
70
|
}
|
|
56
71
|
interface Choice {
|
|
57
72
|
index: number;
|
|
@@ -69,6 +84,7 @@ interface ChatCompletion {
|
|
|
69
84
|
interface ChoiceDelta {
|
|
70
85
|
role?: string | null;
|
|
71
86
|
content?: string | null;
|
|
87
|
+
tool_calls?: ChatCompletionMessageToolCall[];
|
|
72
88
|
}
|
|
73
89
|
interface StreamChoice {
|
|
74
90
|
index: number;
|
|
@@ -91,8 +107,31 @@ interface ChatCompletionCreateParams {
|
|
|
91
107
|
temperature?: number | null;
|
|
92
108
|
max_tokens?: number | null;
|
|
93
109
|
top_p?: number | null;
|
|
110
|
+
/** Keep only the `top_k` most likely tokens (0 = off). */
|
|
111
|
+
top_k?: number | null;
|
|
112
|
+
/** Drop tokens less likely than `min_p` × the top token's probability. */
|
|
113
|
+
min_p?: number | null;
|
|
114
|
+
/** Penalise tokens by how often they've appeared (-2 to 2; 0 = off). */
|
|
115
|
+
frequency_penalty?: number | null;
|
|
116
|
+
/** Penalise tokens that have appeared at all (-2 to 2; 0 = off). */
|
|
117
|
+
presence_penalty?: number | null;
|
|
118
|
+
/** Classic repetition penalty (1.0 = off; e.g. 1.1–1.3 discourages repeats). */
|
|
119
|
+
repeat_penalty?: number | null;
|
|
120
|
+
/** Seed the sampler for reproducible output. */
|
|
121
|
+
seed?: number | null;
|
|
94
122
|
stop?: string | string[] | null;
|
|
95
123
|
stream?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Functions the model may call, in the OpenAI tools format. When the model
|
|
126
|
+
* calls one, the reply's `choices[0].message.tool_calls` is populated and
|
|
127
|
+
* `finish_reason` is `"tool_calls"`; you run the function and send the result
|
|
128
|
+
* back as a `{ role: "tool", ... }` message.
|
|
129
|
+
*/
|
|
130
|
+
tools?: Array<Record<string, unknown>> | null;
|
|
131
|
+
/** `"auto"`, `"none"`, or a specific function to force. */
|
|
132
|
+
tool_choice?: unknown;
|
|
133
|
+
/** Allow the model to request several tool calls in one reply. */
|
|
134
|
+
parallel_tool_calls?: boolean | null;
|
|
96
135
|
/**
|
|
97
136
|
* Optionally pin the request to a specific worker that serves this model.
|
|
98
137
|
* Sent as the `X-Pendra-Worker-Id` header; when omitted, the least-busy
|
|
@@ -101,10 +140,18 @@ interface ChatCompletionCreateParams {
|
|
|
101
140
|
worker_id?: string | null;
|
|
102
141
|
}
|
|
103
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Async-iterable reader for a streaming chat completion.
|
|
145
|
+
*
|
|
146
|
+
* Framing is handled by {@link SseDecoder}, which assembles whole SSE frames
|
|
147
|
+
* rather than filtering lines — so a frame the server tags with a named
|
|
148
|
+
* `event:` is dropped in one piece instead of having its `data:` line mistaken
|
|
149
|
+
* for a chat chunk (issue #1398).
|
|
150
|
+
*/
|
|
104
151
|
declare class Stream implements AsyncIterable<ChatCompletionChunk> {
|
|
105
152
|
private reader;
|
|
106
153
|
private decoder;
|
|
107
|
-
private
|
|
154
|
+
private sse;
|
|
108
155
|
private done;
|
|
109
156
|
private controller;
|
|
110
157
|
constructor(response: Response, controller: AbortController);
|
|
@@ -324,20 +371,24 @@ interface EngineOptions {
|
|
|
324
371
|
declare class PrivateInferenceEngine {
|
|
325
372
|
private baseUrl;
|
|
326
373
|
private apiKey;
|
|
327
|
-
private
|
|
374
|
+
private pinnedFingerprints;
|
|
328
375
|
private affinitySalt;
|
|
329
376
|
private tofuPath;
|
|
330
|
-
private
|
|
377
|
+
private orgPubs;
|
|
331
378
|
constructor(opts: EngineOptions);
|
|
379
|
+
cachedOrgPublicKeys(): Uint8Array[] | null;
|
|
332
380
|
cachedOrgPublicKey(): Uint8Array | null;
|
|
333
381
|
private tofuIdentity;
|
|
334
382
|
/**
|
|
335
|
-
* Validate the key(s) returned by GET /v1/private-inference/key
|
|
336
|
-
*
|
|
337
|
-
*
|
|
383
|
+
* Validate the key(s) returned by GET /v1/private-inference/key, apply the pin
|
|
384
|
+
* allowlist (or auto-trust TOFU), cache the accepted public keys, and return
|
|
385
|
+
* them (newest-seen first). The client seals to **all** of the returned keys
|
|
386
|
+
* so any worker holding any of them can serve the request. Throws
|
|
387
|
+
* PrivateInferenceError on absence, a malformed key, or (when pinned) an empty
|
|
388
|
+
* intersection with the pin set.
|
|
338
389
|
*/
|
|
339
|
-
resolveOrgKey(fetchedKeys: FetchedKey[]): Promise<Uint8Array>;
|
|
340
|
-
private
|
|
390
|
+
resolveOrgKey(fetchedKeys: FetchedKey[]): Promise<Uint8Array[]>;
|
|
391
|
+
private tofuTrust;
|
|
341
392
|
private loadTofu;
|
|
342
393
|
private saveTofu;
|
|
343
394
|
/**
|
|
@@ -428,4 +479,4 @@ declare class RateLimitError extends APIStatusError {
|
|
|
428
479
|
constructor(message?: string);
|
|
429
480
|
}
|
|
430
481
|
|
|
431
|
-
export { APIConnectionError, APIError, APIStatusError, type AudioFileInput, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionMessage, type Choice, type ChoiceDelta, type CreateEmbeddingResponse, type Embedding, type EmbeddingCreateParams, type EmbeddingUsage, type ImageData, type ImageGenerationCreateParams, type ImageResponse, type Model, Pendra, type PendraOptions, PrivateInferenceError, RateLimitError, type RerankCreateParams, type RerankResponse, type RerankResult, type RerankResultDocument, Stream, type StreamChoice, type TranscriptionCreateParams, type TranscriptionResponse, type TranscriptionSegment, type Usage, Pendra as default };
|
|
482
|
+
export { APIConnectionError, APIError, APIStatusError, type AudioFileInput, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionMessage, type ChatCompletionMessageToolCall, type Choice, type ChoiceDelta, type CreateEmbeddingResponse, type Embedding, type EmbeddingCreateParams, type EmbeddingUsage, type ImageData, type ImageGenerationCreateParams, type ImageResponse, type Model, Pendra, type PendraOptions, PrivateInferenceError, RateLimitError, type RerankCreateParams, type RerankResponse, type RerankResult, type RerankResultDocument, Stream, type StreamChoice, type TranscriptionCreateParams, type TranscriptionResponse, type TranscriptionSegment, type Usage, Pendra as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -49,9 +49,24 @@ interface Usage {
|
|
|
49
49
|
completion_tokens: number;
|
|
50
50
|
total_tokens: number;
|
|
51
51
|
}
|
|
52
|
+
interface ChatCompletionMessageToolCall {
|
|
53
|
+
/**
|
|
54
|
+
* Streaming only. A streamed tool call arrives as fragments, and `index` is
|
|
55
|
+
* what says which call each fragment belongs to. Absent on a non-streaming
|
|
56
|
+
* message, where every call arrives complete in one piece.
|
|
57
|
+
*/
|
|
58
|
+
index?: number;
|
|
59
|
+
id: string;
|
|
60
|
+
type: string;
|
|
61
|
+
function: {
|
|
62
|
+
name: string;
|
|
63
|
+
arguments: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
52
66
|
interface ChatCompletionMessage {
|
|
53
67
|
role: string;
|
|
54
68
|
content: string | null;
|
|
69
|
+
tool_calls?: ChatCompletionMessageToolCall[];
|
|
55
70
|
}
|
|
56
71
|
interface Choice {
|
|
57
72
|
index: number;
|
|
@@ -69,6 +84,7 @@ interface ChatCompletion {
|
|
|
69
84
|
interface ChoiceDelta {
|
|
70
85
|
role?: string | null;
|
|
71
86
|
content?: string | null;
|
|
87
|
+
tool_calls?: ChatCompletionMessageToolCall[];
|
|
72
88
|
}
|
|
73
89
|
interface StreamChoice {
|
|
74
90
|
index: number;
|
|
@@ -91,8 +107,31 @@ interface ChatCompletionCreateParams {
|
|
|
91
107
|
temperature?: number | null;
|
|
92
108
|
max_tokens?: number | null;
|
|
93
109
|
top_p?: number | null;
|
|
110
|
+
/** Keep only the `top_k` most likely tokens (0 = off). */
|
|
111
|
+
top_k?: number | null;
|
|
112
|
+
/** Drop tokens less likely than `min_p` × the top token's probability. */
|
|
113
|
+
min_p?: number | null;
|
|
114
|
+
/** Penalise tokens by how often they've appeared (-2 to 2; 0 = off). */
|
|
115
|
+
frequency_penalty?: number | null;
|
|
116
|
+
/** Penalise tokens that have appeared at all (-2 to 2; 0 = off). */
|
|
117
|
+
presence_penalty?: number | null;
|
|
118
|
+
/** Classic repetition penalty (1.0 = off; e.g. 1.1–1.3 discourages repeats). */
|
|
119
|
+
repeat_penalty?: number | null;
|
|
120
|
+
/** Seed the sampler for reproducible output. */
|
|
121
|
+
seed?: number | null;
|
|
94
122
|
stop?: string | string[] | null;
|
|
95
123
|
stream?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Functions the model may call, in the OpenAI tools format. When the model
|
|
126
|
+
* calls one, the reply's `choices[0].message.tool_calls` is populated and
|
|
127
|
+
* `finish_reason` is `"tool_calls"`; you run the function and send the result
|
|
128
|
+
* back as a `{ role: "tool", ... }` message.
|
|
129
|
+
*/
|
|
130
|
+
tools?: Array<Record<string, unknown>> | null;
|
|
131
|
+
/** `"auto"`, `"none"`, or a specific function to force. */
|
|
132
|
+
tool_choice?: unknown;
|
|
133
|
+
/** Allow the model to request several tool calls in one reply. */
|
|
134
|
+
parallel_tool_calls?: boolean | null;
|
|
96
135
|
/**
|
|
97
136
|
* Optionally pin the request to a specific worker that serves this model.
|
|
98
137
|
* Sent as the `X-Pendra-Worker-Id` header; when omitted, the least-busy
|
|
@@ -101,10 +140,18 @@ interface ChatCompletionCreateParams {
|
|
|
101
140
|
worker_id?: string | null;
|
|
102
141
|
}
|
|
103
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Async-iterable reader for a streaming chat completion.
|
|
145
|
+
*
|
|
146
|
+
* Framing is handled by {@link SseDecoder}, which assembles whole SSE frames
|
|
147
|
+
* rather than filtering lines — so a frame the server tags with a named
|
|
148
|
+
* `event:` is dropped in one piece instead of having its `data:` line mistaken
|
|
149
|
+
* for a chat chunk (issue #1398).
|
|
150
|
+
*/
|
|
104
151
|
declare class Stream implements AsyncIterable<ChatCompletionChunk> {
|
|
105
152
|
private reader;
|
|
106
153
|
private decoder;
|
|
107
|
-
private
|
|
154
|
+
private sse;
|
|
108
155
|
private done;
|
|
109
156
|
private controller;
|
|
110
157
|
constructor(response: Response, controller: AbortController);
|
|
@@ -324,20 +371,24 @@ interface EngineOptions {
|
|
|
324
371
|
declare class PrivateInferenceEngine {
|
|
325
372
|
private baseUrl;
|
|
326
373
|
private apiKey;
|
|
327
|
-
private
|
|
374
|
+
private pinnedFingerprints;
|
|
328
375
|
private affinitySalt;
|
|
329
376
|
private tofuPath;
|
|
330
|
-
private
|
|
377
|
+
private orgPubs;
|
|
331
378
|
constructor(opts: EngineOptions);
|
|
379
|
+
cachedOrgPublicKeys(): Uint8Array[] | null;
|
|
332
380
|
cachedOrgPublicKey(): Uint8Array | null;
|
|
333
381
|
private tofuIdentity;
|
|
334
382
|
/**
|
|
335
|
-
* Validate the key(s) returned by GET /v1/private-inference/key
|
|
336
|
-
*
|
|
337
|
-
*
|
|
383
|
+
* Validate the key(s) returned by GET /v1/private-inference/key, apply the pin
|
|
384
|
+
* allowlist (or auto-trust TOFU), cache the accepted public keys, and return
|
|
385
|
+
* them (newest-seen first). The client seals to **all** of the returned keys
|
|
386
|
+
* so any worker holding any of them can serve the request. Throws
|
|
387
|
+
* PrivateInferenceError on absence, a malformed key, or (when pinned) an empty
|
|
388
|
+
* intersection with the pin set.
|
|
338
389
|
*/
|
|
339
|
-
resolveOrgKey(fetchedKeys: FetchedKey[]): Promise<Uint8Array>;
|
|
340
|
-
private
|
|
390
|
+
resolveOrgKey(fetchedKeys: FetchedKey[]): Promise<Uint8Array[]>;
|
|
391
|
+
private tofuTrust;
|
|
341
392
|
private loadTofu;
|
|
342
393
|
private saveTofu;
|
|
343
394
|
/**
|
|
@@ -428,4 +479,4 @@ declare class RateLimitError extends APIStatusError {
|
|
|
428
479
|
constructor(message?: string);
|
|
429
480
|
}
|
|
430
481
|
|
|
431
|
-
export { APIConnectionError, APIError, APIStatusError, type AudioFileInput, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionMessage, type Choice, type ChoiceDelta, type CreateEmbeddingResponse, type Embedding, type EmbeddingCreateParams, type EmbeddingUsage, type ImageData, type ImageGenerationCreateParams, type ImageResponse, type Model, Pendra, type PendraOptions, PrivateInferenceError, RateLimitError, type RerankCreateParams, type RerankResponse, type RerankResult, type RerankResultDocument, Stream, type StreamChoice, type TranscriptionCreateParams, type TranscriptionResponse, type TranscriptionSegment, type Usage, Pendra as default };
|
|
482
|
+
export { APIConnectionError, APIError, APIStatusError, type AudioFileInput, AuthenticationError, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionMessage, type ChatCompletionMessageToolCall, type Choice, type ChoiceDelta, type CreateEmbeddingResponse, type Embedding, type EmbeddingCreateParams, type EmbeddingUsage, type ImageData, type ImageGenerationCreateParams, type ImageResponse, type Model, Pendra, type PendraOptions, PrivateInferenceError, RateLimitError, type RerankCreateParams, type RerankResponse, type RerankResult, type RerankResultDocument, Stream, type StreamChoice, type TranscriptionCreateParams, type TranscriptionResponse, type TranscriptionSegment, type Usage, Pendra as default };
|