llm-large-files 0.8.2 → 0.9.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 +535 -0
- package/README.md +9 -10
- package/dist/access.d.ts +86 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +131 -0
- package/dist/access.js.map +1 -0
- package/dist/ask.d.ts +45 -1
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +181 -20
- 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/encoding.js +5 -3
- package/dist/encoding.js.map +1 -1
- package/dist/error-info.d.ts +57 -0
- package/dist/error-info.d.ts.map +1 -0
- package/dist/error-info.js +217 -0
- package/dist/error-info.js.map +1 -0
- package/dist/errors.d.ts +72 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +102 -15
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +35 -9
- 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 +14 -3
- 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 +46 -35
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +19 -3
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +84 -12
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +18 -6
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +2 -0
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/index.d.ts +1 -1
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +70 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +868 -0
- package/dist/ingest.js.map +1 -0
- package/dist/library.d.ts +169 -34
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +324 -591
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.js +3 -3
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +43 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +63 -3
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +226 -14
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +423 -181
- 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 +18 -3
- 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 +102 -0
- package/dist/node/spool.d.ts.map +1 -0
- package/dist/node/spool.js +365 -0
- package/dist/node/spool.js.map +1 -0
- package/dist/node/sse.d.ts +4 -3
- package/dist/node/sse.d.ts.map +1 -1
- package/dist/node/sse.js +7 -6
- package/dist/node/sse.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/ranged.d.ts +15 -11
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +42 -11
- 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/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 +120 -31
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +582 -139
- 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 +25 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +135 -13
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +116 -13
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +17 -8
- package/docs/getting-started.md +18 -13
- package/docs/guides/anthropic.md +12 -8
- package/docs/guides/conversations.md +112 -47
- package/docs/guides/costs-and-limits.md +16 -7
- package/docs/guides/deployment.md +284 -83
- package/docs/guides/errors-and-reliability.md +161 -23
- package/docs/guides/own-adapter-and-loop.md +27 -10
- package/docs/guides/pdfs.md +123 -29
- package/docs/guides/storage.md +633 -145
- package/docs/guides/testing.md +78 -129
- package/docs/guides/vertex-and-gemini.md +10 -7
- package/docs/guides/web-app.md +312 -78
- package/docs/how-it-works.md +35 -8
- package/docs/measurements.md +43 -8
- package/docs/publishing.md +112 -36
- package/docs/reference/ask.md +154 -13
- package/docs/reference/errors-and-retries.md +166 -14
- package/docs/reference/events.md +53 -20
- package/docs/reference/gemini.md +70 -21
- package/docs/reference/library.md +706 -165
- package/docs/reference/node.md +624 -110
- package/docs/reference/testing.md +311 -0
- package/docs/reference/tools.md +15 -5
- package/docs/security.md +304 -67
- package/docs/troubleshooting.md +144 -65
- package/docs/upgrading-0.9.md +890 -0
- package/package.json +12 -3
- package/src/access.ts +144 -0
- package/src/ask.ts +230 -19
- package/src/cache.ts +20 -5
- package/src/encoding.ts +6 -4
- package/src/error-info.ts +255 -0
- package/src/errors.ts +129 -15
- package/src/events.ts +86 -21
- package/src/evidence.ts +14 -3
- package/src/extract.ts +50 -33
- package/src/gemini/adapter.ts +97 -11
- package/src/gemini/chat.ts +20 -6
- package/src/gemini/index.ts +1 -1
- package/src/index.ts +9 -6
- package/src/ingest.ts +927 -0
- package/src/library.ts +467 -601
- package/src/map-reduce.ts +3 -3
- package/src/model.ts +69 -5
- package/src/node/handlers.ts +630 -183
- package/src/node/index.ts +13 -2
- package/src/node/ingest-child.ts +23 -5
- package/src/node/isolated.ts +11 -4
- package/src/node/originals.ts +78 -0
- package/src/node/spool.ts +365 -0
- package/src/node/sse.ts +7 -6
- package/src/pdf-layout.ts +69 -11
- package/src/ranged.ts +34 -13
- package/src/retry.ts +6 -2
- package/src/scope.ts +63 -0
- package/src/source.ts +178 -0
- package/src/stores.ts +635 -140
- 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 +150 -14
- package/src/types.ts +106 -13
package/docs/troubleshooting.md
CHANGED
|
@@ -91,9 +91,9 @@ What each error and `kind` means, and what to tell your user, is in
|
|
|
91
91
|
### `require("llm-large-files")` throws `ERR_REQUIRE_ESM`
|
|
92
92
|
|
|
93
93
|
**Cause.** The package is an ES module only. CommonJS code can load it with `require()` only on the
|
|
94
|
-
Node versions that load ES modules that way by default:
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
Node versions that load ES modules that way by default: 22.12 and later in Node 22, and 23 and
|
|
95
|
+
later. Node 22.0 to 22.11 refuse. The library needs Node 22.12 or later in any case (20.19 until
|
|
96
|
+
0.9.0).
|
|
97
97
|
|
|
98
98
|
**Fix.** Upgrade Node, or load the package from CommonJS with `await import("llm-large-files")`
|
|
99
99
|
(and `import("llm-large-files/gemini")` and so on for the other entry points). In TypeScript this
|
|
@@ -123,10 +123,9 @@ as `devDependencies` and left out of the production install, or missing from the
|
|
|
123
123
|
bundle you deploy.
|
|
124
124
|
|
|
125
125
|
**Fix.** Install them as dependencies of the application that runs the upload route and the
|
|
126
|
-
questions: `npm install jszip unpdf @cantoo/pdf-lib` on Node 24 and later. On Node
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
[below](#a-pdf-upload-fails-the-unpdf-installed-cannot-read-pdf-files-or-would-stop-the-whole-server)).
|
|
126
|
+
questions: `npm install jszip unpdf @cantoo/pdf-lib` on Node 24 and later. On Node 22, name a
|
|
127
|
+
version of `unpdf` that runs there: `npm install jszip unpdf@1 @cantoo/pdf-lib` (see
|
|
128
|
+
[below](#a-pdf-upload-fails-the-unpdf-installed-would-stop-the-whole-server)).
|
|
130
129
|
Install `@cantoo/pdf-lib` before PDFs are uploaded: without it nothing fails at upload, but the
|
|
131
130
|
text of a PDF is written without the line that marks a page with a picture
|
|
132
131
|
(`[Picture on this page. This text cannot show it.]`), and a document keeps the text it was
|
|
@@ -134,41 +133,35 @@ ingested with.
|
|
|
134
133
|
|
|
135
134
|
See [PDFs and other formats](./guides/pdfs.md).
|
|
136
135
|
|
|
137
|
-
### A PDF upload fails: "The unpdf installed
|
|
136
|
+
### A PDF upload fails: "The unpdf installed would stop the whole server"
|
|
138
137
|
|
|
139
|
-
`files.ingest` throws
|
|
138
|
+
`files.ingest` throws this, and the upload handler answers `422` with it:
|
|
140
139
|
|
|
141
|
-
|
|
142
|
-
- `The unpdf installed would stop the whole server at the first PDF file on Node 20, so PDF files are not read. Install unpdf 1.7.0 (npm install unpdf@1.7.0), or run Node 24 or later.`
|
|
143
|
-
- `The unpdf installed cannot read PDF files on Node 20 (Serverless PDF.js bundle could not be resolved: ReferenceError: Iterator is not defined). Install unpdf 1.7.0 (npm install unpdf@1.7.0), or run Node 22 or later.`
|
|
144
|
-
The text in brackets is unpdf's own message, and differs between its versions.
|
|
140
|
+
`The unpdf installed would stop the whole server at the first PDF file on Node 22, so PDF files are not read. Install unpdf 1.6.1 or later, or run Node 24 or later.`
|
|
145
141
|
|
|
146
142
|
The number is the major version of the Node that runs the server. DOCX, PPTX and text files are
|
|
147
143
|
read as before.
|
|
148
144
|
|
|
149
|
-
**Cause.**
|
|
150
|
-
0.
|
|
151
|
-
|
|
152
|
-
- unpdf 1.5.0 to 1.6.0 load a pdf.js that calls `Promise.try`, which Node 20 and 22 do not have. In
|
|
153
|
-
0.5.0 the first PDF stopped the whole process, with a `TypeError` that nothing could catch.
|
|
154
|
-
- unpdf 1.9 and later, 2.x included, load a pdf.js that needs Node 22. On Node 20, every PDF failed
|
|
155
|
-
with unpdf's message alone.
|
|
145
|
+
**Cause.** unpdf 1.5.0 to 1.6.0 load a pdf.js that calls `Promise.try`, which Node 22 does not
|
|
146
|
+
have. In 0.5.0 the first PDF stopped the whole process, with a `TypeError` that nothing could
|
|
147
|
+
catch. Since 0.6.0 the library checks it before it reads a PDF.
|
|
156
148
|
|
|
157
|
-
unpdf 2 asks for Node 24, and on Node 24 a plain `npm install unpdf` installs it.
|
|
158
|
-
|
|
149
|
+
unpdf 2 asks for Node 24, and on Node 24 a plain `npm install unpdf` installs it. A pdf.js that
|
|
150
|
+
cannot be loaded for another reason fails with unpdf's own message. (Until 0.9.0, on Node 20, that
|
|
151
|
+
failure came as `The unpdf installed cannot read PDF files on Node 20 (…)`. Node 20 is no longer
|
|
152
|
+
supported.)
|
|
159
153
|
|
|
160
|
-
**Fix.** Install the `unpdf` that runs on your Node, or move to
|
|
154
|
+
**Fix.** Install the `unpdf` that runs on your Node, or move to Node 24:
|
|
161
155
|
|
|
162
156
|
| Node | `unpdf` to install |
|
|
163
157
|
|---|---|
|
|
164
|
-
| 20 | 1.4.0, or 1.6.1 to 1.8.1: `npm install unpdf@1.7.0`. 1.7.0 is the last that does not ask for Node 22. |
|
|
165
158
|
| 22 | 1.4.0, or 1.6.1 or a later 1.x: `npm install unpdf@1`. |
|
|
166
159
|
| 24 and later | Any version from 1.4.0, 2.x included: `npm install unpdf`. |
|
|
167
160
|
|
|
168
161
|
If the server loads pdf.js when it starts, as [Deployment](./guides/deployment.md#uploads-and-ingest)
|
|
169
|
-
shows, an `unpdf` that cannot load pdf.js on that Node
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
shows, an `unpdf` that cannot load pdf.js on that Node makes the start fail instead. With unpdf
|
|
163
|
+
1.5.0 to 1.6.0 on Node 22, pdf.js loads and the server starts: PDFs are then refused at upload,
|
|
164
|
+
with the message above.
|
|
172
165
|
|
|
173
166
|
See [PDFs and other formats](./guides/pdfs.md#formats).
|
|
174
167
|
|
|
@@ -265,16 +258,25 @@ New in 0.8.2. `createDocumentHandlers` answers `503` with `Retry-After: 5`, befo
|
|
|
265
258
|
**Cause.** The handlers already hold uploads, and this one would bring them past
|
|
266
259
|
`maxPendingUploadBytes` (twice `maxUploadBytes`, 200 MB by default). An upload is held from the
|
|
267
260
|
reading of its body to the end of its ingest, and its room is taken from its `Content-Length`
|
|
268
|
-
before its body arrives
|
|
269
|
-
|
|
261
|
+
before its body arrives (`maxUploadBytes` for a body sent without a `Content-Length`, until it is
|
|
262
|
+
read: two such uploads fill the default room). Many users sending files at once, or a few clients
|
|
263
|
+
that send their headers and then their bodies slowly, fill it. With `uploadSpool` (new in 0.9.0),
|
|
264
|
+
the same answer comes when the spool's files reach `maxSpooledUploadBytes`.
|
|
270
265
|
|
|
271
266
|
**Fix.** Send the file again after `Retry-After` seconds, as the browser code in
|
|
272
267
|
[Web app](./guides/web-app.md#upload-from-the-browser) does. To take more at once, raise
|
|
273
|
-
`maxPendingUploadBytes` and size the server for it (each upload under way takes about
|
|
274
|
-
times its size while it is ingested
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
`maxPendingUploadBytes` and size the server for it (each upload under way takes about three and a
|
|
269
|
+
half to five and a half times its size while it is ingested over a `FileDocumentStore`,
|
|
270
|
+
[measurements](./measurements.md#the-server); ingests take turns, `maxConcurrentIngests`). Put a
|
|
271
|
+
proxy that reads whole bodies before passing them on in front, so that slow clients hold no room.
|
|
272
|
+
Or take the bodies off the heap: `uploadSpool` writes the larger ones, and those without a
|
|
273
|
+
`Content-Length`, to temporary files, and `maxPendingUploadBytes` then counts only the bodies kept
|
|
274
|
+
in memory ([Deployment](./guides/deployment.md#uploads-and-ingest)).
|
|
275
|
+
"The server is reading other files right now." is another `503`: the readers of
|
|
276
|
+
`createIsolatedExtractors` are busy ([Node reference](./reference/node.md#uploadrequest-response)).
|
|
277
|
+
So is "The server has no room for this file right now. Try again later." (new in 0.9.0, with
|
|
278
|
+
`Retry-After: 30`): the disk the body was written to, the spool's or the folder of
|
|
279
|
+
`prepareUpload`, is full.
|
|
278
280
|
|
|
279
281
|
### `408`: "The upload stopped arriving: nothing came for 30 s. Send it again."
|
|
280
282
|
|
|
@@ -283,6 +285,22 @@ the client's connection stalled, or a proxy held the body. The connection is clo
|
|
|
283
285
|
the file again. For users on slow or unsteady links, raise `uploadIdleTimeoutMs` of
|
|
284
286
|
`createDocumentHandlers`.
|
|
285
287
|
|
|
288
|
+
### `500`: "Upload failed (ETIMEDOUT)." or "Upload failed (ELOOP)."
|
|
289
|
+
|
|
290
|
+
New in 0.9.0, for a body written to a file (the `path` of `prepareUpload`, or `uploadSpool`).
|
|
291
|
+
|
|
292
|
+
- **"ETIMEDOUT".** A call to the disk (checking the folders of a path with a ref, opening the file,
|
|
293
|
+
a write, closing it) did not end within `uploadIdleTimeoutMs` (30 s): the volume stopped
|
|
294
|
+
answering, such as a network volume whose server is gone. The upload's room is given back, and
|
|
295
|
+
the file is removed once the volume answers. **Fix.** Check the volume. A slow network volume can
|
|
296
|
+
take long to close a file it held writes for: raise `uploadIdleTimeoutMs`.
|
|
297
|
+
- **"ELOOP".** `prepareUpload` gave a path that ends with the ref of its `original`, and a folder
|
|
298
|
+
between that root and the file is a link. `fileOriginals` would never read the file back through
|
|
299
|
+
it, so nothing is written. **Fix.** Replace the link with the folder itself, or mount the other
|
|
300
|
+
disk there. The root itself may be a link.
|
|
301
|
+
|
|
302
|
+
See [saving the body](./reference/node.md#saving-the-body-prepareupload).
|
|
303
|
+
|
|
286
304
|
### `400`: "Name the file with an X-File-Name header or a ?name= query parameter."
|
|
287
305
|
|
|
288
306
|
**Cause.** The upload request names no file. The name decides the format, and is shown to the
|
|
@@ -324,7 +342,10 @@ others. 0.5.0 accepted it.
|
|
|
324
342
|
an array.
|
|
325
343
|
|
|
326
344
|
A numeric owner is accepted, as before. `get`, `remove` and questions that pass the owner `""` work
|
|
327
|
-
as before, so documents that 0.5.0 stored with that owner stay readable until they expire.
|
|
345
|
+
as before, so documents that 0.5.0 stored with that owner stay readable until they expire. Under
|
|
346
|
+
`requireOwner` the library refuses that owner on every call: `get` and `remove` then answer
|
|
347
|
+
"The file could not be looked up (empty owner)." and "The file could not be deleted (empty owner).",
|
|
348
|
+
also `500` (new in 0.9.0).
|
|
328
349
|
|
|
329
350
|
**Fix.** Return the user's ID, not the user object. Where every upload needs a signed-in user,
|
|
330
351
|
throw an error with `status: 401` for a request without one. Only where anonymous uploads are
|
|
@@ -350,7 +371,7 @@ handler answers `422` with its message. The common ones:
|
|
|
350
371
|
| `report.txt is empty.` | A file of 0 bytes. |
|
|
351
372
|
| `report.docx did not contain any text.` | Nothing left once read: a DOCX of pictures, a file of blank lines. |
|
|
352
373
|
| `This PDF has no text layer (it may be scanned). It needs OCR before it can be searched.` | A scan, while PDFs are not kept. |
|
|
353
|
-
| `The unpdf installed would stop the whole server at the first PDF file on Node 22, …`
|
|
374
|
+
| `The unpdf installed would stop the whole server at the first PDF file on Node 22, …` | Any PDF, while the `unpdf` installed cannot run on this Node. See [above](#a-pdf-upload-fails-the-unpdf-installed-would-stop-the-whole-server). |
|
|
354
375
|
| `This PDF has 6,200 pages, more than the 5,000 read from one file. Split it, and attach the part you need.` | A PDF of more than `maxPdfPages` pages (5,000 by default). Refused before any page is read. |
|
|
355
376
|
| `This PDF holds more than 100 MB of text, more than is kept from one file. Split it, and attach the part you need.` | A PDF whose text passes `maxTextBytes` (100 MB by default, or `maxUploadBytes` when that is larger). |
|
|
356
377
|
| `notes.txt holds more than 100 MB of text, more than is kept from one file. Split it, and attach the part you need.` | The same, from the text extractor or one of your own: a UTF-16 file can grow by half in UTF-8. |
|
|
@@ -390,9 +411,12 @@ below 2 minutes ("45 s"), in minutes from there ("2 min").
|
|
|
390
411
|
**Cause.** One `ingest` (extracting the text, its line index and its profile) took longer than
|
|
391
412
|
`ingestTimeoutMs`, 120,000 ms by default. Most often: a PDF with many pages that are slow to read;
|
|
392
413
|
an extractor of your own that waits on a slow service, such as OCR of a long scan; or a server
|
|
393
|
-
busy with other ingests, which each take their share of the same process.
|
|
414
|
+
busy with other ingests, which each take their share of the same process. A file read from a path
|
|
415
|
+
(`source: { path }`, an upload of `prepareUpload` or of the spool) gets the same message when its
|
|
416
|
+
volume stops answering while the file is read. Nothing is stored.
|
|
394
417
|
|
|
395
|
-
**Fix.** For a file
|
|
418
|
+
**Fix.** For a file read from a path, check its volume first: the file may be fine. For a file
|
|
419
|
+
that is slow to read, the user splits it, or saves it as plain text. For OCR or
|
|
396
420
|
another slow extractor of your own, raise `ingestTimeoutMs` (0 sets no limit), run the ingest in a
|
|
397
421
|
background job ([Web app](./guides/web-app.md#long-ingests-in-the-background)), and pass
|
|
398
422
|
`input.signal` on to the service it calls, so that the request stops at the limit too. Bound the
|
|
@@ -523,7 +547,10 @@ handler's `get` answers `404` with `This file is no longer available.` for the s
|
|
|
523
547
|
**Fix.** Pass the same `owner` to the question as to the upload: the value `getOwner` returned for
|
|
524
548
|
the same user. Use a store that every server shares and that outlives a restart. Show the user which
|
|
525
549
|
files to attach again: `error.ids` names the IDs, and your chat knows their file names. A
|
|
526
|
-
document's `expiresAt` says when it goes.
|
|
550
|
+
document's `expiresAt` says when it goes. Since 0.9.0 a question can go on without them:
|
|
551
|
+
`onMissingDocuments: "drop"` answers from the other files and lists the missing ones in
|
|
552
|
+
`result.missing`, and a function can ingest them again from uploads you kept
|
|
553
|
+
([missing documents](./reference/ask.md#missing-documents)).
|
|
527
554
|
|
|
528
555
|
See [Storage](./guides/storage.md) and
|
|
529
556
|
[`DocumentsNotFoundError`](./reference/ask.md#documentsnotfounderror).
|
|
@@ -658,7 +685,8 @@ only what the answering model wrote.
|
|
|
658
685
|
**Cause.** The model gets `view_pages` for a PDF only when all of these hold:
|
|
659
686
|
|
|
660
687
|
- `keepOriginals` lists `"pdf"`, and the store has `putOriginal` and `getOriginal`
|
|
661
|
-
(`FileDocumentStore` and `MemoryDocumentStore` have both)
|
|
688
|
+
(`FileDocumentStore` and `MemoryDocumentStore` have both), or (0.9.0) the document was ingested
|
|
689
|
+
with `original: { ref }` and the library has `originals`;
|
|
662
690
|
- the document was ingested after that: one ingested before has no file kept
|
|
663
691
|
(`meta.originalKept` is not `true`);
|
|
664
692
|
- every model of the question can be sent a file: not `openAiCompatible()` without `pdfInput`, not
|
|
@@ -677,6 +705,19 @@ look fails: install it ([above](#a-pdf-docx-or-pptx-upload-fails-needs-the-optio
|
|
|
677
705
|
|
|
678
706
|
See [PDFs and other formats](./guides/pdfs.md).
|
|
679
707
|
|
|
708
|
+
### `view_pages` says a file "changed on the server since it was read"
|
|
709
|
+
|
|
710
|
+
The model reads `report.pdf changed on the server since it was read. Attach it again to look at its
|
|
711
|
+
pages.`, and `files.getOriginal` gives `undefined`.
|
|
712
|
+
|
|
713
|
+
**Cause.** The document was ingested with `original: { ref }` (0.9.0), and the file at that ref is
|
|
714
|
+
no longer the one that was ingested: its size or SHA-256 differs from `meta.original`. It was saved
|
|
715
|
+
again under the same name, cut short by a copy that failed, or edited. Its pages would not match the
|
|
716
|
+
text the model has, so none are shown.
|
|
717
|
+
|
|
718
|
+
**Fix.** Keep each upload under a name of its own, and never write over a file a document names.
|
|
719
|
+
To use the new file, ingest it again (`ifExists: "replace"` under the same `id`).
|
|
720
|
+
|
|
680
721
|
### Whole-file reads never happen, or are refused
|
|
681
722
|
|
|
682
723
|
`steps` holds no `Read all of …` line, or holds one that failed:
|
|
@@ -1052,9 +1093,11 @@ Look at `result.usage`: `inputTokens`, `cachedInputTokens` (read from the provid
|
|
|
1052
1093
|
- **`documentPlacement: "last"`.** The documents then move to the latest turn, and a prompt cache
|
|
1053
1094
|
cannot reuse them: keep the default, `"first"`.
|
|
1054
1095
|
- **The first request of a follow-up question.** The tool rounds of an earlier question are sent
|
|
1055
|
-
again without their `tool_turns_left` (since 0.6.0),
|
|
1056
|
-
|
|
1057
|
-
|
|
1096
|
+
again without their `tool_turns_left` (since 0.6.0), and as their calls alone: a stored round
|
|
1097
|
+
keeps no thought signatures or thinking blocks, which the requests of its own question sent
|
|
1098
|
+
back. Either one makes that request read the cache only up to the tool rounds of the question
|
|
1099
|
+
before it: the documents, the cards and the turns before those rounds still hit. The later
|
|
1100
|
+
requests of the question hit as before.
|
|
1058
1101
|
- **The first request after the upgrade to 0.6.0.** The tool guide, the descriptions of
|
|
1059
1102
|
`search_document` and `analyze_whole_document`, and the frame of every file sent whole changed,
|
|
1060
1103
|
so the first request of each conversation reads from the cache at most what comes before the
|
|
@@ -1171,12 +1214,14 @@ See [Security](./security.md) and [Tools](./reference/tools.md).
|
|
|
1171
1214
|
### `DocumentStoreError`: "The document store could not be read (EIO). Try again."
|
|
1172
1215
|
|
|
1173
1216
|
Thrown by a question, `files.getMeta`, `files.getOriginal`, and by `files.delete` when the look-up
|
|
1174
|
-
fails
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
`The
|
|
1217
|
+
fails. When the error behind it has no `code`, the message has none. Inside a question's tool call,
|
|
1218
|
+
the model gets it as the call's error, and `steps` shows
|
|
1219
|
+
`… — failed: The document store could not be read (EIO). Try again.`. The upload handler's `get`
|
|
1220
|
+
and `remove` answer `503` with that message (since 0.9.0; they answered `500`). Since 0.9.0 the
|
|
1221
|
+
errors of writes are `DocumentStoreError`s too, with their own messages: "The document could not be
|
|
1222
|
+
stored (EIO). Try again." from `files.ingest`, "The document could not be deleted (EIO). Try
|
|
1223
|
+
again." from the store's own `delete`, "The document store could not be cleaned up (EIO). Try
|
|
1224
|
+
again." from `files.sweep`.
|
|
1180
1225
|
|
|
1181
1226
|
**Cause.** The store failed while it was read: a network volume that did not answer, too many open
|
|
1182
1227
|
files, a database that is down. The documents are not gone.
|
|
@@ -1187,6 +1232,31 @@ them to upload again. Log `error.cause`, the store's own error, and `error.code`
|
|
|
1187
1232
|
See [`DocumentStoreError`](./reference/library.md#documentstoreerror) and
|
|
1188
1233
|
[Storage](./guides/storage.md).
|
|
1189
1234
|
|
|
1235
|
+
### "The document store could not be read (EACCES)" after an upgrade to 0.9.0
|
|
1236
|
+
|
|
1237
|
+
Uploads work on the server that took them, and every other server, or a backup or sweep job,
|
|
1238
|
+
answers `EACCES` for the new documents.
|
|
1239
|
+
|
|
1240
|
+
**Cause.** Since 0.9.0, `FileDocumentStore` writes files `0600` and folders `0700`: only the user
|
|
1241
|
+
that wrote them can read them. The servers or the job run as different users.
|
|
1242
|
+
|
|
1243
|
+
**Fix.** Run them all as one user. Or, for users of one group (a Kubernetes `fsGroup`), give every
|
|
1244
|
+
store `fileMode: 0o640` and `directoryMode: 0o750`, and change the files written since the upgrade
|
|
1245
|
+
once with `chmod`. See [Deployment](./guides/deployment.md#a-shared-store).
|
|
1246
|
+
|
|
1247
|
+
### `DocumentScopeError`: "The scope no longer exists."
|
|
1248
|
+
|
|
1249
|
+
An upload into a chat fails with a `DocumentScopeError` of code `"scope_missing"`. The upload
|
|
1250
|
+
handler answers it `404` `{ "error": "This chat no longer exists." }`.
|
|
1251
|
+
|
|
1252
|
+
**Cause.** The store is a `FileDocumentStore` with `scopes`, and the folder of the chat is gone:
|
|
1253
|
+
your application removed it when the chat was deleted, or never made it. The store makes its own
|
|
1254
|
+
folder in a chat's folder, never the chat's folder itself, unless `createScopeFolders` is on.
|
|
1255
|
+
|
|
1256
|
+
**Fix.** For a deleted chat, nothing: tell the user the chat no longer exists. For a new chat, make
|
|
1257
|
+
its folder (`mkdir` with `recursive: true`) when the chat starts, or set `createScopeFolders: true`.
|
|
1258
|
+
See [Storage](./guides/storage.md#files-in-a-folder-per-user-or-per-chat).
|
|
1259
|
+
|
|
1190
1260
|
### Documents are found on one server and missing on another
|
|
1191
1261
|
|
|
1192
1262
|
`DocumentsNotFoundError` for documents that were just uploaded, on some requests and not others, or
|
|
@@ -1214,29 +1284,38 @@ try again.
|
|
|
1214
1284
|
|
|
1215
1285
|
See [Storage](./guides/storage.md) and [`DocumentStore`](./reference/library.md#documentstore).
|
|
1216
1286
|
|
|
1217
|
-
### `
|
|
1287
|
+
### `503`: "The document could not be stored. Try again.", or `500` "Upload failed."
|
|
1288
|
+
|
|
1289
|
+
**Cause.** A store write that fails is a `DocumentStoreError` since 0.9.0 (it was thrown as it
|
|
1290
|
+
came, and answered `500` "Upload failed."). The upload handler answers it `503` with its message,
|
|
1291
|
+
"The document could not be stored (ENOSPC). Try again." when the store's error has a code, and
|
|
1292
|
+
`Retry-After: 5`. Your database's own message is its `cause`, and may name its host, so it is not
|
|
1293
|
+
sent, and the handlers log nothing.
|
|
1294
|
+
|
|
1295
|
+
An `ingest` of your own that throws a new error in its place, without a status, gets `500`
|
|
1296
|
+
"Upload failed." since 0.9.0. Before, it got `422` with that error's message, which could name your
|
|
1297
|
+
database's host (S12). Every case is in the [node reference](./reference/node.md#how-errors-are-answered).
|
|
1298
|
+
|
|
1299
|
+
**Fix.** Log `error.cause` where you catch it, and fix the storage. An `ingest` of your own must
|
|
1300
|
+
pass the `DocumentStoreError` on as it is, or rebuild it, as `ingestInProcess` in
|
|
1301
|
+
[Deployment](./guides/deployment.md#uploads-and-ingest) does. A route of your own answers it with
|
|
1302
|
+
`uploadAnswerOf` ([Web app](./guides/web-app.md#filesingest-and-its-errors)).
|
|
1218
1303
|
|
|
1219
|
-
|
|
1220
|
-
handler answers it `500` with `{ "error": "Upload failed." }` when it has no `status` (or
|
|
1221
|
-
`statusCode`) from 400 to 599 and is not a Node system error with `code` and `syscall`. Its message
|
|
1222
|
-
is your database's own and may name its host, so it is not sent, and the handlers log nothing.
|
|
1304
|
+
### `500` "Upload failed." for a file your own `ingest` refused
|
|
1223
1305
|
|
|
1224
|
-
|
|
1225
|
-
`ingest`
|
|
1226
|
-
|
|
1227
|
-
[Web app](./guides/web-app.md#filesingest-and-its-errors). Every case is in the
|
|
1228
|
-
[node reference](./reference/node.md#uploadrequest-response).
|
|
1306
|
+
**Cause.** Since 0.9.0, the upload handler answers `422` only an `IngestError`. A `LargeFiles` of
|
|
1307
|
+
your own whose `ingest` throws a plain `Error` for a file it refuses gets `500` "Upload failed.",
|
|
1308
|
+
without its message, which could name a host.
|
|
1229
1309
|
|
|
1230
|
-
**Fix.**
|
|
1231
|
-
|
|
1232
|
-
system error's `code` and `syscall`, onto the error it throws, as `ingestInProcess` in
|
|
1233
|
-
[Deployment](./guides/deployment.md#uploads-and-ingest) does.
|
|
1310
|
+
**Fix.** Throw `new IngestError(code, message)` (exported from `llm-large-files`), with a message
|
|
1311
|
+
written for the user. Its code says why: `"unreadable"`, `"too_large"`, `"no_text"`…
|
|
1234
1312
|
|
|
1235
1313
|
See [Storage](./guides/storage.md) and [`llm-large-files/node` reference](./reference/node.md).
|
|
1236
1314
|
|
|
1237
|
-
### `
|
|
1315
|
+
### `503`: "The document could not be stored (ENOSPC). Try again."
|
|
1238
1316
|
|
|
1239
|
-
**Cause.** The disk of a `FileDocumentStore` is full.
|
|
1317
|
+
**Cause.** The disk of a `FileDocumentStore` is full. (Before 0.9.0 the answer was `500` "Upload
|
|
1318
|
+
failed (ENOSPC).".) Expired documents are removed when they are
|
|
1240
1319
|
next looked up, or by `files.sweep()`: one that nobody asks for again stays on disk until a sweep.
|
|
1241
1320
|
Kept originals (`keepOriginals`) take space up to the upload limit each, until they expire.
|
|
1242
1321
|
|