@jaypie/llm 1.3.17 → 1.3.19
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/cjs/index.cjs +21 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -1
- package/dist/cjs/types/LlmProvider.interface.d.ts +2 -1
- package/dist/cjs/util/cacheControl.d.ts +10 -2
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +21 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/LlmProvider.interface.d.ts +2 -1
- package/dist/esm/util/cacheControl.d.ts +10 -2
- package/package.json +1 -1
|
@@ -290,7 +290,8 @@ export interface LlmExchangeEnvelope {
|
|
|
290
290
|
export type LlmExchangeCallback = (envelope: LlmExchangeEnvelope) => unknown | Promise<unknown>;
|
|
291
291
|
/**
|
|
292
292
|
* Prompt-caching control for operate()/stream().
|
|
293
|
-
* - `true` / omitted → caching enabled at the default `"
|
|
293
|
+
* - `true` / omitted → caching enabled at the adapter's default TTL: `"1h"` on
|
|
294
|
+
* Anthropic, `"5m"` everywhere else
|
|
294
295
|
* - `false` / `0` → caching disabled
|
|
295
296
|
* - `"5m"` / `"1h"` → enabled at that TTL (TTL honored by Anthropic/OpenRouter;
|
|
296
297
|
* other providers ignore it and cache with their own defaults)
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { type LlmCache } from "../types/LlmProvider.interface.js";
|
|
2
2
|
export declare const CACHE_TTL_DEFAULT: "5m";
|
|
3
|
+
/**
|
|
4
|
+
* Anthropic bills a 1h cache write at 2x input (vs 1.25x for 5m) but reads at
|
|
5
|
+
* the same ~0.1x, so an hour of reuse pays for itself after ~three reads and
|
|
6
|
+
* survives the gaps between turns in a long agentic session.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CACHE_TTL_ANTHROPIC_DEFAULT: "1h";
|
|
3
9
|
export type CacheTtl = "5m" | "1h";
|
|
4
10
|
export interface ResolvedCache {
|
|
5
11
|
enabled: boolean;
|
|
@@ -7,11 +13,13 @@ export interface ResolvedCache {
|
|
|
7
13
|
}
|
|
8
14
|
/**
|
|
9
15
|
* Normalize the caller-facing `cache` option into a concrete decision.
|
|
10
|
-
* - `undefined` / `true` → enabled at
|
|
16
|
+
* - `undefined` / `true` → enabled at `defaultTtl`
|
|
11
17
|
* - `false` / `0` → disabled
|
|
12
18
|
* - `"5m"` / `"1h"` → enabled at that TTL
|
|
13
19
|
*/
|
|
14
|
-
export declare function resolveCache(cache: LlmCache | undefined
|
|
20
|
+
export declare function resolveCache(cache: LlmCache | undefined, { defaultTtl }?: {
|
|
21
|
+
defaultTtl?: CacheTtl;
|
|
22
|
+
}): ResolvedCache;
|
|
15
23
|
/**
|
|
16
24
|
* Deterministic short key for providers with automatic, prefix-based caching
|
|
17
25
|
* (e.g. OpenAI `prompt_cache_key`). Derived from the stable prefix so the same
|