llm-large-files 0.8.2 → 0.10.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/CHANGELOG.md +981 -0
- package/README.md +22 -17
- package/dist/access.d.ts +128 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +234 -0
- package/dist/access.js.map +1 -0
- package/dist/aggregate.d.ts +6 -0
- package/dist/aggregate.d.ts.map +1 -1
- package/dist/aggregate.js +86 -13
- package/dist/aggregate.js.map +1 -1
- package/dist/analyze.d.ts +4 -0
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +2 -2
- package/dist/analyze.js.map +1 -1
- package/dist/answer-info.d.ts +26 -0
- package/dist/answer-info.d.ts.map +1 -0
- package/dist/answer-info.js +32 -0
- package/dist/answer-info.js.map +1 -0
- package/dist/anthropic/adapter.d.ts +5 -1
- package/dist/anthropic/adapter.d.ts.map +1 -1
- package/dist/anthropic/adapter.js +35 -10
- package/dist/anthropic/adapter.js.map +1 -1
- package/dist/ask.d.ts +159 -14
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +743 -113
- package/dist/ask.js.map +1 -1
- package/dist/cache.d.ts +12 -3
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +18 -5
- package/dist/cache.js.map +1 -1
- package/dist/citations.d.ts +36 -0
- package/dist/citations.d.ts.map +1 -0
- package/dist/citations.js +291 -0
- package/dist/citations.js.map +1 -0
- package/dist/encoding.js +5 -3
- package/dist/encoding.js.map +1 -1
- package/dist/error-info.d.ts +70 -0
- package/dist/error-info.d.ts.map +1 -0
- package/dist/error-info.js +253 -0
- package/dist/error-info.js.map +1 -0
- package/dist/errors.d.ts +74 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +104 -15
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +57 -13
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +42 -11
- package/dist/events.js.map +1 -1
- package/dist/evidence.d.ts +4 -2
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +35 -5
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts +32 -8
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +52 -36
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +54 -7
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +152 -41
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +38 -53
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +20 -25
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/endpoints.d.ts +59 -11
- package/dist/gemini/endpoints.d.ts.map +1 -1
- package/dist/gemini/endpoints.js +33 -7
- package/dist/gemini/endpoints.js.map +1 -1
- package/dist/gemini/errors.d.ts +39 -5
- package/dist/gemini/errors.d.ts.map +1 -1
- package/dist/gemini/errors.js +70 -9
- package/dist/gemini/errors.js.map +1 -1
- package/dist/gemini/generate.d.ts +53 -2
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +100 -50
- package/dist/gemini/generate.js.map +1 -1
- package/dist/gemini/index.d.ts +4 -4
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/http.d.ts +41 -3
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +40 -2
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +13 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +78 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +893 -0
- package/dist/ingest.js.map +1 -0
- package/dist/library.d.ts +295 -33
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +458 -650
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.d.ts +176 -10
- package/dist/map-reduce.d.ts.map +1 -1
- package/dist/map-reduce.js +807 -61
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +79 -6
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +80 -4
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +247 -14
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +491 -227
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/ingest-child.d.ts +7 -1
- package/dist/node/ingest-child.d.ts.map +1 -1
- package/dist/node/ingest-child.js +19 -4
- package/dist/node/ingest-child.js.map +1 -1
- package/dist/node/isolated.d.ts +3 -1
- package/dist/node/isolated.d.ts.map +1 -1
- package/dist/node/isolated.js +11 -4
- package/dist/node/isolated.js.map +1 -1
- package/dist/node/originals.d.ts +19 -0
- package/dist/node/originals.d.ts.map +1 -0
- package/dist/node/originals.js +82 -0
- package/dist/node/originals.js.map +1 -0
- package/dist/node/spool.d.ts +106 -0
- package/dist/node/spool.d.ts.map +1 -0
- package/dist/node/spool.js +378 -0
- package/dist/node/spool.js.map +1 -0
- package/dist/node/sse.d.ts +6 -4
- package/dist/node/sse.d.ts.map +1 -1
- package/dist/node/sse.js +9 -7
- package/dist/node/sse.js.map +1 -1
- package/dist/openai/adapter.d.ts +5 -1
- package/dist/openai/adapter.d.ts.map +1 -1
- package/dist/openai/adapter.js +53 -12
- package/dist/openai/adapter.js.map +1 -1
- package/dist/output-limit.d.ts +2 -1
- package/dist/output-limit.d.ts.map +1 -1
- package/dist/output-limit.js +5 -2
- package/dist/output-limit.js.map +1 -1
- package/dist/pdf-layout.d.ts.map +1 -1
- package/dist/pdf-layout.js +71 -12
- package/dist/pdf-layout.js.map +1 -1
- package/dist/pdf-outline.d.ts +71 -0
- package/dist/pdf-outline.d.ts.map +1 -0
- package/dist/pdf-outline.js +414 -0
- package/dist/pdf-outline.js.map +1 -0
- package/dist/plan.d.ts +137 -7
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +248 -26
- package/dist/plan.js.map +1 -1
- package/dist/prepare.d.ts +50 -0
- package/dist/prepare.d.ts.map +1 -0
- package/dist/prepare.js +207 -0
- package/dist/prepare.js.map +1 -0
- package/dist/ranged.d.ts +16 -11
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +56 -12
- package/dist/ranged.js.map +1 -1
- package/dist/retry.d.ts +3 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +6 -2
- package/dist/retry.js.map +1 -1
- package/dist/scope.d.ts +25 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +60 -0
- package/dist/scope.js.map +1 -0
- package/dist/search.d.ts +7 -0
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +72 -10
- package/dist/search.js.map +1 -1
- package/dist/source.d.ts +60 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +170 -0
- package/dist/source.js.map +1 -0
- package/dist/stores.d.ts +126 -31
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +655 -141
- package/dist/stores.js.map +1 -1
- package/dist/testing/fake-fetch.d.ts +31 -0
- package/dist/testing/fake-fetch.d.ts.map +1 -0
- package/dist/testing/fake-fetch.js +66 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-model.d.ts +38 -0
- package/dist/testing/fake-model.d.ts.map +1 -0
- package/dist/testing/fake-model.js +62 -0
- package/dist/testing/fake-model.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/store-checks.d.ts +72 -0
- package/dist/testing/store-checks.d.ts.map +1 -0
- package/dist/testing/store-checks.js +619 -0
- package/dist/testing/store-checks.js.map +1 -0
- package/dist/tools.d.ts +47 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +440 -71
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +165 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/whole-cost.d.ts +37 -0
- package/dist/whole-cost.d.ts.map +1 -0
- package/dist/whole-cost.js +46 -0
- package/dist/whole-cost.js.map +1 -0
- package/docs/README.md +21 -8
- package/docs/getting-started.md +18 -13
- package/docs/guides/anthropic.md +17 -10
- package/docs/guides/conversations.md +112 -47
- package/docs/guides/costs-and-limits.md +147 -42
- package/docs/guides/deployment.md +380 -86
- package/docs/guides/errors-and-reliability.md +317 -67
- package/docs/guides/explorer-model.md +4 -1
- package/docs/guides/openai-compatible.md +47 -7
- package/docs/guides/own-adapter-and-loop.md +60 -16
- package/docs/guides/pdfs.md +219 -36
- package/docs/guides/storage.md +676 -145
- package/docs/guides/testing.md +149 -129
- package/docs/guides/vertex-and-gemini.md +169 -57
- package/docs/guides/web-app.md +318 -80
- package/docs/how-it-works.md +155 -30
- package/docs/measurements.md +215 -13
- package/docs/publishing.md +185 -37
- package/docs/reference/anthropic.md +12 -7
- package/docs/reference/ask.md +415 -47
- package/docs/reference/errors-and-retries.md +194 -14
- package/docs/reference/events.md +77 -27
- package/docs/reference/gemini.md +252 -87
- package/docs/reference/library.md +886 -178
- package/docs/reference/node.md +659 -111
- package/docs/reference/openai.md +21 -10
- package/docs/reference/testing.md +311 -0
- package/docs/reference/tools.md +285 -30
- package/docs/security.md +404 -78
- package/docs/troubleshooting.md +151 -70
- package/docs/upgrading-0.10.md +472 -0
- package/docs/upgrading-0.9.md +890 -0
- package/package.json +16 -3
- package/src/access.ts +267 -0
- package/src/aggregate.ts +92 -14
- package/src/analyze.ts +2 -2
- package/src/answer-info.ts +45 -0
- package/src/anthropic/adapter.ts +40 -11
- package/src/ask.ts +866 -115
- package/src/cache.ts +20 -5
- package/src/citations.ts +294 -0
- package/src/encoding.ts +6 -4
- package/src/error-info.ts +290 -0
- package/src/errors.ts +131 -15
- package/src/events.ts +112 -24
- package/src/evidence.ts +35 -5
- package/src/extract.ts +56 -34
- package/src/gemini/adapter.ts +196 -43
- package/src/gemini/chat.ts +63 -78
- package/src/gemini/endpoints.ts +89 -16
- package/src/gemini/errors.ts +74 -11
- package/src/gemini/generate.ts +147 -57
- package/src/gemini/index.ts +4 -4
- package/src/http.ts +65 -4
- package/src/index.ts +13 -8
- package/src/ingest.ts +958 -0
- package/src/library.ts +711 -651
- package/src/map-reduce.ts +858 -70
- package/src/model.ts +113 -9
- package/src/node/handlers.ts +709 -221
- package/src/node/index.ts +14 -2
- package/src/node/ingest-child.ts +24 -6
- package/src/node/isolated.ts +11 -4
- package/src/node/originals.ts +78 -0
- package/src/node/spool.ts +379 -0
- package/src/node/sse.ts +9 -7
- package/src/openai/adapter.ts +56 -13
- package/src/output-limit.ts +5 -2
- package/src/pdf-layout.ts +69 -11
- package/src/pdf-outline.ts +400 -0
- package/src/plan.ts +287 -36
- package/src/prepare.ts +253 -0
- package/src/ranged.ts +48 -14
- package/src/retry.ts +6 -2
- package/src/scope.ts +63 -0
- package/src/search.ts +69 -13
- package/src/source.ts +178 -0
- package/src/stores.ts +702 -142
- package/src/testing/fake-fetch.ts +80 -0
- package/src/testing/fake-model.ts +78 -0
- package/src/testing/index.ts +11 -0
- package/src/testing/store-checks.ts +660 -0
- package/src/tools.ts +461 -73
- package/src/types.ts +151 -14
- package/src/whole-cost.ts +64 -0
package/CHANGELOG.md
CHANGED
|
@@ -36,6 +36,987 @@ 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.0 — 2026-11-25
|
|
40
|
+
|
|
41
|
+
Counts that are right and a cost that is bounded, for a chatbot on Gemini. Tables sent whole get
|
|
42
|
+
exact counts, files sent whole get line numbers, and every question has a ceiling on input tokens
|
|
43
|
+
by default. Answers say how they ended, a store that stops answering no longer holds a question or
|
|
44
|
+
a server, Gemini requests take fields of your own, and a PDF whose headings are set in larger type,
|
|
45
|
+
Hebrew included, gets an outline. The text sent to the model changes on purpose, all at once: each
|
|
46
|
+
chat with files misses the provider's prompt cache once at the upgrade.
|
|
47
|
+
[Upgrading to 0.10](docs/upgrading-0.10.md) takes an application from 0.9.0 step by step, with the
|
|
48
|
+
Hebrew chatbot of the 0.9 guide carried over.
|
|
49
|
+
|
|
50
|
+
### Upgrading: what you need to change
|
|
51
|
+
|
|
52
|
+
Code written for 0.9.0 compiles with 0.10.0, except in these cases
|
|
53
|
+
([Does my code compile?](docs/upgrading-0.10.md#does-my-code-compile)):
|
|
54
|
+
|
|
55
|
+
- `NoticeCode` has two new members, `"answer_filtered"` and `"answer_cut"`; `ToolOutcome` one,
|
|
56
|
+
`"redacted"`; and `ModelReply.finish` one, `"other"`, which the `finish` of a `request.end` event
|
|
57
|
+
has too. An exhaustive `switch` over any of them, or a `Record` keyed by it, needs them. The new
|
|
58
|
+
`AskResult.finish` has the same members.
|
|
59
|
+
- The plan of `run.finish` and `run.error` (`EventResult.plan`) holds
|
|
60
|
+
`Omit<DocumentMeta, "owner" | "scope" | "sha256" | "original" | "metaVersion">`, and the result
|
|
61
|
+
of `eventResults: true` leaves those fields out at run time too. Code that reads them there fails
|
|
62
|
+
with TS2339. Read them from `AskResult.plan`.
|
|
63
|
+
- `createLargeFiles` returns `CreatedLargeFiles`, a `LargeFiles` whose `stats()` and `toolsFor()`
|
|
64
|
+
are required. A value typed `ReturnType<typeof createLargeFiles>` and made by hand (a mock), or a
|
|
65
|
+
variable whose type was inferred from it and that you later give a `LargeFiles` of your own,
|
|
66
|
+
fails with TS2322. Type it `LargeFiles`.
|
|
67
|
+
- `DocumentHandlers` has a required `stats()`. A `DocumentHandlers` made by hand (a mock) fails
|
|
68
|
+
with TS2741.
|
|
69
|
+
- `LargeFiles` has two new optional methods, `stats` and `toolsFor`. A `LargeFiles` of your own
|
|
70
|
+
with a member of either name and another type fails with TS2322 or TS2416. Rename it.
|
|
71
|
+
- `vertexAi` takes `VertexAiOptions`, a union of the token form and express mode (`apiKey`), and
|
|
72
|
+
its token function is typed with its `{ refresh }` argument. A value typed
|
|
73
|
+
`Parameters<typeof vertexAi>[0]` whose `project` you read as a string, or whose `accessToken`
|
|
74
|
+
you call with no argument, fails with TS2322 or TS2554. Type it
|
|
75
|
+
`Extract<VertexAiOptions, { project: string }>`, and call `accessToken({ refresh: false })`.
|
|
76
|
+
- A subclass of `UsageMeter` whose `add` takes a parameter of its own after `usage` fails with
|
|
77
|
+
TS2416: `add(model, usage, estimatedInputTokens?)` takes that place. Put yours after it.
|
|
78
|
+
|
|
79
|
+
The other changes to the public types add exports, options, fields and optional members.
|
|
80
|
+
`ModelReply.responseId` and `responseModel`, `ExtractedText.headings`, `ToolSet.wholeReadsLeft` and
|
|
81
|
+
`PreparedContext.toolable` are optional, so an adapter, an extractor, a tool set or a `LargeFiles`
|
|
82
|
+
of your own still compiles, unless it already has a field of the same name and another type. The
|
|
83
|
+
type of `askGemini`'s options is now `Omit<AskOptions, "model" | "explorer" | "messages"> &
|
|
84
|
+
GeminiOwnOptions`: no field was removed, and every option of `askWithFiles` reaches the loop. No
|
|
85
|
+
export was removed or renamed. The new exports are under **New**.
|
|
86
|
+
|
|
87
|
+
Some behavior is different. Check each point against your app:
|
|
88
|
+
|
|
89
|
+
- **One prompt-cache miss for each chat with files at the upgrade.** The text sent changes once:
|
|
90
|
+
files sent whole are numbered (`12| `), and when no file is searched the system text gets the
|
|
91
|
+
line `Cite line numbers like (report.docx L12).`; a table sent whole gets three tool
|
|
92
|
+
declarations, its `document_id` in its frame line, and a line of the system text that says to
|
|
93
|
+
count with them; `analyze_whole_document` is declared with two more arguments, `output` and
|
|
94
|
+
`labels`; the closing request after files shown in full asks for an answer from those files and
|
|
95
|
+
what the tools returned, with line citations, where 0.9's named only what the tools returned; and
|
|
96
|
+
on a card, a size between 999,500 and 999,999 tokens reads "1.0M", and one between 1,048,064 and
|
|
97
|
+
1,048,575 bytes "1 MB", on a card and in `get_document_overview`'s `size` (LLF-059); error
|
|
98
|
+
messages that print a size in that range (upload and text limits, `view_pages`) read "1 MB" too.
|
|
99
|
+
After that one miss, the cache works across questions as in 0.9: a follow-up still differs from
|
|
100
|
+
its first stored round, which goes back as its calls.
|
|
101
|
+
**What to do:** nothing; the first question of each chat after the deploy costs its full input
|
|
102
|
+
([Prompt caching](docs/guides/costs-and-limits.md#prompt-caching)).
|
|
103
|
+
- **A ceiling on input tokens by default.** A question that sets no `limits.inputTokens` stops
|
|
104
|
+
calling tools once what it spent, its next tool request and the answer would pass the larger of
|
|
105
|
+
`DEFAULT_INPUT_TOKENS` (1,000,000) and `toolTurns` times the estimate of its first request, plus
|
|
106
|
+
room for the whole-file reads it may make. It looks ahead before each tool request, and a request
|
|
107
|
+
that reports no input counts by its estimate. A question of four tool turns over a 3 MB log uses
|
|
108
|
+
less than half of it.
|
|
109
|
+
**What to do:** nothing, or set your own ceiling. `limits: { inputTokens: Infinity }` gives 0.9's
|
|
110
|
+
behavior ([The default ceiling](docs/guides/costs-and-limits.md#the-default-ceiling)).
|
|
111
|
+
- **At most 2 whole-file reads per question**, over all its documents. A third is refused with its
|
|
112
|
+
reason. **What to do:** `limits: { wholeReadsPerQuestion: Infinity }` gives 0.9's rule.
|
|
113
|
+
- **Tables sent whole get tools** (`inlineTables: "tools"`, the default of `askWithFiles` and
|
|
114
|
+
`askGemini`). A CSV, an XLSX workbook, or a DOCX, PPTX, PDF, HTML or Markdown file with a table of
|
|
115
|
+
at least 3 `| cell |` rows that is sent whole gets `search_document`, `read_document` and
|
|
116
|
+
`aggregate_table`, and the question runs the tool loop. A question with no count stays at one
|
|
117
|
+
request when the model answers at once; a count takes 2 or 3 (live, a median of 2 on both
|
|
118
|
+
models), each sending the table again; at most, about `toolTurns` times the first request (about
|
|
119
|
+
1.5M input tokens for a CSV of 3,000 invoices), bounded by the ceiling. Live, input tokens on the
|
|
120
|
+
eval's cases shared with 0.9.0 were about 2.3 to 2.4 times 0.9.0's, and counts were right in 24
|
|
121
|
+
of 24 on both models
|
|
122
|
+
([Measurements](docs/measurements.md#tables-sent-whole-p1s-live-gate)). Gemini 3.5 Flash-Lite
|
|
123
|
+
looks a row up with a tool even when the table is shown in full: 21 of 39 questions with no count
|
|
124
|
+
took one request (Gemini 3.8 Flash: 38 of 39), so a lookup takes 2, each sending the table. This
|
|
125
|
+
is recorded, not tuned. Limits sized for 0.9's one request (`toolTurns: 1`, `requests: 1`, an
|
|
126
|
+
`inputTokens` between one and two requests with the table) leave no tool turn: such a question
|
|
127
|
+
makes 0.9's one request, without tools.
|
|
128
|
+
**What to do:** nothing, or `inlineTables: "text"` for 0.9's cost and counts by eye
|
|
129
|
+
([Tables sent whole](docs/guides/costs-and-limits.md#tables-sent-whole)).
|
|
130
|
+
- **Files sent whole are numbered** (`numberInline: true`, the default of `askWithFiles` and
|
|
131
|
+
`askGemini`), so that answers cite their lines: about 8% to 16% more tokens for each file, and a
|
|
132
|
+
file at the edge of `inlineTokens` may become a card. When no file is searched, the system text
|
|
133
|
+
gets the line `Cite line numbers like (report.docx L12).`.
|
|
134
|
+
**What to do:** nothing, or `numberInline: false` to send them as 0.9 did.
|
|
135
|
+
- **`AskResult.evidence` lists each file sent whole first**, as
|
|
136
|
+
`{ tool: "inline", documentId, document, lines: [[1, n]], whole: true }`, with no `callId`.
|
|
137
|
+
**What to do:** code that counts tool calls from evidence, or maps it to `tool.end`, skips the
|
|
138
|
+
entries without a `callId`.
|
|
139
|
+
- **What the opt-outs do not give back.** `inlineTables: "text"` and `numberInline: false` each
|
|
140
|
+
give 0.9's bytes for what they cover. With both, these stay: the `whole_file` hint of a
|
|
141
|
+
`read_document` result cut short, and the `filter_note` of `aggregate_table`; the declaration of
|
|
142
|
+
`analyze_whole_document` and the prompts of its part reads (M8); and the card sizes of LLF-059
|
|
143
|
+
([What has a way back](docs/upgrading-0.10.md#going-back-to-09s-text)).
|
|
144
|
+
- **Rolling deploys.** What 0.10.0 stores is what 0.9 stores, so servers of both versions share a
|
|
145
|
+
store and nothing fails. But they send different text, so a chat answered by 0.9 and 0.10 servers
|
|
146
|
+
in turn misses the prompt cache on every switch.
|
|
147
|
+
**What to do:** deploy every server at once, or route each chat to one version until the rollout
|
|
148
|
+
ends. Run the sweep from a server of 0.10.0
|
|
149
|
+
([Rolling deploys](docs/upgrading-0.10.md#rolling-deploys)).
|
|
150
|
+
- **Store calls have a time limit.** A `getMeta`, a read of a text, its index or its original, or a
|
|
151
|
+
`delete` that does not end within `storeTimeoutMs` (30 s) fails with a `DocumentStoreError` of
|
|
152
|
+
code `"ETIMEDOUT"` (503, to retry), where it hung. In a question, a store call that times out,
|
|
153
|
+
in a tool call or in a part of a whole-file read too, ends it with `run.error`: `execute` and
|
|
154
|
+
`executeWithFiles` throw it, where they returned an error result, and a page look at a hung
|
|
155
|
+
original is that error, where the model was told the file could not be read in time. While
|
|
156
|
+
`maxStuckStoreCalls` calls of the process are stuck past their limit (half of
|
|
157
|
+
`UV_THREADPOOL_SIZE`: 2 by default), store calls fail at once with code `"STORE_STUCK"` (503).
|
|
158
|
+
**What to do:** on servers that use a network volume, set `UV_THREADPOOL_SIZE=32`. Raise
|
|
159
|
+
`storeTimeoutMs` for a slow store, or set 0 for none
|
|
160
|
+
([A store that stops answering](docs/guides/deployment.md#a-store-that-stops-answering)).
|
|
161
|
+
- **Transient system errors are 503 and retryable.** `ETIMEDOUT`, `ECONNRESET`, `ECONNREFUSED`,
|
|
162
|
+
`EPIPE`, `EAI_AGAIN`, `EAGAIN`, `EBUSY`, `EMFILE`, `ENFILE`, `ESTALE`, `EHOSTUNREACH` and
|
|
163
|
+
`ENETUNREACH` are 503 with `Retry-After: 5` in `errorInfoOf` and the upload handlers, and
|
|
164
|
+
`ENOSPC` and `EDQUOT` 503 with 30 s. They were 500, not to retry: "Upload failed (ETIMEDOUT)." is
|
|
165
|
+
now a 503. A path upload whose read does not answer within `ingestTimeoutMs` is such an
|
|
166
|
+
`ETIMEDOUT`, not the `IngestError` `"timeout"` (422) it was.
|
|
167
|
+
**What to do:** tell users to try again when `errorInfoOf(error).retryable` is true
|
|
168
|
+
([Transient errors](docs/guides/errors-and-reliability.md#transient-errors-a-store-or-a-disk-that-does-not-answer)).
|
|
169
|
+
- **Gemini errors inside a stream, or in a reply of HTTP 200, are retried.** One with no numeric
|
|
170
|
+
code gets the status of its `google.rpc` name (`UNAVAILABLE` 503, `RESOURCE_EXHAUSTED` 429,
|
|
171
|
+
`DEADLINE_EXCEEDED` 504, 500 for a name it does not know), and a transient one is sent again up to
|
|
172
|
+
`retry.retries` times (3), unless text was already shown. It had status 200 and was not sent
|
|
173
|
+
again. A daily quota is still `"quota"`, and not sent again.
|
|
174
|
+
**What to do:** nothing.
|
|
175
|
+
- **Part reads that run out of time** are a `ModelRequestError` of kind `"timeout"` and status 0
|
|
176
|
+
in every adapter, sent again once after the first wait of `retry`. Before, it was the timer's
|
|
177
|
+
abort error, with no status. `timeoutMs: 0` now sets no limit; it aborted every part read at once.
|
|
178
|
+
**What to do:** nothing; `gemini({ timeoutMs })` and `askGemini`'s `timeoutMs` set the limit
|
|
179
|
+
([Part reads](docs/guides/errors-and-reliability.md#part-reads-have-a-time-limit-of-their-own)).
|
|
180
|
+
- **Filtered and cut answers say so.** `result.finish` tells how the answer ended, an
|
|
181
|
+
`answer_filtered` or `answer_cut` notice comes before `run.finish`, and a reply that a filter or
|
|
182
|
+
another reason that asking again cannot mend ended (`finish` `"filtered"` or `"other"`) is not
|
|
183
|
+
asked for again: 2 requests over a searched file, where 0.9 made 4. Gemini's `MODEL_ARMOR`,
|
|
184
|
+
`IMAGE_PROHIBITED_CONTENT`, `IMAGE_RECITATION` and `IMAGE_OTHER` are now `"filtered"` (as
|
|
185
|
+
`IMAGE_SAFETY` was), and `OTHER`, `LANGUAGE` and four more `"other"`; they gave no finish.
|
|
186
|
+
`MALFORMED_RESPONSE` is now `"malformed_call"`: the turn is asked for once more.
|
|
187
|
+
**What to do:** switch on `answerInfoOf(result)` for the message to show. With
|
|
188
|
+
`filteredAnswer: "drop"`, take back streamed text when the notice has `discardText`
|
|
189
|
+
([Filtered and cut answers](docs/guides/errors-and-reliability.md#filtered-and-cut-answers)).
|
|
190
|
+
- **A PDF ingested from 0.10.0 on** whose text gives fewer than 3 headings gets an outline from its
|
|
191
|
+
lines set at least 15% larger than its body, when 3 or more of them are found in its text. Its
|
|
192
|
+
card gains an "Outline" block, `get_document_overview` lists it, and search hits gain `section`.
|
|
193
|
+
A PDF with a title alone keeps the card and hits of 0.9. Documents already stored keep their
|
|
194
|
+
metadata until they are ingested again; `metaVersion` stays 1. A wrapper around the built-in PDF
|
|
195
|
+
extractor that returns only `text` and `pages` keeps the 0.9 outline.
|
|
196
|
+
**What to do:** pass `headings` on in such a wrapper (`{ ...extracted, text }`)
|
|
197
|
+
([PDF outline](docs/guides/pdfs.md#pdf-outline)).
|
|
198
|
+
- **Tests that compare results, events or requests whole.** Requests change as the first point
|
|
199
|
+
says. `usage` gains `estimatedInputTokens` and `unmeasuredRequests` when a request reports no
|
|
200
|
+
input. Replies gain `responseId` and `responseModel` where the provider gives them. A malformed
|
|
201
|
+
call on the last tool turn now gets a closing request: one request more (LLF-048). The loop
|
|
202
|
+
answers a call of an unknown tool itself ("Unknown tool “x”. The tools are: …"), with outcome
|
|
203
|
+
`"refused"` and no `onActivity` line, where the tool set returned an `"error"`. A size between
|
|
204
|
+
1,048,064 and 1,048,575 bytes reads "1 MB" on a card, in `get_document_overview` and in error
|
|
205
|
+
messages (LLF-059).
|
|
206
|
+
**What to do:** update the tests that compare these whole.
|
|
207
|
+
|
|
208
|
+
### New: what you can add
|
|
209
|
+
|
|
210
|
+
**Answers and costs**
|
|
211
|
+
|
|
212
|
+
- **How an answer ended:** `AskResult.finish`, the notices `"answer_filtered"` and `"answer_cut"`,
|
|
213
|
+
`AskOptions.filteredAnswer` (`"keep"` or `"drop"`, with `discardText` on the notice), and
|
|
214
|
+
`answerInfoOf(result)` with `AnswerInfo`: one value to switch on, `"filtered"`, `"cut"`,
|
|
215
|
+
`"blocked"`, `"language"` (Gemini's `LANGUAGE`, not a filter), `"no_answer"` or `"other"`
|
|
216
|
+
([Filtered and cut answers](docs/guides/errors-and-reliability.md#filtered-and-cut-answers)).
|
|
217
|
+
- **Citations checked:** `AskResult.citations` and `checkCitations` (`CitationCheck`). They read
|
|
218
|
+
"(name L12)", ranges, "line N", "Row N", and the Hebrew "שורה N" and "שורות N-M", and check each
|
|
219
|
+
against what the tools showed; a workbook's rows are unchecked (S3,
|
|
220
|
+
[CitationCheck](docs/reference/ask.md#citationcheck)).
|
|
221
|
+
- **`onToolResult`** (`ToolResultContext`, `ToolResultVerdict`): see each tool result before the
|
|
222
|
+
model does, and keep it, replace it (outcome `"redacted"`) or refuse it
|
|
223
|
+
([Security](docs/security.md#tool-results-ontoolresult)).
|
|
224
|
+
- **Limits:** `limits.wholeReadsPerQuestion` and `DEFAULT_INPUT_TOKENS`; `UsageTotals`
|
|
225
|
+
`estimatedInputTokens` and `unmeasuredRequests`, and `UsageMeter.add(model, usage,
|
|
226
|
+
estimatedInputTokens?)` ([Costs and limits](docs/guides/costs-and-limits.md#the-limits-of-a-question)).
|
|
227
|
+
- **Response IDs:** `ModelReply.responseId` and `responseModel` from Gemini, OpenAI-compatible
|
|
228
|
+
servers and Claude, on `request.end` too.
|
|
229
|
+
|
|
230
|
+
**Tables and line numbers**
|
|
231
|
+
|
|
232
|
+
- `AskOptions.inlineTables` (`"tools"` by default) and `AskOptions.numberInline` (`true` by
|
|
233
|
+
default), also in `askGemini`. For loops of your own, `PrepareOptions.inlineTables` and
|
|
234
|
+
`numberInline` (off by default) and `PreparedContext.toolable`; and for the tool set,
|
|
235
|
+
`ToolOptions.inline` (the files sent whole) and `ToolOptions.declare` (exactly these tools), with
|
|
236
|
+
`declarationsFor(names)` and `ToolName`
|
|
237
|
+
([Numbered lines and tables sent whole](docs/how-it-works.md#numbered-lines-and-tables-sent-whole)).
|
|
238
|
+
|
|
239
|
+
The chat of a Hebrew chatbot on Vertex AI and MongoDB:
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
import { answerInfoOf, hashedScopeSegment } from "llm-large-files";
|
|
243
|
+
import { askGemini, vertexAi } from "llm-large-files/gemini";
|
|
244
|
+
|
|
245
|
+
const turn = { role: "user" as const, text: question };
|
|
246
|
+
const result = await askGemini({
|
|
247
|
+
files,
|
|
248
|
+
endpoint: vertexAi({ project, location: "global", model, accessToken }), // accessToken({ refresh })
|
|
249
|
+
body: { labels: { app: "chatbot", team: "hr" } }, // billing labels: no user IDs
|
|
250
|
+
documentIds: chat.documentIds,
|
|
251
|
+
messages: [...chat.messages, turn], // the stored turns and tool rounds, as in 0.9
|
|
252
|
+
owner: userId,
|
|
253
|
+
scope: [hashedScopeSegment(userId), chatId],
|
|
254
|
+
onMissingDocuments: "drop",
|
|
255
|
+
filteredAnswer: "drop",
|
|
256
|
+
});
|
|
257
|
+
const info = answerInfoOf(result); // complete, or why not: one switch for the Hebrew message
|
|
258
|
+
const answer = result.answered ? [{ role: "assistant" as const, text: result.text }] : [];
|
|
259
|
+
await chats.updateOne({ _id: chatId }, {
|
|
260
|
+
$push: { messages: { $each: [turn, ...result.toolTurns, ...answer] } }, // as in 0.9
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Whole-file reads and tools**
|
|
265
|
+
|
|
266
|
+
- `analyze_whole_document` with `output: "items"` and `labels`: items judged by meaning, each
|
|
267
|
+
checked against its line, and counted by code (`total_items`, `counts_by_label`, `items`,
|
|
268
|
+
`unverified_items`, `parts_failed`, `parts_cut_short`; M9,
|
|
269
|
+
[Items](docs/reference/tools.md#items-output-items)).
|
|
270
|
+
- `notes_left_out` on a whole-read result, and `whole_file` on a `read_document` result cut short
|
|
271
|
+
of its range when a whole read would run.
|
|
272
|
+
- `ToolCallHooks.signal` (I9) and `ToolSet.wholeReadsLeft(documentId)`.
|
|
273
|
+
|
|
274
|
+
**Gemini and Vertex AI**
|
|
275
|
+
|
|
276
|
+
- `gemini()` and `askGemini` take `body`, `analysisBody` and `functionCallingMode` (`"AUTO"` or
|
|
277
|
+
`"VALIDATED"`), and `timeoutMs` for part reads; `askGemini` also `explorerBody`. Types
|
|
278
|
+
`GeminiRequestFields` and `GeminiOwnOptions` (A5,
|
|
279
|
+
[Fields of your own](docs/guides/vertex-and-gemini.md#fields-of-your-own-safety-settings-labels-and-more)).
|
|
280
|
+
- `answerWithoutTools` in `gemini()` and `askGemini`: `"omit"` (the default) or `"mode_none"` for
|
|
281
|
+
the request of the answer (NEW-answer-request-tools).
|
|
282
|
+
- `vertexAi({ headers, host, apiKey })` (`VertexAiOptions`); `apiKey` is Vertex AI express mode
|
|
283
|
+
(NEW-vertex-endpoint-options).
|
|
284
|
+
- `accessToken({ refresh })` and a `HeaderSource` that takes a context: after a 401, the request is
|
|
285
|
+
sent once more with a fresh token. `GeminiEndpoint.refreshable`
|
|
286
|
+
([Access tokens](docs/guides/vertex-and-gemini.md#access-tokens-for-vertex-ai)).
|
|
287
|
+
|
|
288
|
+
**Operations**
|
|
289
|
+
|
|
290
|
+
- `storeTimeoutMs` (30,000), `sweepTimeoutMs` and `maxStuckStoreCalls` in `createLargeFiles`, and
|
|
291
|
+
the `DocumentStoreError` codes `"ETIMEDOUT"` and `"STORE_STUCK"`
|
|
292
|
+
([Deployment](docs/guides/deployment.md#a-store-that-stops-answering)).
|
|
293
|
+
- `AccessOptions.signal`: ends the caller's own wait for the store.
|
|
294
|
+
- `files.stats()` (`LargeFilesStats`) and `handlers.stats()` (`DocumentHandlerStats`): counters for
|
|
295
|
+
metrics, alerts and readiness, read without a store call
|
|
296
|
+
([files.stats()](docs/reference/library.md#filesstats)).
|
|
297
|
+
- `files.toolsFor(ids, options)` (I6), and the type `CreatedLargeFiles`.
|
|
298
|
+
- `sseMessageOf` sends `finish` and `citations` in `run.finish`.
|
|
299
|
+
|
|
300
|
+
**PDFs**
|
|
301
|
+
|
|
302
|
+
- `ExtractedText.headings`: a PDF's lines set larger than its body, with page, level and title,
|
|
303
|
+
and `skip`, how many lines above it on its page read the same (a contents list). The built-in
|
|
304
|
+
extractor returns them; an extractor of your own may too
|
|
305
|
+
([PDF outline](docs/guides/pdfs.md#pdf-outline)).
|
|
306
|
+
|
|
307
|
+
### Changed: what works differently
|
|
308
|
+
|
|
309
|
+
**Costs and limits**
|
|
310
|
+
|
|
311
|
+
- The ceiling on input tokens looks ahead before each tool request. A whole-file read is priced
|
|
312
|
+
before it starts by what its requests send: its numbered lines, its prompts, its merges, and the
|
|
313
|
+
heading line a part starts under. An items read is priced at its parts, with a frame of 650
|
|
314
|
+
tokens.
|
|
315
|
+
- A reply ended by a reason that asking again cannot mend (`"filtered"`, `"other"`) is neither
|
|
316
|
+
nudged nor asked for again. Over files sent whole alone (nothing searched or viewed), one with no
|
|
317
|
+
text ends the question without a closing request. Otherwise the closing request is made once, and
|
|
318
|
+
a filtered closing is not asked for again.
|
|
319
|
+
- The room for tool results is shared in tokens, at each document's own characters per token. A
|
|
320
|
+
result that would still pass the room is cut before the model gets it, in call order.
|
|
321
|
+
- A question that is stopped ends at once, even while `files.prepare`, a tool call or
|
|
322
|
+
`onToolResult` waits on a store that hangs.
|
|
323
|
+
|
|
324
|
+
**Tables, numbers and citations**
|
|
325
|
+
|
|
326
|
+
- A file counts as having a table when it has 3 rows of one table.
|
|
327
|
+
- `aggregate_table`: a filter that orders a column (`>`, `>=`, `<`, `<=`) against a value that
|
|
328
|
+
names another column compares the two cells of each row, and says so in `filter_note`. A column
|
|
329
|
+
letter works in every table. Over a table sent whole, a grouped result ends with a `cite` line.
|
|
330
|
+
- With an explorer, a question in which no file is searched, and a table sent whole gets the tools,
|
|
331
|
+
is run by the answering model alone: the files sent whole are not sent to two models.
|
|
332
|
+
|
|
333
|
+
**Whole-file reads, search and tools**
|
|
334
|
+
|
|
335
|
+
- Part reads send the part first and the task last, with the heading line the part starts under
|
|
336
|
+
first, and their system text marks the part as file content. Merges and the read's answer send
|
|
337
|
+
their notes first and the task last (M8).
|
|
338
|
+
- `analyze_whole_document` keeps 0.9.0's description word for word: items are told in `output`
|
|
339
|
+
only. A new description made Gemini 3.5 Flash-Lite skip whole reads.
|
|
340
|
+
- The item check counts a quote near its named line as verified (up to one letter in five
|
|
341
|
+
differs), finds a clause's line by the number it starts with, and repairs short `\u` escapes. The
|
|
342
|
+
rule asks for five to twelve words of the line, copied exactly.
|
|
343
|
+
- A whole read with more parts than `ToolCallLimits.maxRequests` is refused before any request; one
|
|
344
|
+
given `maxRequests` stops merging at it (`notes_left_out`, or `notes_only` when no request is left
|
|
345
|
+
for the answer). A whole read that could read no part is not tried again, even when
|
|
346
|
+
`maxWholeDocumentReads` is above 1.
|
|
347
|
+
- With `declare`, a tool set answers only the declared tools. `ToolSet.resultCharacters` is 600 for
|
|
348
|
+
a name the tool set does not answer.
|
|
349
|
+
- Exact search counts past 1,000,000 matching lines, within the time of a regex search (P8).
|
|
350
|
+
Keyword search keeps its top passages in a heap (P9).
|
|
351
|
+
- Measured live: Gemini 3.5 Flash-Lite's timeline of a diary read whole lost a date in about one
|
|
352
|
+
run in three, when a part replied `NOTHING RELEVANT`. An A/B with 0.9.0, 8 reads each, lost no
|
|
353
|
+
date on either. This is recorded as a limit of Flash-Lite, not tuned
|
|
354
|
+
([Measurements](docs/measurements.md#whole-file-reads-and-items-package-t)).
|
|
355
|
+
|
|
356
|
+
**Gemini and other providers**
|
|
357
|
+
|
|
358
|
+
- A Gemini part read stopped by a filter or for an `"other"` reason is flagged as incomplete.
|
|
359
|
+
- A Vertex AI 401 with a token from a function is sent once more with a fresh token, in chat
|
|
360
|
+
requests, part reads and the explorer. A second 401 is the error; a refresh that throws keeps the
|
|
361
|
+
401 as the error, with the refresh's error as its `cause`.
|
|
362
|
+
- A non-streamed Gemini reply that is a list of chunks is read chunk by chunk, and an error inside
|
|
363
|
+
a stream carries its `retryDelay`.
|
|
364
|
+
- `timeoutMs: 0` sets no limit in `openAiCompatible()` and `anthropic()` too.
|
|
365
|
+
|
|
366
|
+
**Storage and operations**
|
|
367
|
+
|
|
368
|
+
- Deletes of one library run one at a time, and one time limit covers a whole delete.
|
|
369
|
+
- `FileDocumentStore` writes a text longer than 1 Mi UTF-16 units in slices: a 50 MB put held the
|
|
370
|
+
event loop for 379 ms, and now for about 20 ms, with the same bytes.
|
|
371
|
+
- `FileDocumentStore` claims a removal by renaming the metadata to a name of its own, and counts
|
|
372
|
+
only its own removals.
|
|
373
|
+
- The upload handlers' calls to the disk past `uploadIdleTimeoutMs`, and ingest's store calls past
|
|
374
|
+
`ingestTimeoutMs`, count as stuck. At the limit, a sweep and ingest's store calls are refused too;
|
|
375
|
+
ingest's clean-up removal is not.
|
|
376
|
+
|
|
377
|
+
**PDFs**
|
|
378
|
+
|
|
379
|
+
- The outline of a PDF from type sizes: levels 1 to 3 from the sizes used by several headings, and
|
|
380
|
+
a title or cover line set larger than all of them is level 1. Not headings: table rows (a gap of
|
|
381
|
+
more than 3 times the type size between pieces), running headers and footers (a line repeated on
|
|
382
|
+
3 or more pages, or on at least half of them), page numbers (lines that differ only by their
|
|
383
|
+
numbers, on at least half the pages, and that do not count up as section numbers do, on one page
|
|
384
|
+
or from page to page; the same number in a page's header and footer is one page number, while
|
|
385
|
+
headings that count up, such as "פרק 1" to "פרק 5" on the odd pages, are kept; chapters one to a
|
|
386
|
+
page, on pages in a row covering at least half the document, are taken for page numbers), lines
|
|
387
|
+
over 120 characters, and lines with fewer than 3 letters or more digits than letters. A PDF with
|
|
388
|
+
3 or more text-rule headings keeps its outline, and the text of a PDF does not change.
|
|
389
|
+
|
|
390
|
+
**Release**
|
|
391
|
+
|
|
392
|
+
- The release workflow runs by hand as a dry run, the default: it builds and checks the tarball on
|
|
393
|
+
any branch or tag, then runs `npm publish --dry-run` in a job with no identity token
|
|
394
|
+
([Publishing](docs/publishing.md#a-dry-run-of-the-release-workflow), LO-6).
|
|
395
|
+
- An eval suite of 48 Hebrew and English cases (in `evals/`, not published) replays its recorded
|
|
396
|
+
requests on every pull request. The prompt changes of this version were gated on it live, on
|
|
397
|
+
Gemini 3.5 Flash-Lite and 3.8 Flash: tables and line numbers by P1's gate (pass^3, at 64a4ec8),
|
|
398
|
+
whole-file reads and items by T's (at c1fbbb5)
|
|
399
|
+
([Measurements](docs/measurements.md#tables-sent-whole-p1s-live-gate)). Each of its 96
|
|
400
|
+
recordings (48 cases on 2 models) replays against 0.10.0, so 0.10.0 sends the requests that were
|
|
401
|
+
recorded live, byte for byte but for keys and project IDs (T4;
|
|
402
|
+
[Testing](docs/guides/testing.md#the-librarys-own-evals)).
|
|
403
|
+
|
|
404
|
+
### Fixed
|
|
405
|
+
|
|
406
|
+
**Questions and costs**
|
|
407
|
+
|
|
408
|
+
- **No ceiling by default, and a set one overshot (L5, L7):** a runaway question made 13 requests
|
|
409
|
+
and about 6.9M input tokens; a ceiling of 500,000 let 1,219,683 through, and never tripped when the
|
|
410
|
+
provider reported no usage.
|
|
411
|
+
- **L1:** results over tables of numbers took 2.22 times their room.
|
|
412
|
+
- **LLF-048:** on the last tool turn, the remark of a reply whose tool call could not be read was
|
|
413
|
+
taken for the answer.
|
|
414
|
+
- **LLF-049:** calls of unknown tools took room, and shortened earlier results.
|
|
415
|
+
- **LLF-058:** a whole-file read that had failed was priced again, instead of refused with its
|
|
416
|
+
reason.
|
|
417
|
+
- **N12:** a whole-file read passed `limits.requests`: 40 requests against 32, 42 through
|
|
418
|
+
`askWithFiles`.
|
|
419
|
+
- **A6, NEW-filtered-answer:** a reply that Gemini ended with `MODEL_ARMOR`, `OTHER`, `LANGUAGE` or
|
|
420
|
+
another reason the library did not know cost 4 requests and gave no finish, and a filtered or
|
|
421
|
+
cut answer read as complete ("The employee's medical leave was", `answered: true`).
|
|
422
|
+
- **LO-7:** with `eventResults`, event plans held owner, scope, sha256 and original at run time.
|
|
423
|
+
- `alreadyShown` could point to a result that `onToolResult` replaced.
|
|
424
|
+
|
|
425
|
+
**Tables and citations**
|
|
426
|
+
|
|
427
|
+
- **NEW-inline-table-tools:** a CSV of 3,000 Hebrew invoices went whole with no tools, and its 750
|
|
428
|
+
late invoices were counted by eye. Live, counts over tables were right in 24 of 24 on both
|
|
429
|
+
models.
|
|
430
|
+
- **L12:** files sent whole had no line numbers, citation line or evidence.
|
|
431
|
+
- **LLF-059:** card sizes read "1024 KB" and "1000K", and so did the size of
|
|
432
|
+
`get_document_overview` and of some error messages; they read "1 MB" and "1.0M".
|
|
433
|
+
- **LLF-061:** `describe()` of a `read_document` call left out an end line given as a string
|
|
434
|
+
(`"250"`), which the tool reads: it now says "lines 1-250".
|
|
435
|
+
|
|
436
|
+
**Providers**
|
|
437
|
+
|
|
438
|
+
- **LLF-018:** a Gemini error in a stream or a reply of HTTP 200 with no numeric code had status
|
|
439
|
+
200; a part read whose body of HTTP 200 held an error reported "The model returned no text".
|
|
440
|
+
- **LLF-034:** an OpenAI call without an ID got an ID in its tool message that the call itself did
|
|
441
|
+
not have.
|
|
442
|
+
- **LLF-035:** a stream without `index` that repeated the ID on every piece made one call per piece.
|
|
443
|
+
- **LLF-036:** an aborted part read waited for another question's request: 1.5 s after an abort at
|
|
444
|
+
50 ms, now 51 ms.
|
|
445
|
+
- **LLF-056, A11:** the time limit of a Gemini part read (180 s) could not be changed, and a part
|
|
446
|
+
read failed after 6 minutes; a timeout was not of kind `"timeout"`.
|
|
447
|
+
- **LLF-057:** Gemini encoded tool files with its own base64, beside the shared cache.
|
|
448
|
+
- A Gemini part read whose body was a list of chunks kept only the first chunk, and missed an error
|
|
449
|
+
in a later one.
|
|
450
|
+
- A part read's time limit did not end the wait for a `fetch` that ignores its signal, in all three
|
|
451
|
+
adapters.
|
|
452
|
+
|
|
453
|
+
**Storage and operations**
|
|
454
|
+
|
|
455
|
+
- **NEW-store-call-timeout:** a store that did not answer held a question, `files.delete`, the
|
|
456
|
+
DELETE route and the upload handler's rollback delete forever.
|
|
457
|
+
- **Four stuck calls froze a pod:** with the default thread pool, every file call and DNS look-up of
|
|
458
|
+
the process waited.
|
|
459
|
+
- On Windows, two sweeps could count one document twice, and two deletes of one document could both
|
|
460
|
+
return true.
|
|
461
|
+
|
|
462
|
+
**PDFs**
|
|
463
|
+
|
|
464
|
+
- **An unnumbered Hebrew PDF had no outline** (HARNESS-LESSONS item 4): Hebrew has no capitals, and
|
|
465
|
+
pdf.js gives no blank lines. A Hebrew lease now gets its title, sections and subsections, and the
|
|
466
|
+
isolated child returns the same outline as the server.
|
|
467
|
+
|
|
468
|
+
**Docs**
|
|
469
|
+
|
|
470
|
+
- **A1:** the OpenAI recipe uses `reasoning_effort: "none"`, which tool calls on GPT-5.4 and later
|
|
471
|
+
need through Chat Completions.
|
|
472
|
+
- **DeepSeek:** in a request with tools, its thinking mode asks for the reasoning of every earlier
|
|
473
|
+
assistant turn, those of earlier questions included, and refuses a request without it (HTTP 400,
|
|
474
|
+
as DeepSeek's guide says). The library does not keep the reasoning of an earlier question, so the
|
|
475
|
+
guide says to turn thinking off for chat requests in a chat of several questions
|
|
476
|
+
([DeepSeek](docs/guides/openai-compatible.md#deepseek)).
|
|
477
|
+
|
|
478
|
+
In all, this version fixes LLF-018, -034, -035, -036, -048, -049, -056, -057, -058, -059 and
|
|
479
|
+
-061. It closes the roadmap items A5, A6, A11, I6 (`files.toolsFor`), I9 (`ToolCallHooks.signal`),
|
|
480
|
+
L1, L5, L7, L12, M8, M9, N12, P8, P9, S3 (in part: the citation check), T4, the leftovers of 0.9.0
|
|
481
|
+
(LO-1, LO-2 (the write half), LO-3 to LO-7), NEW-answer-request-tools, NEW-filtered-answer,
|
|
482
|
+
NEW-inline-table-tools, NEW-store-call-timeout and NEW-vertex-endpoint-options, and the Hebrew PDF
|
|
483
|
+
outline (HARNESS-LESSONS item 4).
|
|
484
|
+
|
|
485
|
+
## 0.9.0 — 2026-11-24
|
|
486
|
+
|
|
487
|
+
One server process for every user and chat. Every store call carries the scope and the owner of
|
|
488
|
+
the call, `FileDocumentStore` keeps the files of each chat in a folder of its own, documents can
|
|
489
|
+
take your application's IDs, and the uploads your application keeps are read where they are
|
|
490
|
+
instead of copied into the store. The upload handlers can save each upload where you keep it,
|
|
491
|
+
record it in your database and hold large uploads on disk; errors are typed, and `errorInfoOf`
|
|
492
|
+
puts them in your users' words. The text sent to the model is the same as in 0.8.2 for ordinary
|
|
493
|
+
chats, so conversations keep the provider's prompt cache at the upgrade.
|
|
494
|
+
[Upgrading to 0.9](docs/upgrading-0.9.md) takes an application from 0.8.x step by step, with a
|
|
495
|
+
worked example of a chatbot on a shared volume.
|
|
496
|
+
|
|
497
|
+
### Upgrading: what you need to change
|
|
498
|
+
|
|
499
|
+
Code written for 0.8.2 compiles with 0.9.0, except in these cases
|
|
500
|
+
([Does my code compile?](docs/upgrading-0.9.md#does-my-code-compile)):
|
|
501
|
+
|
|
502
|
+
- `NoticeCode` has three new members, `"documents_missing"`, `"document_gone"` and
|
|
503
|
+
`"page_looks_busy"`, and `IngestErrorCode` one, `"exists"`. An exhaustive `switch` over either,
|
|
504
|
+
or a `Record` keyed by either, needs them.
|
|
505
|
+
- `EventError.code` is now `IngestErrorCode | DocumentScopeErrorCode`: the `run.error` or
|
|
506
|
+
`ingest.error` of a scope error carries `"scope_missing"`, `"scope_invalid"` or
|
|
507
|
+
`"scope_required"`. Code that indexes a `Record<IngestErrorCode, …>` with it, or passes it where
|
|
508
|
+
an `IngestErrorCode` is expected, must check it first. A `switch` over it with a `never` check
|
|
509
|
+
needs `"exists"` and the three scope codes.
|
|
510
|
+
- `LargeFiles.ingest` takes `IngestInput | IngestFromSource`. Code that reads `input.bytes` of its
|
|
511
|
+
argument fails with TS18048 or TS2532: a `LargeFiles` of your own whose `ingest` parameter is
|
|
512
|
+
inferred (`{ ...files, ingest: (input) => … }`), the calls of a spy or mock of `files.ingest`
|
|
513
|
+
(`spy.mock.calls[0][0].bytes`), and a value typed `Parameters<LargeFiles["ingest"]>[0]`. Code
|
|
514
|
+
that passes `input` to a function that takes `IngestInput` fails with TS2345. Narrow it:
|
|
515
|
+
`if (input.bytes)`, or `"source" in input`. Annotating `(input: IngestInput)` compiles too, but
|
|
516
|
+
only suits a wrapper that is never given a path: `createDocumentHandlers` gives one with
|
|
517
|
+
`uploadSpool` or `prepareUpload`.
|
|
518
|
+
- A store of your own, or a subclass of `FileDocumentStore` or `MemoryDocumentStore`, whose method
|
|
519
|
+
takes a parameter of its own after those of 0.8 (`get(id, options?)`, `sweep(now?, dryRun?)`,
|
|
520
|
+
`readTextRange(id, start, end, signal?)`) fails with TS2322 or TS2416. The new `context` takes
|
|
521
|
+
that place, and the library passes it there. Put your parameter after `context`.
|
|
522
|
+
- A subclass of `DocumentStoreError` that declares its own `status`, or of
|
|
523
|
+
`DocumentsNotFoundError` that declares its own `status` or `code`: these are now `503`, and `404`
|
|
524
|
+
and `"documents_missing"`.
|
|
525
|
+
- A subclass of `IngestError`, `DocumentStoreError`, `DocumentsNotFoundError` or
|
|
526
|
+
`ModelRequestError` whose own static `is` does not fit `(value: unknown) => value is …` (one
|
|
527
|
+
that returns `boolean`, say) fails with TS2417: each of them has a static `is` now. Make yours
|
|
528
|
+
return `value is` your class, or rename it.
|
|
529
|
+
- `fromGeminiContents` passed as a callback (`histories.map(fromGeminiContents)`) fails with
|
|
530
|
+
TS2345: its new second parameter would get the index. Write
|
|
531
|
+
`histories.map((contents) => fromGeminiContents(contents))`.
|
|
532
|
+
- Code that reads the `messages` of an `AskGeminiOptions` back and reads `text` of a turn fails with
|
|
533
|
+
TS2339, and code that passes them where `Array<ChatTurn | ToolTurn>` is expected with TS2345:
|
|
534
|
+
`messages` is now `ChatMessage[]`, as `askWithFiles` takes it, and a turn may have `parts` instead
|
|
535
|
+
of `text`. Type the history `Array<ChatTurn | ToolTurn>`, or check `"text" in turn`.
|
|
536
|
+
|
|
537
|
+
The other changes to the public types add exports, options, fields and optional parameters. Each
|
|
538
|
+
`DocumentStore` method takes a last, optional `context`: a store whose methods take only the
|
|
539
|
+
arguments of 0.8 still implements the interface. The new exports are under **New**.
|
|
540
|
+
|
|
541
|
+
Some behavior is different. Check each point against your app:
|
|
542
|
+
|
|
543
|
+
- **Node.js 22.12 or later.** `engines.node` is `>=22.12` (was `>=20.19`): Node 22.0 to 22.11 cannot
|
|
544
|
+
`require()` the package from CommonJS, which the docs promise. CI runs Node 22, 24 and 26, on
|
|
545
|
+
Ubuntu and Windows, and 22.12.0 on Ubuntu, where it also checks `require()` of every subpath of
|
|
546
|
+
the packed tarball. npm only warns (`EBADENGINE`) unless `engine-strict` is set, so an app on
|
|
547
|
+
Node 20 still installs, untested. There, an `unpdf` that cannot load pdf.js now throws its own
|
|
548
|
+
error, not "The unpdf installed cannot read PDF files on Node 20".
|
|
549
|
+
**What to do:** run Node 22.12 or later, and `@types/node` 22 or later in TypeScript projects.
|
|
550
|
+
- **The upload handler answers 422 only for an `IngestError` (S12).** A plain `Error` from a
|
|
551
|
+
`LargeFiles` of your own, without a `status` or a system `code`, is answered 500
|
|
552
|
+
`{ "error": "Upload failed." }`: it was 422 with its message, which could name a database host.
|
|
553
|
+
A file of code `"unreadable"` gets fixed words ("This file could not be read. It may be damaged,
|
|
554
|
+
or not of the type its name says."), not its parser's or extractor's message. A model's error
|
|
555
|
+
thrown by an ingest of yours gets the status and words of `errorInfoOf`, not the provider's. A
|
|
556
|
+
`DocumentScopeError` is a 404 "This chat no longer exists." for `"scope_missing"`, and a 500 for
|
|
557
|
+
the other codes. Only the handler's own 413s (its size check, and `IngestError` `"too_large"`)
|
|
558
|
+
get the upload-limit message. `Content-Type` is no longer URI-decoded (`X-File-Type` still is).
|
|
559
|
+
**What to do:** throw `new IngestError(code, message)` for a file you refuse, as the
|
|
560
|
+
`ingestInProcess` recipe of [Deployment](docs/guides/deployment.md#uploads-and-ingest) now does. A
|
|
561
|
+
route of your own answers the same way with `uploadAnswerOf`
|
|
562
|
+
([node](docs/reference/node.md#how-errors-are-answered)).
|
|
563
|
+
- **A store that fails is a `DocumentStoreError`, answered 503.** A failed write of `files.ingest`
|
|
564
|
+
throws one with `operation: "write"` (code `"ETIMEDOUT"` for a write that did not end within
|
|
565
|
+
`ingestTimeoutMs`), a failed `files.delete` one with `"delete"`, a failed `files.sweep` one with
|
|
566
|
+
`"sweep"`. Before, the store's own error came out as it was; it is now the `cause`. The upload
|
|
567
|
+
handler answers a failed write 503 with `Retry-After: 5` (it was a 500), and `get` and `remove`
|
|
568
|
+
answer a store that fails 503 with `Retry-After: 5` (it was a 500, such as "The file could not be
|
|
569
|
+
looked up (EIO)."). The `ingest.error` event of a failed write has `name: "DocumentStoreError"`
|
|
570
|
+
and `status: 503`.
|
|
571
|
+
**What to do:** code that catches its own store error class reads `error.cause`. Log
|
|
572
|
+
`error.cause`: the handlers log nothing
|
|
573
|
+
([Store failures](docs/upgrading-0.9.md#store-failures-are-documentstoreerror)).
|
|
574
|
+
- **`DocumentStoreError` has `status: 503`, and `DocumentsNotFoundError` has `status: 404` and
|
|
575
|
+
`code: "documents_missing"`.** Their `run.error` events carry the status too.
|
|
576
|
+
**What to do:** code that takes any error with a numeric `status` for a model's error checks
|
|
577
|
+
these first: `DocumentStoreError.is(error)`, `DocumentsNotFoundError.is(error)`, or
|
|
578
|
+
`errorInfoOf(error)`.
|
|
579
|
+
- **Every store call carries a context.** The library passes `{ scope, owner }` as the last argument
|
|
580
|
+
of every `DocumentStore` method. A wrapper or a subclass that passes only the ID on
|
|
581
|
+
(`super.getMeta(id)`, `(id) => inner.getMeta(id)`) still compiles, but drops it. Over a store that
|
|
582
|
+
keeps scopes apart, such a call does not find the documents stored in a scope. Over a
|
|
583
|
+
`FileDocumentStore` with `scopes`, every call but `sweep` throws a `DocumentScopeError`
|
|
584
|
+
`"scope_required"`. With `unscoped: "root"`, the documents go to the root folder without an error,
|
|
585
|
+
outside the chat's folder, so removing that folder does not erase them. And a `sweep` that drops
|
|
586
|
+
it sweeps every scope: `files.sweep({ scope })` removes the expired documents of every chat. A
|
|
587
|
+
store that ignores the context still keeps scopes apart for the library, through `meta.scope`,
|
|
588
|
+
and then needs application IDs that are unique in the whole store.
|
|
589
|
+
**What to do:** pass the context on (`super.getMeta(id, context)`), and run `documentStoreChecks`
|
|
590
|
+
of `llm-large-files/testing` on your store
|
|
591
|
+
([Stores of your own](docs/upgrading-0.9.md#stores-of-your-own)).
|
|
592
|
+
- **A store that writes the text before the record.** The storage guide's example
|
|
593
|
+
`BlobDocumentStore` wrote the text, then inserted the record under a unique key. When two servers
|
|
594
|
+
ingest one application's ID at the same moment, the ingest that loses has then written its text
|
|
595
|
+
over the winner's. The library now reads the winner's document as missing when the two texts
|
|
596
|
+
differ in length or lines; otherwise it serves the loser's text.
|
|
597
|
+
**What to do:** insert the record first, hidden from `getMeta` until the text is written, as the
|
|
598
|
+
example now does ([Example: object storage and a database](docs/guides/storage.md#example-object-storage-and-a-database)).
|
|
599
|
+
Two ingests of one ID that overlap then both fail with a 503 instead of storing the wrong text.
|
|
600
|
+
With an ID of its own for each upload, as `attach()` and the worked example make, none of this
|
|
601
|
+
happens ([Write the record before the text](docs/upgrading-0.9.md#write-the-record-before-the-text)).
|
|
602
|
+
- **New fields in what you store.** `ingest` writes `metaVersion: 1` and `sha256` into every
|
|
603
|
+
`DocumentMeta`, and `scope` and `original` when it is given them. Every `ToolTurn` that
|
|
604
|
+
`askWithFiles` returns has `version: 1`.
|
|
605
|
+
**What to do:** tests that compare a meta or a round whole expect these fields. A schema that
|
|
606
|
+
refuses fields it does not know (a MongoDB `$jsonSchema` with `additionalProperties: false`, a
|
|
607
|
+
Mongoose schema in strict mode that throws) must allow them, for the metadata a store of yours
|
|
608
|
+
keeps and for the rounds you keep with each question: otherwise every ingest fails with a 503.
|
|
609
|
+
Change it before the first server of 0.9.0 starts
|
|
610
|
+
([Allow the new fields](docs/upgrading-0.9.md#allow-the-new-fields)).
|
|
611
|
+
- **Data written by a newer version is refused, not taken for missing.** Metadata with
|
|
612
|
+
`metaVersion` above 1 makes `getMeta`, `getOriginal`, `delete`, `prepare`, `askWithFiles` and the
|
|
613
|
+
tools throw a `DocumentStoreError` of code `"NEWER_VERSION"`, so that your app does not ingest
|
|
614
|
+
the file again over newer data. A stored `ToolTurn` with `version` above 1 makes `askWithFiles`
|
|
615
|
+
throw a `TypeError`, before any request. Servers of 0.8 ignore both fields.
|
|
616
|
+
**What to do:** nothing now. While servers of 0.9 and a later version share a store, let such a
|
|
617
|
+
call be tried again on a newer server; catch the `TypeError` to ask again without the old rounds.
|
|
618
|
+
- **Servers of 0.8 and 0.9 on one store.** In the flat layout of `FileDocumentStore`, servers of 0.8
|
|
619
|
+
read what 0.9.0 writes under the library's IDs, and ignore the new fields; 0.9.0 reads what 0.8
|
|
620
|
+
wrote. Servers of 0.8 do not see documents under an application's ID, nor the folders of a store
|
|
621
|
+
with `scopes`, nor an original kept by reference, and they do not check `meta.scope`.
|
|
622
|
+
**What to do:** upgrade first with your settings as they are. Turn on `scopes`, application IDs,
|
|
623
|
+
originals by reference, `requireOwner` and `requireScope` in a later deploy: on every server at
|
|
624
|
+
once, or with each chat kept on servers of one setting. Run the sweep from a server of 0.9.0
|
|
625
|
+
([Several servers and rolling deploys](docs/upgrading-0.9.md#several-servers-and-rolling-deploys)).
|
|
626
|
+
- **`requireOwner` and `requireScope`** (new, off by default) make `createDocumentHandlers` throw a
|
|
627
|
+
`TypeError` without `getOwner`, or without `getScope`. Under `requireOwner`, an owner of
|
|
628
|
+
`undefined` or `null` is answered 401 `{ "error": "Sign in first." }` on every route, and `""` a
|
|
629
|
+
500 "(empty owner)". Documents stored without an owner or a scope then read as missing: those of
|
|
630
|
+
0.8, and those that 0.5.0 stored with the owner `""`.
|
|
631
|
+
**What to do:** give `getOwner` and `getScope`, and turn them on once no server writes documents
|
|
632
|
+
without them ([Moving the documents of 0.8](docs/upgrading-0.9.md#moving-the-documents-of-08)).
|
|
633
|
+
- **`FileDocumentStore` writes files `0600` and folders `0700`.** Before, `0666` and `0777` minus the
|
|
634
|
+
umask: `0664` and `0775` under the usual `0002`. Servers, sidecars, and backup or sweep jobs that
|
|
635
|
+
run as other users of one group (a Kubernetes `fsGroup`) read "The document store could not be
|
|
636
|
+
read (EACCES)".
|
|
637
|
+
**What to do:** for those, set `fileMode: 0o640` and `directoryMode: 0o750` on every store. Files
|
|
638
|
+
written before keep their modes: `chmod` them once to narrow them.
|
|
639
|
+
- **`FileDocumentStore` follows no link at a document's file name**, except on Windows, which
|
|
640
|
+
cannot refuse one. A document whose `.json` or `.txt` file is a link (left by a migration or a
|
|
641
|
+
deduplication, say) reads as missing on Linux and macOS, and a kept copy (`.bin`) that is a link
|
|
642
|
+
as not kept.
|
|
643
|
+
**What to do:** replace such links with the files they point to before you upgrade.
|
|
644
|
+
- **`FileDocumentStore.delete` returns true once the metadata is gone.** A text, index or original
|
|
645
|
+
it cannot remove is left for `sweep`; it used to throw. Removals are tried again for about 2.6 s
|
|
646
|
+
on `EPERM`, `EACCES` and `EBUSY`, as renames are.
|
|
647
|
+
**What to do:** for erasure, keep a sweep running, or remove the scope's folder. Tests that mock
|
|
648
|
+
`fs.rm` to make a removal fail must mock `unlink`.
|
|
649
|
+
- **MIME types are cleaned.** `meta.mimeType` is a lowercased type/subtype without parameters
|
|
650
|
+
(`"Text/CSV; charset=x"` is stored as `"text/csv"`). A value that is not a valid type/subtype of at
|
|
651
|
+
most 127 characters, or holds anything but printable ASCII, is stored as
|
|
652
|
+
`application/octet-stream`.
|
|
653
|
+
**What to do:** compare `meta.mimeType` with the clean form.
|
|
654
|
+
- **Looks at pages take turns.** In a library, one `view_pages` look runs at a time
|
|
655
|
+
(`maxConcurrentPageLooks: 1`), and the others wait up to 30 s (`pageLookWaitMs`). Past that the
|
|
656
|
+
model is told the server is busy, and the question gets a `"page_looks_busy"` notice. A look
|
|
657
|
+
holds its turn while its PDF is read for at most `ingestTimeoutMs`.
|
|
658
|
+
**What to do:** nothing. On a server with heap to spare, raise `maxConcurrentPageLooks`;
|
|
659
|
+
`Infinity` runs every look at once, as in 0.8.2 ([PDFs](docs/guides/pdfs.md#view_pages)).
|
|
660
|
+
- **`fromGeminiContents` turns the library's tool rounds back into stored rounds**, and so does
|
|
661
|
+
`askGemini` with `contents`. Pointers and stand-ins then apply, as with `toolTurns`. The first
|
|
662
|
+
request is the same, byte for byte, for rounds that `geminiToolTurns` wrote. Rounds that 0.5.0
|
|
663
|
+
converted hold `tool_turns_left` in their responses: they are now sent without it, so such a
|
|
664
|
+
conversation misses the prompt cache once.
|
|
665
|
+
**What to do:** nothing. `{ rounds: false }` gives the output of 0.8. With `askGemini`, pass it as
|
|
666
|
+
`messages`: `askGemini({ …, messages: fromGeminiContents(contents, { rounds: false }) })`.
|
|
667
|
+
- **Tests of the tool loop.** A first request that stored rounds make too large is shortened before
|
|
668
|
+
it is sent: a test sees a `"results_shortened"` step and one request fewer, not a refused request
|
|
669
|
+
and `"room_made"`. A result that its stand-in would not make smaller (a short grouped search, a
|
|
670
|
+
small `aggregate_table` result) stays whole. An error of an adapter of yours with a `status` and
|
|
671
|
+
no `kind`, as `httpError` of `llm-large-files/testing` makes, gets a `kind` in its `EventError`
|
|
672
|
+
(`"server"` for a 503), and is retried by that kind: a 429 of code `"insufficient_quota"` is a
|
|
673
|
+
quota, and is not sent again. The loop goes by that kind too: an `httpError(413)`, a 429 "Request
|
|
674
|
+
too large … tokens per min" or a 400 of code `context_length_exceeded` is an overflow it mends.
|
|
675
|
+
Older results are shortened and the request is sent again (`"room_made"`), or a first request is
|
|
676
|
+
planned again (`"replanned"`), so a test that expected the question to fail at once sees one more
|
|
677
|
+
request. Thrown plain data with a status is "Something went wrong." in its event.
|
|
678
|
+
**What to do:** update the tests that compare these whole.
|
|
679
|
+
- **`isDocumentId` accepts application IDs.** It tests `APP_DOCUMENT_ID_PATTERN`, which the
|
|
680
|
+
library's `doc_` IDs match too.
|
|
681
|
+
**What to do:** to tell the library's IDs from yours, test `DOCUMENT_ID_PATTERN`.
|
|
682
|
+
- **If you give documents your own IDs** (`IngestInput.id`, new): they reach the model, in what it
|
|
683
|
+
is sent of each document and in its tool calls, so they must hold no personal data. A taken ID is
|
|
684
|
+
an `IngestError` `"exists"` (409), and so is a second ingest of one ID while the first is under way
|
|
685
|
+
in the library. In a folder that `FileDocumentStore` shares with your files, an ingest under the
|
|
686
|
+
ID `report` writes over your `report.txt`.
|
|
687
|
+
**What to do:** use random IDs, or IDs with a prefix per tenant
|
|
688
|
+
([Application IDs](docs/guides/storage.md#application-ids)).
|
|
689
|
+
- **If you keep the uploads yourself:** `keepOriginals` still copies each kept file into the store.
|
|
690
|
+
With `original: { ref }` and `originals` (`fileOriginals(root)` of `llm-large-files/node`), the
|
|
691
|
+
store keeps no copy, and `view_pages` reads your file, checked against the size and SHA-256 it had
|
|
692
|
+
at ingest. The library never writes, moves or deletes it. Documents ingested before keep their
|
|
693
|
+
copy. A server of 0.8 finds no copy of such a file: its `view_pages` answers that the original is
|
|
694
|
+
no longer on the server.
|
|
695
|
+
**What to do:** remove the file with its chat
|
|
696
|
+
([The file your application keeps](docs/guides/storage.md#the-file-your-application-keeps)).
|
|
697
|
+
- **The text sent to the model** is that of 0.8.2 for ordinary chats. Text is new only when its case
|
|
698
|
+
happens: the line for documents left out under `onMissingDocuments: "drop"`, the busy answer of
|
|
699
|
+
`view_pages`, and its answers for a file kept by reference that changed and for a PDF the store
|
|
700
|
+
did not return in time. A document ingested under your ID is named by that ID. A right-to-left
|
|
701
|
+
PDF table ingested from 0.9.0 on can read in another order (LLF-037, under **Fixed**); documents
|
|
702
|
+
ingested before keep their text.
|
|
703
|
+
**What to do:** nothing.
|
|
704
|
+
|
|
705
|
+
### New: what you can add
|
|
706
|
+
|
|
707
|
+
**Owners, scopes and IDs**
|
|
708
|
+
|
|
709
|
+
- **Scopes:** `IngestInput.scope`, `AccessOptions.scope`, `AskOptions.scope` (also in `askStream`
|
|
710
|
+
and `askGemini`) and `files.sweep({ scope })`, with the types `DocumentScope` and
|
|
711
|
+
`DocumentContext`. A document with a scope serves only a caller of the same scope
|
|
712
|
+
([Scopes](docs/guides/storage.md#scopes)).
|
|
713
|
+
- **`requireOwner` and `requireScope`** in `createLargeFiles`, both off: a call without an owner, or
|
|
714
|
+
without a scope, throws a `TypeError`. `files.access` says which are on
|
|
715
|
+
([Storage](docs/guides/storage.md#requiring-an-owner-and-a-scope)).
|
|
716
|
+
- **Application IDs:** `IngestInput.id`, `ifExists` (`"fail"` by default, or `"replace"`) and
|
|
717
|
+
`APP_DOCUMENT_ID_PATTERN` ([Application IDs](docs/guides/storage.md#application-ids)).
|
|
718
|
+
- **A folder per user and chat:** `FileDocumentStore`'s `scopes` option
|
|
719
|
+
(`{ depth, folder, createScopeFolders, unscoped }`) keeps each scope's files in
|
|
720
|
+
`<root>/<user>/<chat>/.llm-large-files/`, under one library for the process. Also its options
|
|
721
|
+
`fileMode`, `directoryMode` and `sweepConcurrency`, the types `FileDocumentStoreOptions` and
|
|
722
|
+
`FileDocumentScopes`, and `isSafeScopeSegment` and `hashedScopeSegment`
|
|
723
|
+
([Files in a folder per user or per chat](docs/guides/storage.md#files-in-a-folder-per-user-or-per-chat)).
|
|
724
|
+
- **`MemoryDocumentStore`** keeps each scope's documents apart.
|
|
725
|
+
- **`ToolOptions.access`:** `files.tools()` checks the owner and scope the store holds, not those
|
|
726
|
+
of the metadata it is given ([Your own loop](docs/guides/own-adapter-and-loop.md#your-own-loop)).
|
|
727
|
+
|
|
728
|
+
**Ingest**
|
|
729
|
+
|
|
730
|
+
- **Ingest from a path:** `files.ingest({ name, source: { path } })` (`IngestFromSource`,
|
|
731
|
+
`IngestSource`). The file is looked at with `lstat` at the call, and read once at its turn, so
|
|
732
|
+
ingests that wait hold none of their files: 100 ingests of 2 MB waiting for their turn held 73 MB
|
|
733
|
+
as paths, against 282 to 286 MB with their bytes
|
|
734
|
+
([IngestFromSource](docs/reference/library.md#ingestfromsource)).
|
|
735
|
+
- **Originals by reference:** `IngestInput.original: { ref }`, `LargeFilesOptions.originals`
|
|
736
|
+
(`OriginalsReader`, `OriginalReadContext`), and `fileOriginals(root)` in `llm-large-files/node`.
|
|
737
|
+
`meta.original` records the ref, the size and the SHA-256
|
|
738
|
+
([Storage](docs/guides/storage.md#the-file-your-application-keeps)).
|
|
739
|
+
- **`DocumentMeta.sha256`:** the SHA-256 of each upload, to find the same file twice in a chat. The
|
|
740
|
+
library does not dedupe.
|
|
741
|
+
- **`Extractor.readsPath`**, with `ExtractInput.path`, `ExtractInput.maxUploadBytes` and
|
|
742
|
+
`ExtractedText.file`: an extractor that reads the file itself. `createIsolatedExtractors` sets it
|
|
743
|
+
([Extractor](docs/reference/library.md#extractor)).
|
|
744
|
+
|
|
745
|
+
**Upload handlers** (`llm-large-files/node`)
|
|
746
|
+
|
|
747
|
+
- **`getScope(request)`:** the scope of each upload, get and delete
|
|
748
|
+
([node](docs/reference/node.md#what-getscope-returns)).
|
|
749
|
+
- **`onUploaded` and `onRemoved`:** record an upload in your database before it is answered, and a
|
|
750
|
+
removal after it. `{ answer }` joins the 201 and `ingest.finish.app`. Types `UploadedContext`,
|
|
751
|
+
`UploadedResult` and `RemovedContext`
|
|
752
|
+
([hooks](docs/reference/node.md#the-hooks-onuploaded-and-onremoved)).
|
|
753
|
+
- **`prepareUpload(request, { name, owner, scope })`:** the upload's ID, and a path where its body
|
|
754
|
+
is saved as it arrives, kept by reference with `original`. Types `PrepareUploadInfo` and
|
|
755
|
+
`PreparedUpload`, and `uploadFileMode` (`0o600`)
|
|
756
|
+
([Web app](docs/guides/web-app.md#save-each-upload-where-you-keep-it-prepareupload)).
|
|
757
|
+
- **`uploadSpool`** (`true`, or `UploadSpoolOptions`; off by default) and `maxSpooledUploadBytes`
|
|
758
|
+
(ten times `maxUploadBytes`): bodies over 1 MiB, or without a `Content-Length`, wait for their
|
|
759
|
+
ingest on disk ([spooling](docs/reference/node.md#spooling-uploadspool)).
|
|
760
|
+
- **`uploadAnswerOf(error)`** and `UploadAnswer`: how the handlers answer an error, for a route of
|
|
761
|
+
your own ([node](docs/reference/node.md#how-errors-are-answered)).
|
|
762
|
+
|
|
763
|
+
**Questions**
|
|
764
|
+
|
|
765
|
+
- **`onMissingDocuments`** in `askWithFiles`, `askStream` and `askGemini`: `"throw"` (the default),
|
|
766
|
+
`"drop"`, or a function that can ingest them again (`{ retry: true }`, `{ replace }`). Also
|
|
767
|
+
`AskResult.missing`, and the types `MissingDocumentsAction` and `MissingDocumentsContext`
|
|
768
|
+
([missing documents](docs/reference/ask.md#missing-documents)).
|
|
769
|
+
- **Notices** `"documents_missing"`, `"document_gone"` and `"page_looks_busy"`, and `documentIds`
|
|
770
|
+
on the `notice` event ([events](docs/reference/events.md#noticecode-and-noticedisplay)).
|
|
771
|
+
- **`maxConcurrentPageLooks`** (1) and **`pageLookWaitMs`** (30,000) in `createLargeFiles`. For
|
|
772
|
+
loops of your own: `ToolCallLimits.maxWaitMs`, and `ToolCallHooks.onDocumentGone` and
|
|
773
|
+
`onPagesBusy` ([library](docs/reference/library.md#largefilesoptions)).
|
|
774
|
+
- **`fromGeminiContents(contents, { rounds })`** and `FromGeminiContentsOptions`
|
|
775
|
+
([gemini](docs/reference/gemini.md#fromgeminicontentscontents-options)).
|
|
776
|
+
- **`AskGeminiOptions.messages` takes what `askWithFiles` takes (`ChatMessage[]`):** plain turns,
|
|
777
|
+
stored tool rounds, and turns with parts, such as `fromGeminiContents(contents, { rounds: false })`
|
|
778
|
+
gives. It was `Array<ChatTurn | ToolTurn>` ([gemini](docs/reference/gemini.md#askgeminioptions)).
|
|
779
|
+
|
|
780
|
+
**Errors and versions**
|
|
781
|
+
|
|
782
|
+
- **`errorInfoOf(error)`**, with `ErrorInfo` and `ErrorCategory`: one record for any error of the
|
|
783
|
+
library, or its `EventError`: a category, a code, the HTTP status, whether to retry and after how
|
|
784
|
+
long, and an English message that is safe to show. One `switch` maps it to your users' language
|
|
785
|
+
([Errors and reliability](docs/guides/errors-and-reliability.md#your-users-words-errorinfoof)).
|
|
786
|
+
- **`DocumentScopeError`** (`"scope_required"`, `"scope_invalid"`, `"scope_missing"`) and
|
|
787
|
+
`DocumentScopeErrorCode`. `DocumentStoreError` takes `{ operation, code }`, and has `operation`
|
|
788
|
+
(`DocumentStoreOperation`). `IngestErrorCode` `"exists"` (409).
|
|
789
|
+
- **A static `is(value)`** on `DocumentStoreError`, `DocumentScopeError`, `DocumentsNotFoundError`,
|
|
790
|
+
`IngestError` and `ModelRequestError`, which works across two copies of the package
|
|
791
|
+
([errors](docs/reference/errors-and-retries.md#telling-errors-apart-across-copies-of-the-package)).
|
|
792
|
+
- **`DOCUMENT_META_VERSION`** and **`TOOL_TURN_VERSION`**, and the fields `DocumentMeta.metaVersion`
|
|
793
|
+
and `ToolTurn.version` ([library](docs/reference/library.md#document_meta_version)).
|
|
794
|
+
|
|
795
|
+
**Testing**
|
|
796
|
+
|
|
797
|
+
- **`llm-large-files/testing`:** `fakeModel` (with `says`, `calls` and `httpError`), `fakeFetch`
|
|
798
|
+
(with `sse`), the test documents `utf8` and `serviceLog`, and `documentStoreChecks`, the checks a
|
|
799
|
+
store of your own must pass. It needs no test framework
|
|
800
|
+
([reference](docs/reference/testing.md), [guide](docs/guides/testing.md)).
|
|
801
|
+
|
|
802
|
+
One library for a chat server, with a folder per user and chat:
|
|
803
|
+
|
|
804
|
+
```ts
|
|
805
|
+
import { createLargeFiles, FileDocumentStore, hashedScopeSegment } from "llm-large-files";
|
|
806
|
+
import { createDocumentHandlers } from "llm-large-files/node";
|
|
807
|
+
|
|
808
|
+
const VOLUME = "/mnt/documents";
|
|
809
|
+
|
|
810
|
+
export const files = createLargeFiles({
|
|
811
|
+
store: new FileDocumentStore(VOLUME, { scopes: { depth: 2 } }), // <user>/<chat>/.llm-large-files/
|
|
812
|
+
keepOriginals: ["pdf"],
|
|
813
|
+
requireOwner: true,
|
|
814
|
+
requireScope: true,
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
// The scope is [hashedScopeSegment(userId), chatId]: a user ID may hold capitals or an "@", which
|
|
818
|
+
// cannot name a folder. Make the folder <VOLUME>/<user>/<chat> when you create the chat: the store
|
|
819
|
+
// makes only .llm-large-files inside it (createScopeFolders is off).
|
|
820
|
+
export const documents = createDocumentHandlers(files, {
|
|
821
|
+
getOwner: (request) => userIdOf(request),
|
|
822
|
+
getScope: (request) => [hashedScopeSegment(userIdOf(request)!), chatIdOf(request)],
|
|
823
|
+
});
|
|
824
|
+
// Ask with the same owner and scope: askGemini({ files, endpoint, owner: userId, scope: [hashedScopeSegment(userId), chatId], … }).
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
`userIdOf` is your sign-in, and `chatIdOf` one of the user's own chats, as an ID that passes
|
|
828
|
+
`isSafeScopeSegment`. To save each upload where you keep it and read it there, add
|
|
829
|
+
`prepareUpload` and `originals`, as the
|
|
830
|
+
[worked example](docs/upgrading-0.9.md#a-worked-example-a-hebrew-chatbot-on-gemini-mongodb-and-a-shared-volume)
|
|
831
|
+
does.
|
|
832
|
+
|
|
833
|
+
### Changed: what works differently
|
|
834
|
+
|
|
835
|
+
**Storage**
|
|
836
|
+
|
|
837
|
+
- One ID in two scopes is two documents everywhere, in memory too. The cache, the decoded pieces
|
|
838
|
+
and the documents being opened are kept per scope, and a copy is checked against the owner the
|
|
839
|
+
store holds. A delete or a re-ingest of an ID forgets its copies in every scope.
|
|
840
|
+
- An owner or a scope of `null` from a store (MongoDB writes left-out fields that way) counts as
|
|
841
|
+
absent. Metadata that a store returns for another ID than the one asked for reads as missing. So
|
|
842
|
+
does a text read whole whose length or number of lines is not what its metadata says, and a text
|
|
843
|
+
read by range whose index, built again, does not match its metadata: the index is built again
|
|
844
|
+
when none is saved, or when the text does not end where the saved one says. A store that writes
|
|
845
|
+
the text and the metadata apart can give one document's metadata with another's text, when two
|
|
846
|
+
servers ingest one ID at the same moment. Before, a text read whole was not checked, and an index
|
|
847
|
+
built again from a text that did not match its metadata was used. A text of the same length and
|
|
848
|
+
lines is not caught. Opening a document through its saved index reads one byte across the end of
|
|
849
|
+
its text: one `readTextRange` call more.
|
|
850
|
+
- The reads of a document's text (`get`, `readTextRange`, `getIndex`, and `putIndex` when an index
|
|
851
|
+
is built again) carry the caller's scope and the document's owner. `getMeta`, `getOriginal` and
|
|
852
|
+
`delete` carry the caller's ([Writing a store of your own](docs/guides/storage.md#writing-a-store-of-your-own)).
|
|
853
|
+
- After a tool call or `prepare` reads a document by range, and after `getOriginal` or `view_pages`
|
|
854
|
+
reads an original, the library calls `getMeta` once more. The read is missing unless the store
|
|
855
|
+
still describes the same document, of the same owner and scope. A kept original must also have
|
|
856
|
+
the document's size and, for documents of 0.9.0 and later, its SHA-256.
|
|
857
|
+
- `MemoryDocumentStore.getOriginal` returns a copy of the bytes (S7).
|
|
858
|
+
- `FileDocumentStore.sweep` reads 16 files at once (`sweepConcurrency`): 5,000 documents took about
|
|
859
|
+
1.1 s instead of 2.5 s on a local SSD. It counts only the documents whose metadata it removed
|
|
860
|
+
itself, and follows no link. In a folder shared with your files, it removes files of no document
|
|
861
|
+
only under the library's IDs, or temporary files.
|
|
862
|
+
- `FileDocumentStore` follows no link at a file name: such a document counts as missing. Windows
|
|
863
|
+
cannot refuse such a link, so there it is followed.
|
|
864
|
+
|
|
865
|
+
**Ingest**
|
|
866
|
+
|
|
867
|
+
- Every ingest hashes its upload with SHA-256, in 1 MB slices between other work: a few
|
|
868
|
+
milliseconds of CPU for each MB. 100 ingests of 2 MB logs took the same time in all as without it.
|
|
869
|
+
- `createIsolatedExtractors` reads a file ingested from a path in its child process, and the
|
|
870
|
+
server reads none of it, unless the store keeps a copy (`keepOriginals` with a store that has
|
|
871
|
+
`putOriginal`, and no `original`).
|
|
872
|
+
- `keepOriginals`, the acceptance of a scanned PDF and the offer of `view_pages` count a file kept
|
|
873
|
+
by reference when the library has `originals`.
|
|
874
|
+
|
|
875
|
+
**Upload handlers**
|
|
876
|
+
|
|
877
|
+
- `maxPendingUploadBytes` counts only the bodies held in memory: a body written to a file (the
|
|
878
|
+
spool, or the path of `prepareUpload`) takes no room of it.
|
|
879
|
+
- `uploadIdleTimeoutMs` (30 s) also bounds each disk call for a body written to a file: the check
|
|
880
|
+
of the folders of a ref, the opening, each write and the closing. A volume that stops answering
|
|
881
|
+
fails the upload with 500 `{ "error": "Upload failed (ETIMEDOUT)." }` and gives its room back. A
|
|
882
|
+
removal of such a file is waited for no longer than that, and then goes on alone. On a slow
|
|
883
|
+
network volume, raise `uploadIdleTimeoutMs`: a close can wait for the writes the system held back.
|
|
884
|
+
- An upload whose `request.body` holds an object with fields (`express.json()` in front) gets its
|
|
885
|
+
400 before the check of room.
|
|
886
|
+
- An ingest of your own that sends `ingest.finish` and then fails ends the event stream with
|
|
887
|
+
`ingest.error`.
|
|
888
|
+
- The `ingest.error` of the handlers names a store that failed (`"DocumentStoreError"`), documents
|
|
889
|
+
that are gone (`"DocumentsNotFoundError"`) and a scope error (`"DocumentScopeError"`, with its
|
|
890
|
+
code), and carries the `kind` of a model's error, so `errorInfoOf` reads it as the error.
|
|
891
|
+
- `sseMessageOf` sends `missing` in the result of `run.finish` and in the partial of `run.error`.
|
|
892
|
+
|
|
893
|
+
**Questions**
|
|
894
|
+
|
|
895
|
+
- Stored rounds that would make the first request larger than its room in tokens are shortened
|
|
896
|
+
before it is sent, for every model, Claude included. The request is what 0.8.2 sent after the
|
|
897
|
+
provider refused it, without the refused request.
|
|
898
|
+
- A function part kept in Gemini's own form is sized by the JSON of its call or response, a thought
|
|
899
|
+
signature included in bytes, not as media. A chat whose history is in `contents` may plan a file
|
|
900
|
+
as a card one question earlier.
|
|
901
|
+
- A result is not replaced by a stand-in as large as itself or larger.
|
|
902
|
+
- A tool call that finds a document gone during the question gives a `"document_gone"` notice.
|
|
903
|
+
- With `eventResults: true`, the full `DocumentMeta` in events also holds `scope`, `sha256` and
|
|
904
|
+
`original`, with its ref, as `AskResult.plan` does. Keep such events on your server.
|
|
905
|
+
|
|
906
|
+
**Errors**
|
|
907
|
+
|
|
908
|
+
- A model's `EventError` always has its `kind`. An error with a `status` of 0 or 400 to 599 and no
|
|
909
|
+
`kind` of its own gets the one `classifyModelError` gives its status, message and code. The
|
|
910
|
+
library's own errors with a status (`DocumentStoreError`, `DocumentsNotFoundError`, `IngestError`,
|
|
911
|
+
`DocumentScopeError`) get none.
|
|
912
|
+
- `withRetry` sends such an error again by that kind: a 429 of code `"insufficient_quota"` (a quota)
|
|
913
|
+
or a 429 "Request too large … tokens per min" (an overflow) is not sent again. Before, both were
|
|
914
|
+
sent again by their status. The library's own adapters do not change.
|
|
915
|
+
- The loop acts on that kind too. For such an error of kind `"context_overflow"` (an
|
|
916
|
+
`httpError(413)`, a 429 for the tokens a minute, a 400 of code `context_length_exceeded`), it makes
|
|
917
|
+
the request smaller, plans the documents again, or reads a part of a whole-file read as two
|
|
918
|
+
halves, with the numbers its message gives, as for a `ModelRequestError` of that kind. Before, the
|
|
919
|
+
question failed. The message of an error that is not an `Error` (an SDK's own class) gives its
|
|
920
|
+
kind too, in its event as in the loop and `errorInfoOf`.
|
|
921
|
+
- The `EventError` message of thrown plain data with a status, or of a status that is not a model's,
|
|
922
|
+
is "Something went wrong.".
|
|
923
|
+
- An extractor's own subclass of `IngestError` is named `"IngestError"` in its `EventError`, and a
|
|
924
|
+
store's subclass of `DocumentStoreError` `"DocumentStoreError"`, so `errorInfoOf` reads their
|
|
925
|
+
events.
|
|
926
|
+
|
|
927
|
+
**Release**
|
|
928
|
+
|
|
929
|
+
- Each release publishes the tarball CI checked, byte for byte. A job without npm's identity token
|
|
930
|
+
builds, tests and packs it, then checks it as npm installs it: with and without the optional
|
|
931
|
+
dependencies, `import` and `require()` of every subpath, an ingest in a child process of
|
|
932
|
+
`createIsolatedExtractors`, a consumer compiled under NodeNext, Bundler and Node10 with
|
|
933
|
+
`skipLibCheck: false`, publint and arethetypeswrong. A second job, the only one with the token,
|
|
934
|
+
stages that file with `npm stage publish` and provenance
|
|
935
|
+
([Publishing](docs/publishing.md#what-the-release-workflow-does)).
|
|
936
|
+
- The package is type-checked without the DOM library (`lib: ["ES2023"]`), as a server app compiles:
|
|
937
|
+
its declarations need only `@types/node`.
|
|
938
|
+
|
|
939
|
+
### Fixed
|
|
940
|
+
|
|
941
|
+
**Access and storage**
|
|
942
|
+
|
|
943
|
+
- **S3:** `files.tools()` given metadata read straight from the store (`await store.getMeta(id)`)
|
|
944
|
+
could read another user's document. With `access` it cannot, and `askWithFiles` always passes it.
|
|
945
|
+
- **S12:** a `LargeFiles` of your own whose `ingest` threw a database driver's error sent that
|
|
946
|
+
error's host to the browser, in a 422. An error that your store gave its own `status` reached the
|
|
947
|
+
client with its message too; it is now the `cause` of a `DocumentStoreError`.
|
|
948
|
+
- **A Node system error whose `code` is not a code** (a driver may put "db-prod.internal:27017"
|
|
949
|
+
there) gave that host in the upload answer, in its `ingest.error` and `run.error`, and in a tool
|
|
950
|
+
result sent to the model. A code is now told only when it reads as one: capitals, digits and `_`.
|
|
951
|
+
- **S11:** an upload's MIME type with CRLF, U+202E, tag characters or 8 KB of text was stored as
|
|
952
|
+
given, and reached the metadata, the summaries, `ingest.finish` and logs. The handler also
|
|
953
|
+
URI-decoded a `Content-Type` such as `text/plain%0D%0A…` into a line break.
|
|
954
|
+
- **S10:** `FileDocumentStore` files were readable by every user of the machine (`0664` under umask
|
|
955
|
+
`0002`).
|
|
956
|
+
- **S8:** `FileDocumentStore.getMeta`, `get` and `getOriginal` threw when an expired document could
|
|
957
|
+
not be removed, on every try, for a document that was gone. They return undefined, and `sweep`
|
|
958
|
+
tries again.
|
|
959
|
+
- **S9, LLF-027:** `files.delete` failed on Windows while another process held a file open for a
|
|
960
|
+
moment (`EBUSY`, `EPERM`), and threw when the metadata was gone but the text could not be removed.
|
|
961
|
+
- **An ingest whose caller left during the store write** still stored the document, never cleaned
|
|
962
|
+
under `ttlMs: Infinity`. Once the writes end, what they stored is now removed, and `ingest` throws
|
|
963
|
+
`signal.reason`. With the upload handlers, a client that leaves before its ingest ends leaves
|
|
964
|
+
nothing stored, and `onUploaded` is not called.
|
|
965
|
+
- **An owner of `null` from a store** read as missing in `getMeta`, and as open to all in the tools.
|
|
966
|
+
- **LLF-055:** the docs said renames are tried again for about three seconds; the pauses add up to
|
|
967
|
+
2.63 s.
|
|
968
|
+
- **LLF-022:** `examples/server.ts` listened on every interface, gave uploads no owner, so any
|
|
969
|
+
browser could read any upload by its ID, and kept chats by chat ID alone. It listens on 127.0.0.1
|
|
970
|
+
unless `HOST` is set, gives each browser a random `HttpOnly`, `SameSite=Strict` cookie as its
|
|
971
|
+
owner, runs with `requireOwner`, keeps chats by owner and chat, reads PDF and Office files with
|
|
972
|
+
`createIsolatedExtractors`, and says it is not for production as is. It also no longer crashes on
|
|
973
|
+
an unhandled rejection when the body of a chat request is cut off.
|
|
974
|
+
|
|
975
|
+
**Questions**
|
|
976
|
+
|
|
977
|
+
- A first request whose stored rounds were over the token limit was sent before anything was
|
|
978
|
+
shortened: one refused request per question on most models, and a failed question on Claude,
|
|
979
|
+
whose conversation may not be shortened.
|
|
980
|
+
- Function parts in a `contents` history were sized as media: about 15,000 tokens short in a test
|
|
981
|
+
of two calls, so planning left too little room.
|
|
982
|
+
- A stand-in could be larger than the result it replaced: 845 characters grew to 1,073, and 877 to
|
|
983
|
+
1,041.
|
|
984
|
+
- Six looks at pages at once ran together: each about four times slower, and 352 MB more than one
|
|
985
|
+
look (P10).
|
|
986
|
+
- A document that expired (`ttlMs`, 72 hours by default) failed the whole next question. With
|
|
987
|
+
`onMissingDocuments: "drop"`, the question is answered without it.
|
|
988
|
+
- The docs gave `tool_turns_left` as the only reason why the first request of a follow-up misses
|
|
989
|
+
the prompt cache. Stored rounds also drop the model's thought signatures and thinking blocks: the
|
|
990
|
+
docs say so now, and the change in code waits for 0.10.0.
|
|
991
|
+
|
|
992
|
+
**PDFs**
|
|
993
|
+
|
|
994
|
+
- **LLF-037:** in a right-to-left PDF table (Hebrew, Arabic), a Latin name or number that pdf.js
|
|
995
|
+
gives as several items was written backwards: a city cell of "New" and "York" read "York New", a
|
|
996
|
+
model "AB" + "-12" read "-12AB", and "8,300" + ",000" read ",0008,300". Each run of words in a
|
|
997
|
+
cell now reads in its own direction, and the runs follow the direction of the table. A Hebrew
|
|
998
|
+
phrase in several items inside a left-to-right table, also reversed before, reads right too. A
|
|
999
|
+
number before its unit or currency ("16 GB", "1,000 USD") reads as before. Documents ingested
|
|
1000
|
+
before keep their text: upload such a PDF again.
|
|
1001
|
+
|
|
1002
|
+
**Uploads**
|
|
1003
|
+
|
|
1004
|
+
- Without a `Content-Length`, an upload took `maxUploadBytes` of room until it was read, so two
|
|
1005
|
+
filled the default `maxPendingUploadBytes`, and a third got a 503 while they arrived. With
|
|
1006
|
+
`uploadSpool` they wait on disk, and three or more fit.
|
|
1007
|
+
- A client that left while `getOwner` ran, when a framework had already read the body
|
|
1008
|
+
(`express.raw()` in front), was not noticed: its upload was ingested and stored for nobody. It now
|
|
1009
|
+
stores nothing, as for a client that leaves later.
|
|
1010
|
+
|
|
1011
|
+
**Docs**
|
|
1012
|
+
|
|
1013
|
+
- [Deployment](docs/guides/deployment.md#memory-on-each-server) sized an ingest from figures
|
|
1014
|
+
recorded before 0.6.0 (five to seven times the log above the upload), and gave 34 ms as its
|
|
1015
|
+
longest stall, for a 99 MB log. Measured again on 0.9.0 with Node 22 on Linux, over a
|
|
1016
|
+
`FileDocumentStore`, on a busy laptop: three and a half to five and a half times the log (135 MB
|
|
1017
|
+
for 25 MB, 345 MB for 95 MB), and a longest stall of 56 to 64 ms for 25 MB and 0.23 to 0.36 s for
|
|
1018
|
+
95 MB. The old figures stay in [Measurements](docs/measurements.md#the-server), marked as history.
|
|
1019
|
+
|
|
39
1020
|
## 0.8.2 — 2026-11-23
|
|
40
1021
|
|
|
41
1022
|
Memory when many users upload at once. A review of how the library holds files found that every
|