@jambonz/llm 0.5.6 → 0.6.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 +162 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +162 -7
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +162 -7
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +1 -1
- package/dist/test-kit/index.d.ts +1 -1
- package/dist/test-kit/index.js +162 -7
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-BEgQaQIb.d.cts → types-Y0o6rN3B.d.cts} +45 -0
- package/dist/{types-BEgQaQIb.d.ts → types-Y0o6rN3B.d.ts} +45 -0
- package/package.json +1 -1
|
@@ -72,8 +72,36 @@ interface PromptRequest {
|
|
|
72
72
|
tools?: Tool[];
|
|
73
73
|
temperature?: number;
|
|
74
74
|
maxTokens?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Provider-specific request-body parameters merged verbatim into the
|
|
77
|
+
* outgoing request by OpenAI-compatible adapters. Opt-in escape hatch for
|
|
78
|
+
* fields the typed interface does not model — e.g. a vLLM/Mantle-served
|
|
79
|
+
* Kimi endpoint's `{chat_template_kwargs: {enable_thinking: false}}` to
|
|
80
|
+
* suppress chain-of-thought. Never sent unless set. Keys that collide with
|
|
81
|
+
* library-managed fields (model, messages, stream, tools, …) are ignored,
|
|
82
|
+
* so this can only add parameters, never override core request shape.
|
|
83
|
+
*/
|
|
84
|
+
providerParams?: Record<string, unknown>;
|
|
75
85
|
/** Abort the stream. Adapters MUST honor this and propagate to the vendor SDK. */
|
|
76
86
|
signal?: AbortSignal;
|
|
87
|
+
/**
|
|
88
|
+
* Caller-supplied prompt-caching routing/grouping hint.
|
|
89
|
+
*
|
|
90
|
+
* NOT a secret and NOT a tenant isolation boundary. Cache hits still require
|
|
91
|
+
* a byte-identical prefix, and vendors isolate caches per org/workspace
|
|
92
|
+
* regardless of this value.
|
|
93
|
+
*
|
|
94
|
+
* Adapter behaviour:
|
|
95
|
+
* - OpenAI-wire adapters (openai, azure-openai, groq, etc.) forward it as
|
|
96
|
+
* `prompt_cache_key` on the request body.
|
|
97
|
+
* - Anthropic and Bedrock (Claude) use its PRESENCE to enable native cache
|
|
98
|
+
* breakpoints on the system prompt, the tool definitions, and the final
|
|
99
|
+
* message — so the entire conversation prefix is cached each turn.
|
|
100
|
+
* - Adapters without a caching mechanism (e.g. Google/Gemini) silently ignore it.
|
|
101
|
+
*
|
|
102
|
+
* The library never auto-derives this value from message content.
|
|
103
|
+
*/
|
|
104
|
+
cacheKey?: string;
|
|
77
105
|
}
|
|
78
106
|
type LlmEvent = {
|
|
79
107
|
type: 'token';
|
|
@@ -135,9 +163,26 @@ type ToolCallEvent = Extract<LlmEvent, {
|
|
|
135
163
|
}>;
|
|
136
164
|
type FinishReason = 'stop' | 'tool' | 'length' | 'filtered' | 'error' | 'aborted';
|
|
137
165
|
interface Usage {
|
|
166
|
+
/**
|
|
167
|
+
* UNCACHED input tokens. The three input classes (uncached, cache read,
|
|
168
|
+
* cache write) are additive and each has its own vendor price, so callers
|
|
169
|
+
* can meter/bill them independently. Adapters normalize to this convention:
|
|
170
|
+
* Anthropic/Bedrock already report exclusively; OpenAI-wire and Gemini
|
|
171
|
+
* report an inclusive prompt total and the adapter subtracts the cached
|
|
172
|
+
* portion out.
|
|
173
|
+
*/
|
|
138
174
|
inputTokens?: number;
|
|
139
175
|
outputTokens?: number;
|
|
176
|
+
/** Vendor-reported grand total across all token classes. */
|
|
140
177
|
totalTokens?: number;
|
|
178
|
+
/** Input tokens served from the vendor's prompt cache (discounted). */
|
|
179
|
+
cacheReadTokens?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Input tokens written to the vendor's prompt cache. Only Anthropic-family
|
|
182
|
+
* vendors bill cache writes (at a premium); vendors that don't report the
|
|
183
|
+
* class omit the field.
|
|
184
|
+
*/
|
|
185
|
+
cacheWriteTokens?: number;
|
|
141
186
|
}
|
|
142
187
|
type AuthSpec = ApiKeyAuth | AzureOpenAIApiKeyAuth | BedrockIamAuth | BedrockApiKeyAuth | GoogleApiKeyAuth | GoogleServiceAccountAuth | VertexServiceAccountAuth;
|
|
143
188
|
interface ApiKeyAuth {
|
|
@@ -72,8 +72,36 @@ interface PromptRequest {
|
|
|
72
72
|
tools?: Tool[];
|
|
73
73
|
temperature?: number;
|
|
74
74
|
maxTokens?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Provider-specific request-body parameters merged verbatim into the
|
|
77
|
+
* outgoing request by OpenAI-compatible adapters. Opt-in escape hatch for
|
|
78
|
+
* fields the typed interface does not model — e.g. a vLLM/Mantle-served
|
|
79
|
+
* Kimi endpoint's `{chat_template_kwargs: {enable_thinking: false}}` to
|
|
80
|
+
* suppress chain-of-thought. Never sent unless set. Keys that collide with
|
|
81
|
+
* library-managed fields (model, messages, stream, tools, …) are ignored,
|
|
82
|
+
* so this can only add parameters, never override core request shape.
|
|
83
|
+
*/
|
|
84
|
+
providerParams?: Record<string, unknown>;
|
|
75
85
|
/** Abort the stream. Adapters MUST honor this and propagate to the vendor SDK. */
|
|
76
86
|
signal?: AbortSignal;
|
|
87
|
+
/**
|
|
88
|
+
* Caller-supplied prompt-caching routing/grouping hint.
|
|
89
|
+
*
|
|
90
|
+
* NOT a secret and NOT a tenant isolation boundary. Cache hits still require
|
|
91
|
+
* a byte-identical prefix, and vendors isolate caches per org/workspace
|
|
92
|
+
* regardless of this value.
|
|
93
|
+
*
|
|
94
|
+
* Adapter behaviour:
|
|
95
|
+
* - OpenAI-wire adapters (openai, azure-openai, groq, etc.) forward it as
|
|
96
|
+
* `prompt_cache_key` on the request body.
|
|
97
|
+
* - Anthropic and Bedrock (Claude) use its PRESENCE to enable native cache
|
|
98
|
+
* breakpoints on the system prompt, the tool definitions, and the final
|
|
99
|
+
* message — so the entire conversation prefix is cached each turn.
|
|
100
|
+
* - Adapters without a caching mechanism (e.g. Google/Gemini) silently ignore it.
|
|
101
|
+
*
|
|
102
|
+
* The library never auto-derives this value from message content.
|
|
103
|
+
*/
|
|
104
|
+
cacheKey?: string;
|
|
77
105
|
}
|
|
78
106
|
type LlmEvent = {
|
|
79
107
|
type: 'token';
|
|
@@ -135,9 +163,26 @@ type ToolCallEvent = Extract<LlmEvent, {
|
|
|
135
163
|
}>;
|
|
136
164
|
type FinishReason = 'stop' | 'tool' | 'length' | 'filtered' | 'error' | 'aborted';
|
|
137
165
|
interface Usage {
|
|
166
|
+
/**
|
|
167
|
+
* UNCACHED input tokens. The three input classes (uncached, cache read,
|
|
168
|
+
* cache write) are additive and each has its own vendor price, so callers
|
|
169
|
+
* can meter/bill them independently. Adapters normalize to this convention:
|
|
170
|
+
* Anthropic/Bedrock already report exclusively; OpenAI-wire and Gemini
|
|
171
|
+
* report an inclusive prompt total and the adapter subtracts the cached
|
|
172
|
+
* portion out.
|
|
173
|
+
*/
|
|
138
174
|
inputTokens?: number;
|
|
139
175
|
outputTokens?: number;
|
|
176
|
+
/** Vendor-reported grand total across all token classes. */
|
|
140
177
|
totalTokens?: number;
|
|
178
|
+
/** Input tokens served from the vendor's prompt cache (discounted). */
|
|
179
|
+
cacheReadTokens?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Input tokens written to the vendor's prompt cache. Only Anthropic-family
|
|
182
|
+
* vendors bill cache writes (at a premium); vendors that don't report the
|
|
183
|
+
* class omit the field.
|
|
184
|
+
*/
|
|
185
|
+
cacheWriteTokens?: number;
|
|
141
186
|
}
|
|
142
187
|
type AuthSpec = ApiKeyAuth | AzureOpenAIApiKeyAuth | BedrockIamAuth | BedrockApiKeyAuth | GoogleApiKeyAuth | GoogleServiceAccountAuth | VertexServiceAccountAuth;
|
|
143
188
|
interface ApiKeyAuth {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jambonz/llm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Voice-oriented LLM adapter library — a uniform interface for streaming chat completions from multiple LLM vendors, with first-class support for tool calls, AbortSignal interruption, and lossless history round-tripping.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|