llm-large-files 0.10.1 → 0.10.2
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/CHANGELOG.md +75 -0
- package/dist/ask.d.ts +16 -0
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +26 -2
- package/dist/ask.js.map +1 -1
- package/dist/cache.d.ts +27 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +96 -21
- package/dist/cache.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +12 -1
- package/dist/ingest.d.ts.map +1 -1
- package/dist/ingest.js +146 -11
- package/dist/ingest.js.map +1 -1
- package/dist/library.d.ts +55 -5
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +74 -4
- package/dist/library.js.map +1 -1
- package/dist/stores.d.ts +38 -1
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +184 -6
- package/dist/stores.js.map +1 -1
- package/dist/testing/store-checks.d.ts +8 -3
- package/dist/testing/store-checks.d.ts.map +1 -1
- package/dist/testing/store-checks.js +74 -1
- package/dist/testing/store-checks.js.map +1 -1
- package/dist/types.d.ts +56 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/guides/deployment.md +3 -3
- package/docs/guides/storage.md +62 -8
- package/docs/reference/ask.md +25 -3
- package/docs/reference/events.md +1 -1
- package/docs/reference/library.md +106 -11
- package/docs/reference/testing.md +10 -4
- package/docs/security.md +2 -1
- package/package.json +1 -1
- package/src/ask.ts +35 -2
- package/src/cache.ts +95 -19
- package/src/index.ts +2 -2
- package/src/ingest.ts +144 -12
- package/src/library.ts +122 -8
- package/src/stores.ts +174 -7
- package/src/testing/store-checks.ts +74 -3
- package/src/types.ts +55 -0
package/CHANGELOG.md
CHANGED
|
@@ -36,6 +36,81 @@ Grouped by area. One or two lines each, written for an app developer, with the n
|
|
|
36
36
|
matter.
|
|
37
37
|
-->
|
|
38
38
|
|
|
39
|
+
## 0.10.2 — 2026-11-25
|
|
40
|
+
|
|
41
|
+
Storage for a chatbot that keeps its files in the library: the files of a chat in one call, an
|
|
42
|
+
expiry counted from the last use, the application's own data on a document, and one document for a
|
|
43
|
+
file uploaded twice. Stored tool rounds can be kept small. A large document over a store without
|
|
44
|
+
`readTextRange` is no longer loaded again for every tool call. The text sent to the model is the
|
|
45
|
+
same as 0.10.1's.
|
|
46
|
+
|
|
47
|
+
### Upgrading: what you need to change
|
|
48
|
+
|
|
49
|
+
Nothing. Code written for 0.10.1 compiles as it is: the new store methods, library members and
|
|
50
|
+
options are optional, and the requests are byte for byte those of 0.10.1. (A store or a
|
|
51
|
+
`LargeFiles` of your own that already has a member named `list`, `patchMeta`, `touch` or `update`
|
|
52
|
+
with another signature no longer matches the interface: rename it.)
|
|
53
|
+
|
|
54
|
+
- A subclass of `MemoryDocumentStore` or `FileDocumentStore` with its own `put`, `get`, `getMeta` or
|
|
55
|
+
`delete` is used as if it had no `list` and no `patchMeta` until it has its own: the built-in ones
|
|
56
|
+
would go past its own reads and writes. Its conformance checks pass as before.
|
|
57
|
+
|
|
58
|
+
- A store of your own that keeps a fixed list of metadata fields drops `appData`, the new field of
|
|
59
|
+
`DocumentMeta`: keep `meta` whole, as the storage guide says
|
|
60
|
+
([The methods](docs/guides/storage.md#the-methods)).
|
|
61
|
+
- `documentStoreChecks` checks `list` and `patchMeta` only for a store that has them: your store's
|
|
62
|
+
tests pass as before.
|
|
63
|
+
|
|
64
|
+
### New: what you can add
|
|
65
|
+
|
|
66
|
+
- **`files.list(access)`**: the documents of exactly the caller's owner and scope, the oldest first,
|
|
67
|
+
for a chat's file panel without a second list in your database. A document without an owner is
|
|
68
|
+
listed only to a caller without one. It needs the store's new optional
|
|
69
|
+
`list(context)`, which `MemoryDocumentStore` and `FileDocumentStore` have
|
|
70
|
+
([`files.list`](docs/reference/library.md#fileslistaccess)).
|
|
71
|
+
- **`files.touch(id, access)`**: the document's expiry is counted again from now (H5), so `ttlMs`
|
|
72
|
+
becomes the time a file is kept after its last use. Only the expiry is changed, through the
|
|
73
|
+
store's new optional `patchMeta(id, { createdAt, owner?, scope?, expiresAt?, appData? }, context)`:
|
|
74
|
+
field by field, and only in the document of that `createdAt`, owner and scope, so a document
|
|
75
|
+
stored again under the same ID meanwhile is never changed, and a `touch` and an `update` at once
|
|
76
|
+
both stay. `FileDocumentStore` makes them take turns with its `put` and `delete` of the document;
|
|
77
|
+
across servers sharing a folder, see [Storage](docs/guides/storage.md#filedocumentstore)
|
|
78
|
+
([Expiry from the last use](docs/guides/storage.md#expiry-from-the-last-use)).
|
|
79
|
+
- **`appData`**: the application's own data about a document (`DocumentMeta.appData`, a JSON object
|
|
80
|
+
of at most 16 KB, `MAX_APP_DATA_BYTES`), set with `ingest({ appData })` and changed with
|
|
81
|
+
`files.update(id, { appData }, access)`. Never sent to the model, nor in a summary.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const meta = await files.ingest({ name, bytes, owner: userId, scope: [userId, chatId], appData: { rowId } });
|
|
85
|
+
await files.update!(meta.id, { appData: { rowId, label: "contract" } }, { owner: userId, scope: [userId, chatId] });
|
|
86
|
+
```
|
|
87
|
+
- **`ingest({ dedupe: true })`**: a file uploaded again gives back the document of the same owner
|
|
88
|
+
and scope with the same SHA-256, with its expiry counted again, instead of a second copy (H6). The
|
|
89
|
+
file is read once to hash it, not extracted. Never across owners or scopes; not with `id`. The
|
|
90
|
+
document keeps its `createdAt`, which tells it from a new one
|
|
91
|
+
([`IngestInput`](docs/reference/library.md#ingestinput)).
|
|
92
|
+
- **`storeRounds: "compact"`** and **`compactToolTurns(turns)`**: stored tool rounds with each large
|
|
93
|
+
result replaced by the stand-in the loop already sends when it drops a result (I2), a few hundred
|
|
94
|
+
bytes a call instead of up to 24,000 characters. A later question sends the stand-ins, and the
|
|
95
|
+
model reads again what it needs ([`compactToolTurns`](docs/reference/ask.md#compacttoolturnsturns)).
|
|
96
|
+
- `documentStoreChecks` checks `list` and `patchMeta`; `StoreCheckPart` has `"list"` and `"meta"`.
|
|
97
|
+
|
|
98
|
+
### Changed: what works differently
|
|
99
|
+
|
|
100
|
+
- **The last document larger than the whole cache is kept apart** for a minute after its last use
|
|
101
|
+
(P4): over a store without `readTextRange`, the tool calls of a question no longer each load and
|
|
102
|
+
index it again (250 ms a read, and about 2 GB of RSS at 100 MB in the 0.6 review). One at most, on
|
|
103
|
+
top of `cacheBytes`; `cacheBytes: 0` keeps none; `stats().cache.bytes` counts it,
|
|
104
|
+
`stats().cache.entries` does not.
|
|
105
|
+
- **`FileDocumentStore.sweep` removes metadata whose text is gone**, once it is older than
|
|
106
|
+
`orphanAgeMs`, as it removes files of no document: a document changed on one server while another
|
|
107
|
+
deleted it can be left so, and reads already took it as missing.
|
|
108
|
+
- **An ingest's own reads of a path upload count as stuck calls** (the `lstat`, the parts read for
|
|
109
|
+
the format, and, when `ingestTimeoutMs` is a time limit, the read of the file), as its store calls
|
|
110
|
+
do, once they have run the time the ingest gives them: a volume that does not answer now shows in `stats().stuckStoreCalls`, and past
|
|
111
|
+
`maxStuckStoreCalls` store calls fail at once with `"STORE_STUCK"`
|
|
112
|
+
([A store that stops answering](docs/guides/deployment.md#a-store-that-stops-answering)).
|
|
113
|
+
|
|
39
114
|
## 0.10.1 — 2026-11-25
|
|
40
115
|
|
|
41
116
|
A patch from the review of 0.10.0 against its code: a few pages said more, or less, than the code
|
package/dist/ask.d.ts
CHANGED
|
@@ -208,6 +208,14 @@ export type AskOptions = {
|
|
|
208
208
|
* documents, and events are often sent on to a browser.
|
|
209
209
|
*/
|
|
210
210
|
eventResults?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* How `AskResult.toolTurns` holds the results of the question's tool calls. "full" (the default):
|
|
213
|
+
* as the model had them. "compact": each large result replaced by the stand-in the loop sends
|
|
214
|
+
* when it drops a result to make room (`compactToolTurns`), so that a stored question takes a few
|
|
215
|
+
* hundred bytes a call. A later question then sends those stand-ins: the model reads again what it
|
|
216
|
+
* needs, at the price of a tool call. New in 0.10.2.
|
|
217
|
+
*/
|
|
218
|
+
storeRounds?: "full" | "compact";
|
|
211
219
|
signal?: AbortSignal;
|
|
212
220
|
};
|
|
213
221
|
export type AskResult = {
|
|
@@ -310,6 +318,14 @@ export type MissingDocumentsContext = {
|
|
|
310
318
|
scope?: DocumentScope;
|
|
311
319
|
signal?: AbortSignal;
|
|
312
320
|
};
|
|
321
|
+
/**
|
|
322
|
+
* Stored tool rounds (`AskResult.toolTurns`) made small: each result that is large is replaced by
|
|
323
|
+
* the stand-in the loop sends when it drops a result to make room (`stubResult`): the document, the
|
|
324
|
+
* lines or pages it showed, a search's query and total, the largest groups of a count, and a note
|
|
325
|
+
* that it was dropped. Errors and small results stay as they are. Copies: the turns given are not
|
|
326
|
+
* changed. For rounds stored by `storeRounds: "full"`, or by an earlier version. New in 0.10.2.
|
|
327
|
+
*/
|
|
328
|
+
export declare function compactToolTurns(turns: readonly ToolTurn[]): ToolTurn[];
|
|
313
329
|
/**
|
|
314
330
|
* Shares `room` among tool calls whose results may be up to `caps` characters. A character of the
|
|
315
331
|
* result of call i takes `rates[i]` of the room (1 when `rates` is left out: the room is in
|
package/dist/ask.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../src/ask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqD,KAAK,QAAQ,EAAsC,KAAK,WAAW,EAA4E,MAAM,aAAa,CAAC;AAC/N,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAKf,KAAK,QAAQ,EACb,KAAK,QAAQ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C;AAE5E;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAE9G,qIAAqI;AACrI,MAAM,MAAM,uBAAuB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AA+BtG;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAQvE;AAgVD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAoBnG;AAgCD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAErE;AA6FD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CA0B1E;AAsBD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAa/E"}
|
package/dist/ask.js
CHANGED
|
@@ -62,6 +62,28 @@ function checkFilteredAnswer(given) {
|
|
|
62
62
|
return;
|
|
63
63
|
throw new TypeError(`filteredAnswer must be "keep" or "drop", and is ${shownValue(given)}.`);
|
|
64
64
|
}
|
|
65
|
+
/** `storeRounds` checked: "full", "compact" or nothing (0.10.2). */
|
|
66
|
+
function checkStoreRounds(given) {
|
|
67
|
+
if (given === undefined || given === "full" || given === "compact")
|
|
68
|
+
return;
|
|
69
|
+
throw new TypeError(`storeRounds must be "full" or "compact", and is ${shownValue(given)}.`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Stored tool rounds (`AskResult.toolTurns`) made small: each result that is large is replaced by
|
|
73
|
+
* the stand-in the loop sends when it drops a result to make room (`stubResult`): the document, the
|
|
74
|
+
* lines or pages it showed, a search's query and total, the largest groups of a count, and a note
|
|
75
|
+
* that it was dropped. Errors and small results stay as they are. Copies: the turns given are not
|
|
76
|
+
* changed. For rounds stored by `storeRounds: "full"`, or by an earlier version. New in 0.10.2.
|
|
77
|
+
*/
|
|
78
|
+
export function compactToolTurns(turns) {
|
|
79
|
+
return turns.map((turn) => ({
|
|
80
|
+
...turn,
|
|
81
|
+
calls: turn.calls.map((call) => {
|
|
82
|
+
const { result, ...rest } = call;
|
|
83
|
+
return { ...rest, result: stubResult(rest, result) ?? result };
|
|
84
|
+
}),
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
65
87
|
/**
|
|
66
88
|
* `inlineTables` and `numberInline` checked: a value they cannot be ("Text", "false") is an error
|
|
67
89
|
* before anything is planned, as `prepare` would throw it, but in the words of the question.
|
|
@@ -621,6 +643,7 @@ async function ask(options, carried, state) {
|
|
|
621
643
|
const limits = checkedLimits(options.limits);
|
|
622
644
|
checkMissingPolicy(options.onMissingDocuments);
|
|
623
645
|
checkFilteredAnswer(options.filteredAnswer);
|
|
646
|
+
checkStoreRounds(options.storeRounds);
|
|
624
647
|
checkInlineOptions(options.inlineTables, options.numberInline);
|
|
625
648
|
// Since 0.10.0 by default: the tables sent whole get the tools, and the files sent whole have
|
|
626
649
|
// numbered lines. "text" and false send them as 0.9 did.
|
|
@@ -927,13 +950,14 @@ async function ask(options, carried, state) {
|
|
|
927
950
|
...(blockReason ? { blockReason } : {}),
|
|
928
951
|
steps,
|
|
929
952
|
evidence,
|
|
930
|
-
// The rounds as the model last had them
|
|
953
|
+
// The rounds as the model last had them, or their stand-ins (`storeRounds: "compact"`). A
|
|
954
|
+
// file cannot be kept as JSON: what is kept says that it was shown.
|
|
931
955
|
toolTurns: messages.slice(asked).filter(isRound).map((round) => ({
|
|
932
956
|
role: "tools",
|
|
933
957
|
version: TOOL_TURN_VERSION,
|
|
934
958
|
calls: round.answers.map(({ call: { problem: _problem, ...call }, result: returned, files: shownFiles }) => ({
|
|
935
959
|
...call,
|
|
936
|
-
result: shownFiles?.length ? stubResult(call, returned, true) ?? returned : returned,
|
|
960
|
+
result: shownFiles?.length ? stubResult(call, returned, true) ?? returned : options.storeRounds === "compact" ? stubResult(call, returned) ?? returned : returned,
|
|
937
961
|
})),
|
|
938
962
|
})),
|
|
939
963
|
plan: prepared.plan,
|