@jambonz/llm 0.5.7 → 0.6.1
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 +197 -9
- 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 +197 -9
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +197 -9
- 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 +197 -9
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-rZZBXYhB.d.cts → types-Y0o6rN3B.d.cts} +35 -0
- package/dist/{types-rZZBXYhB.d.ts → types-Y0o6rN3B.d.ts} +35 -0
- package/package.json +1 -1
|
@@ -84,6 +84,24 @@ interface PromptRequest {
|
|
|
84
84
|
providerParams?: Record<string, unknown>;
|
|
85
85
|
/** Abort the stream. Adapters MUST honor this and propagate to the vendor SDK. */
|
|
86
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;
|
|
87
105
|
}
|
|
88
106
|
type LlmEvent = {
|
|
89
107
|
type: 'token';
|
|
@@ -145,9 +163,26 @@ type ToolCallEvent = Extract<LlmEvent, {
|
|
|
145
163
|
}>;
|
|
146
164
|
type FinishReason = 'stop' | 'tool' | 'length' | 'filtered' | 'error' | 'aborted';
|
|
147
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
|
+
*/
|
|
148
174
|
inputTokens?: number;
|
|
149
175
|
outputTokens?: number;
|
|
176
|
+
/** Vendor-reported grand total across all token classes. */
|
|
150
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;
|
|
151
186
|
}
|
|
152
187
|
type AuthSpec = ApiKeyAuth | AzureOpenAIApiKeyAuth | BedrockIamAuth | BedrockApiKeyAuth | GoogleApiKeyAuth | GoogleServiceAccountAuth | VertexServiceAccountAuth;
|
|
153
188
|
interface ApiKeyAuth {
|
|
@@ -84,6 +84,24 @@ interface PromptRequest {
|
|
|
84
84
|
providerParams?: Record<string, unknown>;
|
|
85
85
|
/** Abort the stream. Adapters MUST honor this and propagate to the vendor SDK. */
|
|
86
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;
|
|
87
105
|
}
|
|
88
106
|
type LlmEvent = {
|
|
89
107
|
type: 'token';
|
|
@@ -145,9 +163,26 @@ type ToolCallEvent = Extract<LlmEvent, {
|
|
|
145
163
|
}>;
|
|
146
164
|
type FinishReason = 'stop' | 'tool' | 'length' | 'filtered' | 'error' | 'aborted';
|
|
147
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
|
+
*/
|
|
148
174
|
inputTokens?: number;
|
|
149
175
|
outputTokens?: number;
|
|
176
|
+
/** Vendor-reported grand total across all token classes. */
|
|
150
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;
|
|
151
186
|
}
|
|
152
187
|
type AuthSpec = ApiKeyAuth | AzureOpenAIApiKeyAuth | BedrockIamAuth | BedrockApiKeyAuth | GoogleApiKeyAuth | GoogleServiceAccountAuth | VertexServiceAccountAuth;
|
|
153
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.1",
|
|
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",
|