@kreuzberg/liter-llm-node 1.6.4 → 1.7.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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:bfb3bc291787eb8f5228b353fec6c4ba65c5bcc3438beaff9afb5b0cc9c3aa87
|
|
3
3
|
// To regenerate: alef generate
|
|
4
4
|
// To verify freshness: alef verify --exit-code
|
|
5
5
|
/* eslint-disable */
|
|
@@ -154,6 +154,26 @@ export declare function createClient(
|
|
|
154
154
|
*/
|
|
155
155
|
export declare function createClientFromJson(json: string): DefaultClient;
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Decode a base64 data URL into [`DecodedDataUrl`].
|
|
159
|
+
*
|
|
160
|
+
* Returns `None` for:
|
|
161
|
+
* - Non-data URLs (strings that do not start with `"data:"`).
|
|
162
|
+
* - Malformed prefixes (missing `";base64,"` marker).
|
|
163
|
+
* - Invalid base64 payloads.
|
|
164
|
+
*
|
|
165
|
+
* The returned MIME string is extracted verbatim from the URL prefix —
|
|
166
|
+
* it is not validated or normalised.
|
|
167
|
+
*/
|
|
168
|
+
export declare function decodeDataUrl(url: string): DecodedDataUrl | null;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Encode bytes as a base64 data URL: `data:<mime>;base64,<b64>`.
|
|
172
|
+
*
|
|
173
|
+
* `mime` defaults to [`IMAGE_PNG`] when `None`.
|
|
174
|
+
*/
|
|
175
|
+
export declare function encodeDataUrl(bytes: Uint8Array, mime?: string | undefined | null): string;
|
|
176
|
+
|
|
157
177
|
/**
|
|
158
178
|
* Install the `ring` crypto provider as the rustls process default, idempotently.
|
|
159
179
|
*
|
|
@@ -174,10 +194,29 @@ export declare function createClientFromJson(json: string): DefaultClient;
|
|
|
174
194
|
*/
|
|
175
195
|
export declare function ensureCryptoProvider(): void;
|
|
176
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Content shape for assistant messages.
|
|
199
|
+
*
|
|
200
|
+
* `#[serde(untagged)]` means providers returning a plain scalar string for the
|
|
201
|
+
* `content` field still deserialise correctly into `AssistantContent::Text(_)`.
|
|
202
|
+
* Providers returning an array of typed parts (e.g. after an image-generation
|
|
203
|
+
* or audio-synthesis request) deserialise into `AssistantContent::Parts(_)`.
|
|
204
|
+
*/
|
|
205
|
+
export declare enum AssistantContent {
|
|
206
|
+
/** Plain text response (the common case for text-only models). */
|
|
207
|
+
Text = "Text",
|
|
208
|
+
/** Structured parts — text, refusals, output images, output audio. */
|
|
209
|
+
Parts = "Parts",
|
|
210
|
+
}
|
|
211
|
+
|
|
177
212
|
/** Assistant's response to a user message. */
|
|
178
213
|
export interface AssistantMessage {
|
|
179
|
-
/**
|
|
180
|
-
|
|
214
|
+
/**
|
|
215
|
+
* The assistant's response: plain text, structured parts, or absent.
|
|
216
|
+
*
|
|
217
|
+
* `None` is valid when the model replies with tool calls only.
|
|
218
|
+
*/
|
|
219
|
+
readonly content?: AssistantContent;
|
|
181
220
|
/** Optional name for the assistant. */
|
|
182
221
|
readonly name?: string;
|
|
183
222
|
/** Tool calls the model wants to execute, if any. */
|
|
@@ -188,6 +227,18 @@ export interface AssistantMessage {
|
|
|
188
227
|
readonly functionCall?: FunctionCall;
|
|
189
228
|
}
|
|
190
229
|
|
|
230
|
+
/**
|
|
231
|
+
* One part of a structured assistant response.
|
|
232
|
+
*
|
|
233
|
+
* `#[serde(tag = "type", rename_all = "snake_case")]` matches OpenAI's
|
|
234
|
+
* parts-spec discriminator (`"type": "text"`, `"type": "output_image"`, …).
|
|
235
|
+
*/
|
|
236
|
+
export type AssistantPart =
|
|
237
|
+
| { type: "text"; text: string }
|
|
238
|
+
| { type: "refusal"; refusal: string }
|
|
239
|
+
| { type: "output_image"; imageUrl: ImageUrl }
|
|
240
|
+
| { type: "output_audio"; audio: AudioContent };
|
|
241
|
+
|
|
191
242
|
/** Audio content part for speech-capable models. */
|
|
192
243
|
export interface AudioContent {
|
|
193
244
|
/** Base64-encoded audio data. */
|
|
@@ -411,6 +462,13 @@ export interface ChatCompletionRequest {
|
|
|
411
462
|
readonly seed?: number;
|
|
412
463
|
/** Reasoning effort level (low, medium, high) for extended-thinking models. */
|
|
413
464
|
readonly reasoningEffort?: ReasoningEffort;
|
|
465
|
+
/**
|
|
466
|
+
* Output modalities to request from the model.
|
|
467
|
+
*
|
|
468
|
+
* For OpenAI audio models, pass `["text", "audio"]`. Vertex AI / Gemini
|
|
469
|
+
* translates these to `generationConfig.responseModalities` (uppercase).
|
|
470
|
+
*/
|
|
471
|
+
readonly modalities?: Array<Modality>;
|
|
414
472
|
/**
|
|
415
473
|
* Provider-specific extra parameters merged into the request body.
|
|
416
474
|
* Use for guardrails, safety settings, grounding config, etc.
|
|
@@ -591,7 +649,7 @@ export interface CreateTranscriptionRequest {
|
|
|
591
649
|
export interface CustomProviderConfig {
|
|
592
650
|
/** Unique name for this provider (e.g., "my-provider"). */
|
|
593
651
|
readonly name: string;
|
|
594
|
-
/** Base URL for the provider's API (e.g.,
|
|
652
|
+
/** Base URL for the provider's API (e.g., `<https://api.my-provider.com/v1>`). */
|
|
595
653
|
readonly baseUrl: string;
|
|
596
654
|
/** Authentication header format. */
|
|
597
655
|
readonly authHeader: AuthHeaderFormat;
|
|
@@ -599,6 +657,19 @@ export interface CustomProviderConfig {
|
|
|
599
657
|
readonly modelPrefixes: Array<string>;
|
|
600
658
|
}
|
|
601
659
|
|
|
660
|
+
/**
|
|
661
|
+
* Result of decoding a `data:` URL — MIME type and the decoded byte payload.
|
|
662
|
+
*
|
|
663
|
+
* Named struct (rather than a tuple) so polyglot bindings can extract
|
|
664
|
+
* `decode_data_url` with a typed return rather than a sanitized scalar.
|
|
665
|
+
*/
|
|
666
|
+
export interface DecodedDataUrl {
|
|
667
|
+
/** MIME type extracted from the URL prefix (verbatim, not normalised). */
|
|
668
|
+
readonly mime?: string;
|
|
669
|
+
/** Decoded base64 payload. */
|
|
670
|
+
readonly data?: Uint8Array;
|
|
671
|
+
}
|
|
672
|
+
|
|
602
673
|
/**
|
|
603
674
|
* Default client implementation backed by `reqwest`.
|
|
604
675
|
*
|
|
@@ -944,6 +1015,21 @@ export type Message =
|
|
|
944
1015
|
| { role: "developer"; 0: DeveloperMessage }
|
|
945
1016
|
| { role: "function"; 0: FunctionMessage };
|
|
946
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Output modality requested from the model.
|
|
1020
|
+
*
|
|
1021
|
+
* Passed as `modalities: ["text", "audio"]` (OpenAI) or translated to
|
|
1022
|
+
* `generationConfig.responseModalities` (Gemini / Vertex AI).
|
|
1023
|
+
*/
|
|
1024
|
+
export declare enum Modality {
|
|
1025
|
+
/** Text output (the default for all providers). */
|
|
1026
|
+
Text = "text",
|
|
1027
|
+
/** Audio / speech output. */
|
|
1028
|
+
Audio = "audio",
|
|
1029
|
+
/** Image output (Gemini Imagen, gpt-image-1). */
|
|
1030
|
+
Image = "image",
|
|
1031
|
+
}
|
|
1032
|
+
|
|
947
1033
|
/** A model available from the API. */
|
|
948
1034
|
export interface ModelObject {
|
|
949
1035
|
/** Model ID (e.g., `"gpt-4o"`, `"claude-3-5-sonnet"`). */
|
|
@@ -1194,7 +1280,7 @@ export interface ProviderConfig {
|
|
|
1194
1280
|
*
|
|
1195
1281
|
* Each entry maps an OpenAI-spec field name (e.g. `"max_completion_tokens"`)
|
|
1196
1282
|
* to the name this provider expects (e.g. `"max_tokens"`). Applied
|
|
1197
|
-
* automatically by
|
|
1283
|
+
* automatically by `ConfigDrivenProvider::transform_request`.
|
|
1198
1284
|
*/
|
|
1199
1285
|
readonly paramMappings?: Record<string, string>;
|
|
1200
1286
|
}
|
|
@@ -1264,7 +1350,24 @@ export interface RerankResultDocument {
|
|
|
1264
1350
|
readonly text: string;
|
|
1265
1351
|
}
|
|
1266
1352
|
|
|
1267
|
-
/**
|
|
1353
|
+
/**
|
|
1354
|
+
* Wire format for the chat completions `response_format` field.
|
|
1355
|
+
*
|
|
1356
|
+
* # Provider mapping
|
|
1357
|
+
*
|
|
1358
|
+
* - **OpenAI** (and OpenAI-compatible providers): emitted verbatim as
|
|
1359
|
+
* `{"type": "json_schema", "json_schema": {...}}` per the
|
|
1360
|
+
* chat-completions spec.
|
|
1361
|
+
* - **Gemini / Vertex AI**: translated to
|
|
1362
|
+
* `generationConfig.responseMimeType = "application/json"` and
|
|
1363
|
+
* `generationConfig.responseSchema = <schema>`. The `name`,
|
|
1364
|
+
* `description`, and `strict` fields are dropped — Gemini's
|
|
1365
|
+
* structured-output API does not consume them.
|
|
1366
|
+
* - **Anthropic**: no native JSON mode. A system instruction is
|
|
1367
|
+
* prepended asking the model to respond with valid JSON.
|
|
1368
|
+
* `strict` is advisory only; callers should still validate the
|
|
1369
|
+
* returned JSON if the schema is load-bearing.
|
|
1370
|
+
*/
|
|
1268
1371
|
export type ResponseFormat =
|
|
1269
1372
|
| { type: "text" }
|
|
1270
1373
|
| { type: "json_object" }
|
|
@@ -1447,8 +1550,13 @@ export interface StreamToolCall {
|
|
|
1447
1550
|
|
|
1448
1551
|
/** System message guiding model behavior for the entire conversation. */
|
|
1449
1552
|
export interface SystemMessage {
|
|
1450
|
-
/**
|
|
1451
|
-
|
|
1553
|
+
/**
|
|
1554
|
+
* Instructions or context that apply throughout the conversation.
|
|
1555
|
+
*
|
|
1556
|
+
* Accepts either a plain text string or an array of content parts,
|
|
1557
|
+
* mirroring [`UserContent`] so that `Message::system_with_parts` works.
|
|
1558
|
+
*/
|
|
1559
|
+
readonly content?: UserContent;
|
|
1452
1560
|
/** Optional name for the system message source. */
|
|
1453
1561
|
readonly name?: string;
|
|
1454
1562
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kreuzberg/liter-llm-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Universal LLM API client with Rust-powered polyglot bindings.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"@napi-rs/cli": "^3.6.2"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@kreuzberg/liter-llm-node-darwin-arm64": "1.
|
|
37
|
-
"@kreuzberg/liter-llm-node-darwin-x64": "1.
|
|
38
|
-
"@kreuzberg/liter-llm-node-linux-arm64-gnu": "1.
|
|
39
|
-
"@kreuzberg/liter-llm-node-linux-x64-gnu": "1.
|
|
40
|
-
"@kreuzberg/liter-llm-node-win32-arm64-msvc": "1.
|
|
41
|
-
"@kreuzberg/liter-llm-node-win32-x64-msvc": "1.
|
|
36
|
+
"@kreuzberg/liter-llm-node-darwin-arm64": "1.7.0",
|
|
37
|
+
"@kreuzberg/liter-llm-node-darwin-x64": "1.7.0",
|
|
38
|
+
"@kreuzberg/liter-llm-node-linux-arm64-gnu": "1.7.0",
|
|
39
|
+
"@kreuzberg/liter-llm-node-linux-x64-gnu": "1.7.0",
|
|
40
|
+
"@kreuzberg/liter-llm-node-win32-arm64-msvc": "1.7.0",
|
|
41
|
+
"@kreuzberg/liter-llm-node-win32-x64-msvc": "1.7.0"
|
|
42
42
|
},
|
|
43
43
|
"napi": {
|
|
44
44
|
"binaryName": "liter-llm-node",
|