llm-large-files 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +500 -0
- package/README.md +13 -7
- package/dist/access.d.ts +45 -3
- package/dist/access.d.ts.map +1 -1
- package/dist/access.js +106 -3
- package/dist/access.js.map +1 -1
- 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 +115 -14
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +572 -103
- package/dist/ask.js.map +1 -1
- package/dist/citations.d.ts +36 -0
- package/dist/citations.d.ts.map +1 -0
- package/dist/citations.js +298 -0
- package/dist/citations.js.map +1 -0
- package/dist/error-info.d.ts +13 -0
- package/dist/error-info.d.ts.map +1 -1
- package/dist/error-info.js +37 -1
- package/dist/error-info.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -1
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +27 -8
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +21 -2
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +6 -1
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +35 -4
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +68 -29
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +28 -55
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +20 -27
- 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 +3 -3
- 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 +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +9 -1
- package/dist/ingest.d.ts.map +1 -1
- package/dist/ingest.js +50 -25
- package/dist/ingest.js.map +1 -1
- package/dist/library.d.ts +129 -2
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +224 -149
- 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 +804 -58
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +36 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -1
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +29 -8
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +148 -126
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/ingest-child.js +2 -2
- package/dist/node/ingest-child.js.map +1 -1
- package/dist/node/spool.d.ts +9 -5
- package/dist/node/spool.d.ts.map +1 -1
- package/dist/node/spool.js +28 -15
- package/dist/node/spool.js.map +1 -1
- package/dist/node/sse.d.ts +6 -5
- package/dist/node/sse.d.ts.map +1 -1
- package/dist/node/sse.js +8 -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-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 +2 -1
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +16 -3
- package/dist/ranged.js.map +1 -1
- 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/stores.d.ts +6 -0
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +82 -11
- package/dist/stores.js.map +1 -1
- package/dist/tools.d.ts +22 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +323 -76
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +49 -1
- 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 +4 -0
- package/docs/guides/anthropic.md +5 -2
- package/docs/guides/conversations.md +1 -1
- package/docs/guides/costs-and-limits.md +133 -36
- package/docs/guides/deployment.md +106 -13
- package/docs/guides/errors-and-reliability.md +158 -45
- package/docs/guides/explorer-model.md +4 -1
- package/docs/guides/openai-compatible.md +47 -7
- package/docs/guides/own-adapter-and-loop.md +33 -6
- package/docs/guides/pdfs.md +96 -7
- package/docs/guides/storage.md +46 -3
- package/docs/guides/testing.md +71 -0
- package/docs/guides/vertex-and-gemini.md +159 -50
- package/docs/guides/web-app.md +10 -6
- package/docs/how-it-works.md +120 -22
- package/docs/measurements.md +172 -5
- package/docs/publishing.md +76 -4
- package/docs/reference/anthropic.md +12 -7
- package/docs/reference/ask.md +264 -35
- package/docs/reference/errors-and-retries.md +30 -2
- package/docs/reference/events.md +27 -10
- package/docs/reference/gemini.md +189 -68
- package/docs/reference/library.md +190 -23
- package/docs/reference/node.md +51 -17
- package/docs/reference/openai.md +21 -10
- package/docs/reference/tools.md +273 -26
- package/docs/security.md +101 -12
- package/docs/troubleshooting.md +14 -12
- package/docs/upgrading-0.10.md +484 -0
- package/package.json +5 -1
- package/src/access.ts +127 -4
- 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 +646 -106
- package/src/citations.ts +301 -0
- package/src/error-info.ts +36 -1
- package/src/errors.ts +3 -1
- package/src/events.ts +31 -7
- package/src/evidence.ts +21 -2
- package/src/extract.ts +6 -1
- package/src/gemini/adapter.ts +99 -32
- package/src/gemini/chat.ts +53 -82
- 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 +3 -3
- package/src/http.ts +65 -4
- package/src/index.ts +7 -5
- package/src/ingest.ts +58 -27
- package/src/library.ts +336 -142
- package/src/map-reduce.ts +855 -67
- package/src/model.ts +44 -4
- package/src/node/handlers.ts +159 -118
- package/src/node/index.ts +1 -0
- package/src/node/ingest-child.ts +2 -2
- package/src/node/spool.ts +28 -14
- package/src/node/sse.ts +8 -7
- package/src/openai/adapter.ts +56 -13
- package/src/output-limit.ts +5 -2
- package/src/pdf-outline.ts +400 -0
- package/src/plan.ts +287 -36
- package/src/prepare.ts +253 -0
- package/src/ranged.ts +16 -3
- package/src/search.ts +69 -13
- package/src/stores.ts +76 -11
- package/src/tools.ts +327 -75
- package/src/types.ts +45 -1
- package/src/whole-cost.ts +64 -0
package/docs/reference/tools.md
CHANGED
|
@@ -6,7 +6,7 @@ loop of your own, show `steps` to users, keep `toolTurns`, or want to know exact
|
|
|
6
6
|
was told and what it read.
|
|
7
7
|
|
|
8
8
|
```ts
|
|
9
|
-
import { MAX_VIEW_PAGES, MAX_WHOLE_DOCUMENT_READS, REGEX_BUDGET_MS, TOOL_NAMES, toolResultSummary } from "llm-large-files";
|
|
9
|
+
import { declarationsFor, MAX_VIEW_PAGES, MAX_WHOLE_DOCUMENT_READS, REGEX_BUDGET_MS, TOOL_NAMES, toolResultSummary } from "llm-large-files";
|
|
10
10
|
import type { JsonSchema, ToolCallLimits, ToolDeclaration, ToolFile, ToolFileLimits, ToolOutput, ToolResult, ToolSet } from "llm-large-files";
|
|
11
11
|
```
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ Contents:
|
|
|
19
19
|
[`analyze_whole_document`](#analyze_whole_document), [`view_pages`](#view_pages)
|
|
20
20
|
- [The tool guide](#the-tool-guide)
|
|
21
21
|
- [What `askWithFiles` adds to results](#what-askwithfiles-adds-to-results)
|
|
22
|
-
- Exports: [`TOOL_NAMES`](#tool_names), [`MAX_VIEW_PAGES`](#max_view_pages),
|
|
22
|
+
- Exports: [`TOOL_NAMES`](#tool_names), [declarationsFor(names)](#declarationsfornames), [`MAX_VIEW_PAGES`](#max_view_pages),
|
|
23
23
|
[`MAX_WHOLE_DOCUMENT_READS`](#max_whole_document_reads), [`REGEX_BUDGET_MS`](#regex_budget_ms),
|
|
24
24
|
[toolResultSummary(label, result)](#toolresultsummarylabel-result), [`ToolSet`](#toolset),
|
|
25
25
|
[`ToolCallLimits`](#toolcalllimits), [`ToolFileLimits`](#toolfilelimits),
|
|
@@ -90,6 +90,24 @@ Through `files.tools(documents, options)` (a loop of your own, see [`ToolSet`](#
|
|
|
90
90
|
- `view_pages` is declared when `options.viewPages` names at least one PDF whose `originalKept` is
|
|
91
91
|
true and the store has `getOriginal`: `true` means every PDF in `documents`, and a list (such as
|
|
92
92
|
`prepared.viewable`) means exactly those.
|
|
93
|
+
- `options.declare` (new in 0.10.0) declares exactly the tools it names, in place of the rules
|
|
94
|
+
above, always in the order search, read, overview, aggregate, analyze, view, whatever the order
|
|
95
|
+
of the list: what [declarationsFor(names)](#declarationsfornames) gives. `askWithFiles` uses it
|
|
96
|
+
when tables are sent whole (`inlineTables`), to declare exactly the tools of the question: for
|
|
97
|
+
those tables search, read and aggregate, not overview or a whole-file read. A list of your own may
|
|
98
|
+
name a tool that has nothing to work on: each call of it then answers with the reason,
|
|
99
|
+
`No attached file has a table: aggregate_table needs one.` for `aggregate_table` when no document
|
|
100
|
+
may hold a table, `No attached file has pages to look at: view_pages needs a PDF whose original
|
|
101
|
+
file is kept. Answer from the text.` for `view_pages` with no PDF to look at, and
|
|
102
|
+
`Whole-document analysis is not enabled.` for `analyze_whole_document` without `generate`. It
|
|
103
|
+
answers those tools and no other: a call of a tool it does not name gets `Unknown tool “NAME”.`,
|
|
104
|
+
and `has(name)` is false, where without `declare` `aggregate_table` and (with `generate`)
|
|
105
|
+
`analyze_whole_document` are answered when not declared. With today's set, `declare` gives
|
|
106
|
+
today's bytes.
|
|
107
|
+
- `options.inline` (new in 0.10.0) lists the IDs of documents whose text is in the prompt. Pass
|
|
108
|
+
them among `documents` too, so that the text tools can count and search them;
|
|
109
|
+
`analyze_whole_document` refuses them (see [its errors](#analyze_whole_document)), and
|
|
110
|
+
`wholeReadsLeft` is 0 for them.
|
|
93
111
|
|
|
94
112
|
## Rules for every tool
|
|
95
113
|
|
|
@@ -126,6 +144,25 @@ storage (EIO). Try the call again.", and a store that could not be read gives th
|
|
|
126
144
|
| `ID is no longer available on the server. Ask the user to attach the file again.` | The document was deleted or expired after the request was planned, or its text went while a search or read went through it. Since 0.9.0 the call's hooks are told (`ToolCallHooks.onDocumentGone`), and `askWithFiles` gives a `"document_gone"` notice. |
|
|
127
145
|
| `Unknown tool “NAME”.` | The name is not a tool of this tool set. The name is cut at 64 characters, never in the middle of a character. Until 0.6.0: `Unknown tool NAME.`, with the whole name. |
|
|
128
146
|
|
|
147
|
+
**Store timeouts.** Since 0.10.0 a call does not answer the model when the store did not answer in
|
|
148
|
+
time: a [`DocumentStoreError`](./library.md#documentstoreerror) of code `"ETIMEDOUT"` (a store call
|
|
149
|
+
past `storeTimeoutMs`, or a system error of that code), or of code `"STORE_STUCK"` (refused at once
|
|
150
|
+
because too many store calls of the process are stuck). `execute` and `executeWithFiles` throw it,
|
|
151
|
+
from any tool and from any part of a whole-file read, which would otherwise count as a part that
|
|
152
|
+
could not be read. The other parts of that read stop then: their requests under way are aborted
|
|
153
|
+
through the signal they were sent with, and no part is sent after it. In `askWithFiles` the question then ends with a `run.error`, which
|
|
154
|
+
[errorInfoOf(error)](./errors-and-retries.md#errorinfooferror) reads as a 503 to try again, and the model is sent no
|
|
155
|
+
new text. Until 0.10.0 the model read "The document store could not be read (ETIMEDOUT). Try
|
|
156
|
+
again." and went on, with a store that was not answering. Any other store error is still an error
|
|
157
|
+
result for the model.
|
|
158
|
+
|
|
159
|
+
**A call's own signal.** `ToolCallHooks.signal` (new in 0.10.0, the fourth argument of
|
|
160
|
+
`executeWithFiles`) ends that call alone: its load of the document, its search, its regex time, its
|
|
161
|
+
whole-file read, its wait for a turn to look at pages, its read of the original, and the check made
|
|
162
|
+
once it has read, that the store still holds the document it loaded. It is joined
|
|
163
|
+
with the tool set's `signal`. The call throws the signal's reason, as for the tool set's own; the
|
|
164
|
+
other calls of the tool set go on.
|
|
165
|
+
|
|
129
166
|
**Size.** One result is at most `toolResultCharacters` characters of JSON (a field of
|
|
130
167
|
[`Budget`](./library.md#budget): 24,000 with the default budget, less for a model with a small
|
|
131
168
|
window). The answer of `analyze_whole_document` may have up to the larger of that and 40,000.
|
|
@@ -214,14 +251,20 @@ language.
|
|
|
214
251
|
matches its plain form, as inside a longer word: כסף finds כספים. New in 0.8.0.
|
|
215
252
|
- A passage is a run of whole lines of about 1,500 characters, or 40 lines at most. A passage that
|
|
216
253
|
contains the whole query as a phrase (more than one term, up to 200 characters) is ranked higher.
|
|
217
|
-
- Passages come best first
|
|
254
|
+
- Passages come best first; of two with the same score, the one the search met first. Passages are
|
|
255
|
+
met one query term at a time, so of two with the same score that two terms found, the earlier in
|
|
256
|
+
the file is not always first.
|
|
257
|
+
`score` is rounded to two decimals and only orders the results. Since 0.10.0 the search keeps only
|
|
258
|
+
the best passages as it goes, rather than sorting every passage it scored.
|
|
218
259
|
- A query with no usable term, or with no hit, returns no passage and the note "No passage contains
|
|
219
260
|
these keywords. Try other words, synonyms, or exact mode."
|
|
220
261
|
|
|
221
262
|
**`exact`** finds every line that contains the text. A line counts once, however many times it
|
|
222
263
|
contains the text. A text with a line break matches across lines and counts on each line where it
|
|
223
|
-
starts, overlapping ones included: "a\na" counts 2 lines of "a\na\na" (1 until 0.8.0).
|
|
224
|
-
|
|
264
|
+
starts, overlapping ones included: "a\na" counts 2 lines of "a\na\na" (1 until 0.8.0). Past
|
|
265
|
+
1,000,000 matching lines the scan goes on counting within 3 seconds, the time of a regex search, and
|
|
266
|
+
stops there (until 0.10.0 it stopped at 1,000,000, and a count of 1,200,000 lines read 1,000,000); with
|
|
267
|
+
`whole_word` or `group_by` it stops after 3 seconds in all. The query is composed (NFC), as the text is at ingest, so
|
|
225
268
|
"é" typed as "e" and an accent finds "é". Without `case_sensitive`, both sides are folded: lower
|
|
226
269
|
case, Greek final sigma as σ, curly quotes and primes as `'` and `"`, dashes and the minus sign as
|
|
227
270
|
`-`, no-break and thin spaces as a space, Hebrew geresh, gershayim and maqaf as `'`, `"` and `-`,
|
|
@@ -260,7 +303,7 @@ Results of `exact` and `regex`:
|
|
|
260
303
|
| `total_matching_lines` | number | Every matching line in the file (or in `searched_lines`), not only those shown. This is the number to count with. |
|
|
261
304
|
| `order` | `"last"`, optional | With `order: "last"` ([below](#the-last-matches-order-last)). |
|
|
262
305
|
| `table_headers` | array, optional | When matches are rows of a table: the first row of each such table, as `{ line, text }`, up to 5: line 1 of a CSV file, the first row of each sheet of a workbook a match is in, the first row of each `\| cell \|` table elsewhere (looked for up to 20,000 lines above the match). Absent when no match is a row of a table, or the match is that first row. New in 0.8.1. |
|
|
263
|
-
| `note` | string, optional | When more lines match than are shown: "N of the M matching lines are shown: the first K and the last (line L). To see the ones in between, search again with from_line F, or count them with group_by." ("the first and the last" when K is 1). Until 0.8.0 it ended "narrow the search." When the scan stopped (1,000,000 lines, 3 seconds of a `whole_word` or `group_by` search, or a regex limit): "The scan stopped early; the total is a lower bound, and the last match in the file is not known." Or a size-limit note (below). Absent when every match is shown. |
|
|
306
|
+
| `note` | string, optional | When more lines match than are shown: "N of the M matching lines are shown: the first K and the last (line L). To see the ones in between, search again with from_line F, or count them with group_by." ("the first and the last" when K is 1). Until 0.8.0 it ended "narrow the search." When the scan stopped (3 seconds past 1,000,000 lines, 3 seconds of a `whole_word` or `group_by` search, or a regex limit): "The scan stopped early; the total is a lower bound, and the last match in the file is not known." Or a size-limit note (below). Absent when every match is shown. |
|
|
264
307
|
| `next_from_line` | number, optional | When matches between the first ones and the last one are not shown: the line after the last of the first ones (F above). A search with `from_line` set to it shows the ones after. Absent when every match is shown, when the scan stopped early, with `order: "last"` and with `group_by`. New in 0.8.0. |
|
|
265
308
|
| `matches` | array | The first `max_results` matching lines, in file order, then the last matching line of the file when it is not among them. A scan that stopped early shows no last line, since it did not reach the end. With `order: "last"`, the last `max_results` matching lines, in file order. |
|
|
266
309
|
| `matches[].line` | number | The line number. |
|
|
@@ -338,7 +381,7 @@ To fit its room, it loses the earliest of them first, and keeps the very last. T
|
|
|
338
381
|
file: the last match is on line L, and the first on line F. Narrow the query or read specific
|
|
339
382
|
lines."
|
|
340
383
|
|
|
341
|
-
When the scan stopped early (1,000,000 lines, 3 seconds of a `whole_word` or `group_by` search, or a regex limit), the lines shown are the last of
|
|
384
|
+
When the scan stopped early (3 seconds past 1,000,000 lines, 3 seconds of a `whole_word` or `group_by` search, or a regex limit), the lines shown are the last of
|
|
342
385
|
those it found, and the line of the first match is not named. The note is then "The scan stopped
|
|
343
386
|
early; the total is a lower bound. These are the last N matching lines it found, in the order of
|
|
344
387
|
the file. There may be later ones, after line L: search again with from_line F." (F is L + 1;
|
|
@@ -455,7 +498,8 @@ The tables it reads:
|
|
|
455
498
|
|
|
456
499
|
A column is named as in the header (case and spaces ignored), by its letter (`C`) or number (`3`),
|
|
457
500
|
or by the lower part of a joined header ("הכנסות" for "פברואר / הכנסות") when only one column has
|
|
458
|
-
it.
|
|
501
|
+
it. A letter or a number names a column only when no column has that name; until 0.10.0 a letter
|
|
502
|
+
named one only in a sheet with no header. Numbers are read as people write them: `1,234.5`, `-12`, `(1,200)` for a negative, `₪4,750`,
|
|
459
503
|
`$ 12.00`, `12%` (12), `1 234`, `12,5` (a decimal comma), `1.234,56`. A sum or average leaves out
|
|
460
504
|
cells that are not numbers, and says how many (`values_not_numbers`); `min` and `max` of ISO dates
|
|
461
505
|
compare them as text. Up to 10,000 groups are counted one by one; rows of further groups are
|
|
@@ -475,6 +519,8 @@ Result:
|
|
|
475
519
|
| `total_groups` | number, optional | Groups found, with `group_by`. |
|
|
476
520
|
| `groups` | array | One entry a group: `group` (the value of each group-by column, as its first row writes it), each metric by its name (`count`, `"sum:Revenue"`: null when no row of the group had a number there), `rows` when `count` was not asked, and `lines`, the lines of its first 3 rows. |
|
|
477
521
|
| `note` | string, optional | "N of the M groups are shown…", when `limit` cut them. |
|
|
522
|
+
| `cite` | string, optional | For a table sent whole (`ToolOptions.inline`), when a group was found: how to cite the lines listed, with the file's name, as "Cite the lines listed in your answer, like (orders-2026.csv L5, L10, L15)." Over a table shown in full, Flash-Lite answered with the count alone. Its last field. New in 0.10.0. |
|
|
523
|
+
| `filter_note` | string, optional | A filter whose value names a column, compared with that column's cell in each row: "Each row's \"Q1 / Actual\" was compared with its own \"Q1 / Budget\" (>), as the filter's value names that column." New in 0.10.0. |
|
|
478
524
|
| `values_not_numbers`, `other_rows`, `repeated_header_rows`, `irregular_rows` | optional | Cells left out of a metric, rows of groups past 10,000, header rows found again inside the table, and rows with values past the header's columns (a sign that the header was read wrong). |
|
|
479
525
|
|
|
480
526
|
```json
|
|
@@ -498,6 +544,17 @@ names 3 columns of this table: …. Name one of them in full.", "No table \"Budg
|
|
|
498
544
|
has 3 sheets…", "This file has no table to aggregate…". `evidence` cites the header line and each
|
|
499
545
|
group's lines; a result dropped to make room keeps its largest 30 groups.
|
|
500
546
|
|
|
547
|
+
A filter that orders a column (`>`, `>=`, `<`, `<=`) against a value that is not a number and
|
|
548
|
+
names a column (its full name, the lower part of a joined header, or a letter when the filter's own
|
|
549
|
+
column is a letter too: `C` > `B`) compares the two cells of each row, since 0.10.0: `{ "column":
|
|
550
|
+
"Q1 / Actual", "op": ">", "value": "Q1 / Budget" }` keeps the rows that spent more than their Q1
|
|
551
|
+
budget. Two numbers compare as numbers and two texts as text; a number against a text, or an empty
|
|
552
|
+
cell, does not match. The result says so in `filter_note`. A value that is the lower part of
|
|
553
|
+
several columns is an error that names them. Before, the value was compared as text: the filter
|
|
554
|
+
matched no row, and said nothing of why. `=`, `!=` and the text filters keep a value that is also a
|
|
555
|
+
column's name as a value ("Department" != "Total"). The description the model sees does not
|
|
556
|
+
mention it: the models write such filters unasked.
|
|
557
|
+
|
|
501
558
|
## `read_document`
|
|
502
559
|
|
|
503
560
|
The description the model sees:
|
|
@@ -516,6 +573,32 @@ shortened (to 70% of its length, step by step) until it fits, and `next_start_li
|
|
|
516
573
|
go on. When one line alone is longer than that, its text is cut to half of that room and
|
|
517
574
|
`text_cut` is `true`.
|
|
518
575
|
|
|
576
|
+
A read cut short of its range that way also says, in `whole_file`, that the whole file can be
|
|
577
|
+
read with `analyze_whole_document`, when all of these hold (new in 0.10.0), so that it points only
|
|
578
|
+
at a read that the tool set and the question's limits would let through on the model's next turn,
|
|
579
|
+
by the read's estimated parts:
|
|
580
|
+
|
|
581
|
+
- the tool set declares `analyze_whole_document` and has a part reader (`generate`);
|
|
582
|
+
- the file can be read whole: it is not sent whole in the prompt (`ToolOptions.inline`), a
|
|
583
|
+
whole read of it is left (`maxWholeDocumentReads`, and no earlier read of it that could read no
|
|
584
|
+
part), and its estimated parts are within `maxMapChunks` (without the margin of 5% that the
|
|
585
|
+
declaration and the card give the estimate: the read counts its parts, and may count one more)
|
|
586
|
+
and within the call's [`ToolCallLimits.maxRequests`](#toolcalllimits), when it has one. In
|
|
587
|
+
`askWithFiles` that is what `limits.requests` leaves once the next turn, which calls the read,
|
|
588
|
+
and the answer of the question have their requests; and 0 when the question would not start a
|
|
589
|
+
whole read of the file on that turn: one that would pass its ceiling on input tokens or requests
|
|
590
|
+
(`limits.inputTokens`, `limits.requests`) with that turn's request counted, or one more than its
|
|
591
|
+
`wholeReadsPerQuestion`;
|
|
592
|
+
- the result, with it, stays within its cap.
|
|
593
|
+
|
|
594
|
+
At a border the hint can still point at a read that is then refused, before it sends any request:
|
|
595
|
+
the read can count one part more than the estimate, and the next turn's request is counted at the
|
|
596
|
+
size of the conversation before this turn's results.
|
|
597
|
+
|
|
598
|
+
A read that shows every line asked for, and one shortened only to 600 lines, have no `whole_file`.
|
|
599
|
+
Gemini 3.5 Flash-Lite and 3.8 Flash read a contract they were asked to summarize in ranges of about
|
|
600
|
+
16 lines, and answered from those, when a whole read would have given all of it.
|
|
601
|
+
|
|
519
602
|
| Field | Type | Meaning |
|
|
520
603
|
|---|---|---|
|
|
521
604
|
| `document` | string | The file name. |
|
|
@@ -526,6 +609,7 @@ go on. When one line alone is longer than that, its text is cut to half of that
|
|
|
526
609
|
| `text_cut` | `true`, optional | The one line shown was cut: its end is missing. |
|
|
527
610
|
| `next_start_line` | number, optional | The first line not shown, when the file goes on. |
|
|
528
611
|
| `note` | `"End of file."`, optional | Instead of `next_start_line`, when the last line shown is the file's last. |
|
|
612
|
+
| `whole_file` | string, optional | "Only N lines fit here. To read all M lines for a task that needs all of them, such as a full summary or a timeline, use analyze_whole_document." ("Only 1 line fits here" for one; "Not even one line fits here: the text of line N is cut." when `text_cut` is `true`), on a read cut short of its range by the size limit when the file can be read whole (see above). New in 0.10.0. |
|
|
529
613
|
|
|
530
614
|
```json
|
|
531
615
|
{ "document": "app.log", "lines": "1200-1399", "total_lines": 5000, "text": "1200| ...\n1201| ...", "next_start_line": 1400 }
|
|
@@ -571,19 +655,53 @@ The description the model sees:
|
|
|
571
655
|
|---|---|---|---|
|
|
572
656
|
| `document_id` | string | yes | The document. |
|
|
573
657
|
| `task` | string | yes | What to find or produce from the whole file, stated completely. Not blank (`task is required.`). |
|
|
658
|
+
| `output` | `"answer"` \| `"items"` | no | `"answer"`, the default: one answer written from the notes of every part, for a summary, a timeline, or a description of events. `"items"`: to count the items of a kind that must be judged by meaning, such as the clauses that set a fine; each part lists them, each with its line and a quote checked against the file, and the result counts them, by label ([below](#items-output-items)). Any other value is `"answer"`. New in 0.10.0. |
|
|
659
|
+
| `labels` | string[] | no | With `output: "items"`: the kinds of item to label each one with, such as `["penalty", "deadline"]`. Up to 12, each up to 40 characters; one string is read as a list of one. Ignored for `"answer"`. New in 0.10.0. |
|
|
660
|
+
|
|
661
|
+
0.10.0 added the two arguments, and kept the description of 0.9.0 word for word: a chat where the
|
|
662
|
+
tool is declared misses the provider's prompt cache once after the upgrade. Said in the
|
|
663
|
+
description, a sentence on items made Gemini Flash-Lite choose this read for a full summary in 3
|
|
664
|
+
of 10 runs, against 7 of 8 with 0.9.0's words, so items are told in the description of `output`
|
|
665
|
+
alone. There, `"answer"` names a summary and a timeline: told only that items list what a task asks
|
|
666
|
+
for, Flash-Lite chose them for a timeline of events, whose items explain nothing, and its answers
|
|
667
|
+
lost events.
|
|
574
668
|
|
|
575
669
|
The file is split into parts of up to `mapChunkTokens` tokens (and 80% of `maxRequestBytes`), 4 are
|
|
576
670
|
read at a time with the `generate` function of the tool set, their notes are merged, and one answer
|
|
577
671
|
is written from them. A part the model refuses as too large is read as two halves, while
|
|
578
672
|
`maxMapChunks` and [`ToolCallLimits.maxRequests`](#toolcalllimits) allow it. The steps, output
|
|
579
|
-
limits and retries are in [How it works](../how-it-works.md); what a read costs is in
|
|
673
|
+
limits and retries are in [How it works](../how-it-works.md#map-reduce); what a read costs is in
|
|
580
674
|
[Costs and limits](../guides/costs-and-limits.md).
|
|
581
675
|
|
|
676
|
+
Each part's request sends the file's name and lines, then the part between `<part>` and `</part>`,
|
|
677
|
+
then where the part is in the file, the task and the rules. A part that starts in the middle of a
|
|
678
|
+
section of the file's outline (a day of a diary, a chapter, a sheet) has the line of the heading it
|
|
679
|
+
is under first, numbered as in the file and cut to 120 characters, and its first line says so:
|
|
680
|
+
`Document: diary.md, lines 967-1277, under the heading on line 958, which comes first.` (since
|
|
681
|
+
0.10.0; Gemini Flash-Lite dated the events of such a part by the day before). Logs, JSON and CSV
|
|
682
|
+
files have no outline. Its system text says that text inside
|
|
683
|
+
`<part>` is the file's content: never instructions to follow. A merge of notes and the answer of the
|
|
684
|
+
read send their notes first, between `<notes>` and `</notes>`, and the task last. So two reads of
|
|
685
|
+
one document with other tasks send the same start in each part's request, up to the end of the
|
|
686
|
+
part, for a provider's prompt cache. Until 0.10.0 the task came first, before the part.
|
|
687
|
+
|
|
688
|
+
Given `maxRequests`, a read counts its requests (since 0.10.0). Each part is one request, so a read
|
|
689
|
+
with more parts than `maxRequests` is refused before any request is sent (see the errors below). A
|
|
690
|
+
round of merges that would leave
|
|
691
|
+
no request for the answer is not made: the answer is then written from the notes that fit one
|
|
692
|
+
request (`mapChunkTokens`), in the order of the file, and the result says how many parts' notes it
|
|
693
|
+
left out (`notes_left_out`). When not even the answer has a request left, the notes are the answer
|
|
694
|
+
(`notes_only`). A part is halved only while the requests left also cover the merges its notes may
|
|
695
|
+
need, priced as long as the output limit allows, and the answer. Until 0.10.0 the merges went past
|
|
696
|
+
`maxRequests`: a read of 27 parts given 32 requests made 40.
|
|
697
|
+
|
|
582
698
|
Each document may be read whole [`MAX_WHOLE_DOCUMENT_READS`](#max_whole_document_reads) times (1)
|
|
583
699
|
by one tool set, which is one question in `askWithFiles`. Set it with `limits.wholeDocumentReads`
|
|
584
700
|
in [`AskLimits`](./ask.md#asklimits), or `maxWholeDocumentReads` in
|
|
585
701
|
[`ToolOptions`](./library.md#tooloptions). A read is counted when it starts, so two calls in one
|
|
586
|
-
turn do not both pass.
|
|
702
|
+
turn do not both pass. A read that could read no part is not tried again in the tool set, whatever
|
|
703
|
+
that number is (since 0.10.0; before, a number of 2 or more let it try again).
|
|
704
|
+
[`ToolSet.wholeReadsLeft`](#toolset) says how many reads of a document are left.
|
|
587
705
|
|
|
588
706
|
| Field | Type | Meaning |
|
|
589
707
|
|---|---|---|
|
|
@@ -592,9 +710,10 @@ turn do not both pass.
|
|
|
592
710
|
| `parts_with_relevant_content` | number | The parts that were read and held something for the task. |
|
|
593
711
|
| `parts_that_failed` | number, optional | Parts that could not be read. The notes name each one: "[This part could not be read: reason]". |
|
|
594
712
|
| `notes_cut_short` | number, optional | Notes of parts, and merges of notes, that stopped at the output limit or were cut off by the provider. |
|
|
713
|
+
| `notes_left_out` | number, optional | The relevant parts whose notes are not in the answer: the read reached `maxRequests` before it could merge them. New in 0.10.0. |
|
|
595
714
|
| `answer_cut_short` | `true`, optional | The final answer stopped at its output limit. |
|
|
596
|
-
| `notes_only` | `true`, optional | The last step, which writes one answer from the notes, failed
|
|
597
|
-
| `note` | string, optional | With `notes_only`: "The last step of this read, which writes one answer from the notes of the parts, failed (REASON). The answer is those notes: answer from them.", plus "Some of them were cut off at the output limit, so they are incomplete: tell the user." when some were. Otherwise, when notes or the answer were cut short: "Incomplete: the model's output limit was reached, so some relevant items are missing from this answer. Tell the user it is incomplete. For a complete list or an exact count, use search_document in exact or regex mode (it returns total_matching_lines), or ask about a narrower part of the file." |
|
|
715
|
+
| `notes_only` | `true`, optional | The last step, which writes one answer from the notes, failed, or (since 0.10.0) had no request left within `maxRequests`: `answer` is the notes of the parts, with their line citations. |
|
|
716
|
+
| `note` | string, optional | With `notes_only`: "The last step of this read, which writes one answer from the notes of the parts, failed (REASON). The answer is those notes: answer from them.", or "This read reached the question's limit on model requests before its last step, which writes one answer from the notes of the parts. The answer is those notes: answer from them.", plus "Some of them were cut off at the output limit, so they are incomplete: tell the user." when some were. With `notes_left_out`: "Incomplete: this read reached the question's limit on model requests before it could combine the notes of every part, so the notes of N of the M relevant parts are not in this answer. Tell the user it is incomplete." and the same pointer to exact search as below. Otherwise, when notes or the answer were cut short: "Incomplete: the model's output limit was reached, so some relevant items are missing from this answer. Tell the user it is incomplete. For a complete list or an exact count, use search_document in exact or regex mode (it returns total_matching_lines), or ask about a narrower part of the file." |
|
|
598
717
|
| `answer` | string | The answer. When no part held anything relevant: "No part of NAME contained anything relevant to: TASK", with the count of parts that could not be read, if any. |
|
|
599
718
|
| `answer_shortened` | string, optional | "The rest of this answer did not fit in the room left in this conversation." The answer was cut at its end, which then reads `…`. |
|
|
600
719
|
|
|
@@ -602,6 +721,100 @@ turn do not both pass.
|
|
|
602
721
|
{ "document": "novel.txt", "parts_read": 4, "parts_with_relevant_content": 3, "answer": "Ada appears first in chapter 2 (L412) ..." }
|
|
603
722
|
```
|
|
604
723
|
|
|
724
|
+
### Items: `output: "items"`
|
|
725
|
+
|
|
726
|
+
New in 0.10.0. Each part replies with one JSON object for each item it finds, on a line of its own:
|
|
727
|
+
`{"line": 123, "label": "penalty", "value": "5%", "quote": "a fine of 5% of the order"}`, the label
|
|
728
|
+
only when the call gave `labels`. The rules ask for a quote of five to twelve words of the line
|
|
729
|
+
that state the item, copied exactly, letter by letter, at most 80 characters: the longer quotes
|
|
730
|
+
asked for at first (200 characters) made Gemini Flash-Lite cut its list at the output limit more
|
|
731
|
+
often, and copy more words wrong; asked for "the few words" of the line, it gave some quotes of 14
|
|
732
|
+
characters, too short for the near check below. Code reads the replies, checks the items and
|
|
733
|
+
counts them. No model merges them, and there is no answer of the read: one request a part.
|
|
734
|
+
|
|
735
|
+
- A reply is read leniently: a line may start with a list mark (`- `, `1. `) and end with a comma,
|
|
736
|
+
or hold several objects (`{…} {…}`), code fences are passed over, and a JSON array of the objects
|
|
737
|
+
is read too, and so is an object that wraps their list (`{"items": […]}`: no `quote` of its own,
|
|
738
|
+
and one array of objects). A line that is not a JSON object is skipped. A reply that says
|
|
739
|
+
`NOTHING RELEVANT` has no item, unless it lists items after it: those are checked as any other.
|
|
740
|
+
- An item counts when its `quote` is on the line it names, within the part that listed it. They
|
|
741
|
+
are compared composed (NFC) and folded as exact search folds text (case, quotes, dashes, spaces),
|
|
742
|
+
without Hebrew points, with final letters as plain ones (כסף is found in כספים), without the
|
|
743
|
+
characters that show nothing (the direction marks U+200E, U+200F and U+061C that Hebrew text
|
|
744
|
+
from Word and PDF files often has next to a number, and the joiners), and with runs of blanks as
|
|
745
|
+
one space. A line number copied with the quote (`12| `) and the quote marks around it
|
|
746
|
+
are left out, and a quote cut with `…` must have each of its pieces on the line, in order.
|
|
747
|
+
- An item whose quote is not on the line it names, but on exactly one line of its part, is given
|
|
748
|
+
that line: in a file whose lines start with numbers ("7| 5. …", clause 5 on line 7), a model may
|
|
749
|
+
name the number in the text.
|
|
750
|
+
- An item whose quote is on no line of its part, but near the line it names, keeps that line: a
|
|
751
|
+
quote of 15 characters or more, compared as above, whose numbers are all numbers of the line,
|
|
752
|
+
and whose pieces are runs of the line with at most one letter in five changed, added or taken
|
|
753
|
+
out in all. Gemini Flash-Lite copies Hebrew quotes with a letter or a word changed (השרים for
|
|
754
|
+
השרתים, מקוזז for לקזז, ש"ץ for ש"ח). A quote with an amount other than the line's is not near
|
|
755
|
+
it, so neither is the quote of the next clause of a contract written to the same pattern. A line
|
|
756
|
+
of up to 2,000 characters, the longest that ingest stores, is compared whole. A longer line, which
|
|
757
|
+
a store of your own may give, is looked at only around the two longest words of each piece of the
|
|
758
|
+
quote that are on it in 1 to 4 places: a piece none of whose words is so counts as wrong in all
|
|
759
|
+
its letters, and a quote none of whose words is so is not near it. Measured along all of a line
|
|
760
|
+
of 118,759 characters, one quote took 688 ms, and one cut with "…" into 41 short pieces 677 ms.
|
|
761
|
+
- An item whose quote is on no line of its part, nor near the line it names, is given the line of
|
|
762
|
+
its part that is near its quote and starts with the number it names ("7| 5. …" for 5), when
|
|
763
|
+
exactly one line is both: Gemini Flash-Lite named the clause for the line and copied a letter of
|
|
764
|
+
the quote wrong (שילם for ישלם). When two lines start with that number and are near the quote,
|
|
765
|
+
as in a file whose numbering starts again, it is not counted. A line that starts with a date or
|
|
766
|
+
a time (`5/11 …`, `5-11-2026 …`, `05:30:12 …`, `5.11.2026 …`) does not start with the number 5.
|
|
767
|
+
New in 0.10.0.
|
|
768
|
+
- Any other item counts in `unverified_items`, not in `total_items`.
|
|
769
|
+
- A backslash that starts no JSON escape (`ש\"\ח`, as Gemini Flash-Lite escapes a Hebrew letter) is
|
|
770
|
+
taken out before a line is read again, and a `\u` with fewer than four hex digits is taken out
|
|
771
|
+
with the digits it has (Flash-Lite wrote ט as `\u05d`, which left "u05d" in the quote).
|
|
772
|
+
- The same item listed twice (the same line, label and value) counts once. So does an item given
|
|
773
|
+
a line other than the one it named (either way above) when that line has an item with its label,
|
|
774
|
+
whatever its value: Gemini Flash-Lite listed a clause once by its line and once by the clause's
|
|
775
|
+
number, with the value written another way (`5,000 ש"ח` and `5000`). The item that named its own
|
|
776
|
+
line is the one kept. New in 0.10.0.
|
|
777
|
+
- A label is matched to `labels` as quotes are compared, and given as the call spelled it. A label
|
|
778
|
+
that is not one of them is kept as the model wrote it.
|
|
779
|
+
- A part whose list stops at the output limit is read again as two halves, and a half as two
|
|
780
|
+
quarters: two levels at most, while `maxRequests` allows it (without it, while the halves take no
|
|
781
|
+
more than `maxMapChunks` requests). A part the model refuses as too large is halved the same way.
|
|
782
|
+
A list still cut is counted as it is, and the result says that items may be missing.
|
|
783
|
+
- The read costs its parts alone, each with the longer rules of a list, which is less than an
|
|
784
|
+
answer read, with its merges and its answer. The ceiling of `askWithFiles` prices it so: in input
|
|
785
|
+
tokens and in requests, an items read is its parts alone, and an answer read its parts, a merge
|
|
786
|
+
and its answer. So an items read can run where an answer read of the same file would pass the
|
|
787
|
+
ceiling.
|
|
788
|
+
|
|
789
|
+
| Field | Type | Meaning |
|
|
790
|
+
|---|---|---|
|
|
791
|
+
| `document` | string | The file name. |
|
|
792
|
+
| `total_items` | number | The items found, each once, whose quote is on their line, or near it as above. Counted by code. |
|
|
793
|
+
| `counts_by_label` | object, optional | The items by label, when they have labels: `{ "penalty": 37 }`. An item with no label among labelled ones counts under `"unlabeled"`. |
|
|
794
|
+
| `items` | array | The first 50 items, in the order of the file, each `{ line, label?, value?, quote }`. The value and the quote are as the model wrote them, up to 200 and 300 characters. |
|
|
795
|
+
| `more_items` | number, optional | The items not shown: past the first 50, or past those kept when the result was cut to its room. |
|
|
796
|
+
| `unverified_items` | number | Items a part listed that are not counted: a quote on no line of the part and not near the line the item names, or on several lines but not on that one. A quote near its line (15 characters or more, at most one letter in five wrong, every number a number of the line) counts there, so it is not among them. |
|
|
797
|
+
| `parts_read` | number | The parts the file was read in, those that could not be read included; a halved part counts as its halves. |
|
|
798
|
+
| `parts_failed` | number, optional | Parts that could not be read: their items are missing. |
|
|
799
|
+
| `parts_cut_short` | number, optional | Parts whose list was still cut at the output limit. |
|
|
800
|
+
| `note` | string, optional | What to tell the user, from these: "No part of NAME listed an item for: TASK." (a stop is added to a task that has none); "No item was found on its line for: TASK." when items were listed and none is counted; "The first 50 items are shown; total_items counts them all.", or "The first K items are shown, to stay within the size limit; total_items counts them all." when the result was cut to its room; "N listed items are not counted: their quote is not on the line they name, nor on just one other line of the part." (an item whose quote is near its line counts, so it is not among them); "N parts could not be read (REASON), so items may be missing: tell the user the count may be incomplete."; "N parts listed more items than fit the model's output limit, even read in smaller pieces, so items may be missing: tell the user the count may be incomplete." |
|
|
801
|
+
|
|
802
|
+
```json
|
|
803
|
+
{
|
|
804
|
+
"document": "contract.docx",
|
|
805
|
+
"total_items": 37,
|
|
806
|
+
"counts_by_label": { "penalty": 37 },
|
|
807
|
+
"items": [{ "line": 7, "label": "penalty", "value": "1,250", "quote": "קנס בסך 1,250 ש\"ח לכל מקרה" }],
|
|
808
|
+
"unverified_items": 0,
|
|
809
|
+
"parts_read": 5
|
|
810
|
+
}
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
Cut to its room, it loses items from the end of its list (one is always kept), `more_items` counts
|
|
814
|
+
every item it does not show, and the note says how many it shows. Its counts are kept whole. Its evidence
|
|
815
|
+
([`evidenceOf`](./ask.md#evidenceofcall-result)) is `whole: true` with the lines of the items it
|
|
816
|
+
shows, and its stand-in keeps the counts and the first 20 items.
|
|
817
|
+
|
|
605
818
|
Errors:
|
|
606
819
|
|
|
607
820
|
| Error | When | Counted as a read |
|
|
@@ -609,9 +822,12 @@ Errors:
|
|
|
609
822
|
| `NAME was already read whole for this question, and is not read whole again. Use the answer of that read, or search_document and read_document for the details.` | The document was read whole as often as it may be (" N times" is added when that is more than 1). | no |
|
|
610
823
|
| `Whole-file reads are turned off for this question. Use search_document and read_document on NAME.` | `maxWholeDocumentReads` (or `limits.wholeDocumentReads`) is 0. | no |
|
|
611
824
|
| `The whole-file read of NAME failed earlier in this question (REASON), and is not tried again. Use search_document and read_document.` | An earlier read of it could read no part. | no |
|
|
612
|
-
| `
|
|
825
|
+
| `NAME is shown in full above: answer from it, and use search_document or aggregate_table for exact counts.` | The document is one of `ToolOptions.inline`: its text is in the prompt. Nothing is sent. New in 0.10.0. | no |
|
|
826
|
+
| `labels takes up to 12 labels, each up to 40 characters.` | `output: "items"` with more labels, or a longer one. New in 0.10.0. | no |
|
|
827
|
+
| `Reading all of NAME needs N model calls, over the limit of M. Use search_document to narrow the question first.` | The read counted more parts than `maxMapChunks` ("1 model call" for one). Nothing was sent. | no |
|
|
828
|
+
| `Reading all of NAME takes N model requests, one for each part, and M are left for it in this question. Use search_document and read_document.` | The read counted more parts than [`ToolCallLimits.maxRequests`](#toolcalllimits) ("1 is left" for one; "takes 1 model request, for its one part" for a file of one part). Nothing was sent. New in 0.10.0: before, the read sent every part whatever its limit. | no |
|
|
613
829
|
| `Could not read any part of NAME: REASON` | Every part failed at the model. | yes |
|
|
614
|
-
| The store's error | No part could be read from the store. Nothing was sent. | no |
|
|
830
|
+
| The store's error | No part could be read from the store. Nothing was sent. A store timeout is thrown instead ([Store timeouts](#rules-for-every-tool)). | no |
|
|
615
831
|
|
|
616
832
|
REASON, in these errors, in the notes of a part that could not be read, and in the note of
|
|
617
833
|
`notes_only`, says why a model request failed. Since 0.6.0 it is built from the error's kind, its
|
|
@@ -771,8 +987,9 @@ of this unless you write it.
|
|
|
771
987
|
- For the same call twice in one turn: `{ "already_shown": true, "note": "Not run: call 1 of this turn is the same call, and its result is next to this one. Use it." }`
|
|
772
988
|
|
|
773
989
|
A result of an earlier turn that failed, was cut (`truncated`, `text_cut`, a note that starts
|
|
774
|
-
"Showing "), came from a search that stopped early,
|
|
775
|
-
|
|
990
|
+
"Showing "), came from a search that stopped early, is itself a pointer or a stand-in, or (since
|
|
991
|
+
0.10.0) was replaced by your `onToolResult` (`redacted: true`) is never pointed to: the call runs,
|
|
992
|
+
and may get more. A search whose note only says how many of its
|
|
776
993
|
matches are shown ("21 of the 442 matching lines are shown: …") was not cut, and is pointed to.
|
|
777
994
|
The same call made twice in one turn gets the pointer to the first whatever the first returns (an
|
|
778
995
|
error, a cut result, a pointer); only when the first is refused for lack of room is the second
|
|
@@ -857,6 +1074,23 @@ const TOOL_NAMES = {
|
|
|
857
1074
|
Compare a `ToolCall.name` with these rather than with string literals. See
|
|
858
1075
|
[Your own adapter and loop](../guides/own-adapter-and-loop.md).
|
|
859
1076
|
|
|
1077
|
+
### declarationsFor(names)
|
|
1078
|
+
|
|
1079
|
+
`declarationsFor(names: readonly ToolName[]): ToolDeclaration[]`
|
|
1080
|
+
|
|
1081
|
+
The [declarations](#tooldeclaration) of the tools `names`, in the order a tool set declares them
|
|
1082
|
+
(search, read, overview, aggregate, analyze, view), whatever the order of `names`: the declarations
|
|
1083
|
+
of `files.tools(documents, { declare: names })`, byte for byte. A name that is not a tool's is left
|
|
1084
|
+
out. Use it to plan the size of a request before the tools are made. New in 0.10.0.
|
|
1085
|
+
|
|
1086
|
+
```ts
|
|
1087
|
+
import { declarationsFor } from "llm-large-files";
|
|
1088
|
+
|
|
1089
|
+
const declared = declarationsFor(["aggregate_table", "search_document", "read_document"]);
|
|
1090
|
+
// search_document, read_document, aggregate_table
|
|
1091
|
+
const bytes = Buffer.byteLength(JSON.stringify(declared));
|
|
1092
|
+
```
|
|
1093
|
+
|
|
860
1094
|
### `MAX_VIEW_PAGES`
|
|
861
1095
|
|
|
862
1096
|
`5`. The most pages one `view_pages` call shows. [`ToolCallLimits.maxPages`](#toolcalllimits)
|
|
@@ -889,7 +1123,8 @@ throws.
|
|
|
889
1123
|
| `error` | ` — failed:` and the error, as in ` — failed: Unknown tool “do_magic”.` |
|
|
890
1124
|
| `total_matching_lines` (exact, regex) | ` — 1,203 matching lines` (numbers in en-US form), ` — 1 matching line` for one. With `total_groups` (`group_by`): ` — 214 matching lines in 3 groups`, ` in 1 group` for one |
|
|
891
1125
|
| `passages` (keywords) | ` — 5 passages`, ` — 1 passage` for one |
|
|
892
|
-
| `parts_read` (whole-file read) | ` —
|
|
1126
|
+
| `total_items` and `parts_read` (a whole-file read that lists items, since 0.10.0) | ` — 37 items in 5 parts` (` — 1 item in 1 part` for one), then `, 2 not counted` with `unverified_items`, and `, incomplete` with `parts_failed` or `parts_cut_short` |
|
|
1127
|
+
| `parts_read` (whole-file read) | ` — 9 parts, 3 relevant` (` — 1 part, 1 relevant` for one), then `, notes only` with `notes_only`, or `, incomplete` with `notes_cut_short`, `notes_left_out` (since 0.10.0) or `answer_cut_short` |
|
|
893
1128
|
| `lines` and `total_lines` (read) | ` — got 1200-1342` when the label does not end with the lines shown, else `""` |
|
|
894
1129
|
| `pages` and `total_pages` (view_pages) | ` — got page 2` or ` — got pages 2-3` when the label does not end with the pages shown, else `""` |
|
|
895
1130
|
| anything else (an overview, a cut result) | `""` |
|
|
@@ -920,20 +1155,24 @@ type ToolSet = {
|
|
|
920
1155
|
executeWithFiles(name: string, args: Record<string, unknown>, limits?: ToolCallLimits, hooks?: ToolCallHooks): Promise<ToolOutput>;
|
|
921
1156
|
describe(name: string, args: Record<string, unknown>): string;
|
|
922
1157
|
resultCharacters(name: string): number;
|
|
1158
|
+
wholeReadsLeft?(documentId: string): number; // new in 0.10.0
|
|
923
1159
|
};
|
|
924
1160
|
```
|
|
925
1161
|
|
|
926
1162
|
| Member | What it does |
|
|
927
1163
|
|---|---|
|
|
928
|
-
| `declarations` | The tools to declare to the model, in this order: `search_document`, `read_document`, `get_document_overview`, `analyze_whole_document`, `view_pages`, those that are [offered](#which-tools-are-offered). |
|
|
929
|
-
| `has(name)` | `true` for each declared tool. Also `true` for `analyze_whole_document` when `generate` was given
|
|
1164
|
+
| `declarations` | The tools to declare to the model, in this order: `search_document`, `read_document`, `get_document_overview`, `aggregate_table`, `analyze_whole_document`, `view_pages`, those that are [offered](#which-tools-are-offered), or (since 0.10.0) exactly those `ToolOptions.declare` names, in the same order. |
|
|
1165
|
+
| `has(name)` | `true` for each declared tool. Also, while the text tools are declared, `true` for `aggregate_table` whatever the documents (a call over no table gets the reason), and for `analyze_whole_document` when `generate` was given, even if it is not declared because no document is small enough: a call then gets the reason. With `ToolOptions.declare` (since 0.10.0), `true` for the declared tools alone. Use it to tell the calls of this tool set from others. |
|
|
930
1166
|
| `execute(name, args)` | Runs a call and returns its JSON result, within the tool's own cap. Failures come back as `{ error }`, as listed above. `view_pages` answers with an error here: it returns a file. |
|
|
931
|
-
| `executeWithFiles(name, args, limits?, hooks?)` | Runs any call with [`ToolCallLimits`](#toolcalllimits), and returns the result with the files it produced (`files` is empty for every tool but `view_pages`). Use it in a loop that can send files to the model. `hooks` ([`ToolCallHooks`](./library.md#toolcallhooks), new in 0.7.0) are listeners for this call alone: the progress of a whole-file read, in place of `ToolOptions.onProgress`, and each of its model requests with their retries.
|
|
932
|
-
| `describe(name, args)` | A short line for a progress UI, read from the arguments the way the tool reads them: `Search app.log (exact) for “timeout”` (the query cut to 80 characters; since 0.8.0 followed by ` in lines 1941-end` with `from_line` or `to_line`, and by `, counted by hour` with `group_by` or `, the last ones` with `order: "last"` in exact and regex mode), `Read app.log lines 1200-1260` (`-1260` only when `end_line`
|
|
933
|
-
| `resultCharacters(name)` | The most characters of a result of this tool: the larger of `toolResultCharacters` and 40,000 for `analyze_whole_document`, 600 for `view_pages` (its file is counted in bytes), and `toolResultCharacters` for
|
|
1167
|
+
| `executeWithFiles(name, args, limits?, hooks?)` | Runs any call with [`ToolCallLimits`](#toolcalllimits), and returns the result with the files it produced (`files` is empty for every tool but `view_pages`). Use it in a loop that can send files to the model. `hooks` ([`ToolCallHooks`](./library.md#toolcallhooks), new in 0.7.0) are listeners for this call alone: the progress of a whole-file read, in place of `ToolOptions.onProgress`, and each of its model requests with their retries; a document found gone, and a look told the server is busy (0.9.0); and its own `signal` (0.10.0, [above](#rules-for-every-tool)). |
|
|
1168
|
+
| `describe(name, args)` | A short line for a progress UI, read from the arguments the way the tool reads them: `Search app.log (exact) for “timeout”` (the query cut to 80 characters; since 0.8.0 followed by ` in lines 1941-end` with `from_line` or `to_line`, and by `, counted by hour` with `group_by` or `, the last ones` with `order: "last"` in exact and regex mode), `Read app.log lines 1200-1260` (`-1260` only when the call gave an `end_line` not below `start_line`, read as the tool reads it: since 0.10.0 an `end_line` sent as text, `"250"`, shows too, and one past the 600 lines a read shows reads as its last line), `Read all of contract.docx for “every penalty”, as a list of items` (with `output: "items"`, since 0.10.0), `Overview of app.log`, `Read all of novel.txt for “list every character”` (the task cut to 100 characters), `Look at report.pdf pages 2-3`. A cut never splits an emoji. A file not yet known is "the file"; an unknown tool is its name, as it came (`askWithFiles` labels it `Call “NAME”` instead). The line quotes the model's words as they are: show it as plain text, or clean it as `askWithFiles` does its steps. In `askWithFiles`, this line, made one line of plain text, is the `label` of the call's `tool.start` event, the line `onActivity` gets with "…", and the start of its step. |
|
|
1169
|
+
| `resultCharacters(name)` | The most characters of a result of this tool: the larger of `toolResultCharacters` and 40,000 for `analyze_whole_document`, 600 for `view_pages` (its file is counted in bytes), 600 for a name the tool set does not answer (its error is a few words; since 0.10.0, before which it was `toolResultCharacters`), 600 for a tool declared with `declare` that cannot run and for `analyze_whole_document` without `generate` (since 0.10.0: they answer their reason), and `toolResultCharacters` for the other tools. What a loop sets aside in its request before it runs a call. |
|
|
1170
|
+
| `wholeReadsLeft(documentId)` | How many more times this tool set may read the document whole: 0 once a read of it could read no part, at the cap (`maxWholeDocumentReads`), for a document sent whole (`inline`), for one that is not among its documents, and without `generate`. `askWithFiles` asks it before it prices a read, so a read the tool would refuse is refused with the tool's reason, not its price. Optional in the type, so a tool set of your own still compiles. New in 0.10.0. |
|
|
934
1171
|
|
|
935
|
-
`execute` and `executeWithFiles` throw only when the tool set's `signal
|
|
936
|
-
|
|
1172
|
+
`execute` and `executeWithFiles` throw only when the tool set's `signal`, or (since 0.10.0) the
|
|
1173
|
+
call's own `signal`, was aborted, or the store did not answer in time ([Store
|
|
1174
|
+
timeouts](#rules-for-every-tool), since 0.10.0): the error that ended the call is thrown again
|
|
1175
|
+
instead of being returned to the model.
|
|
937
1176
|
|
|
938
1177
|
A turn of your own loop, run with the tool set. `files` is your
|
|
939
1178
|
[`LargeFiles`](./library.md#largefiles), created once with
|
|
@@ -1002,14 +1241,17 @@ type ToolCallLimits = {
|
|
|
1002
1241
|
| `maxFileBytes` | number | 3/8 of (`maxRequestBytes` − 262,144): 3,651,696 bytes with the default budget | `view_pages`: the most bytes its file may have. Pages are left off the end until the cut fits. Below 1,024 the call fails. Give the room left in your request, times 3/4 when you send files as base64. |
|
|
1003
1242
|
| `maxPages` | number | [`MAX_VIEW_PAGES`](#max_view_pages) (5) | `view_pages`: the most pages this call may show, never more than 5. Below 1 the call fails. Lower it as the pages already shown use up your token budget. |
|
|
1004
1243
|
| `maxResultCharacters` | number | The tool's own cap ([`resultCharacters`](#toolset)) | The most characters of the JSON result, when that is less than the tool's cap: the room left in the request. The result is cut to it and says where to go on. Never below 600. `view_pages` ignores it. |
|
|
1005
|
-
| `maxRequests` | number | No limit | `analyze_whole_document`: the most model requests the read may make.
|
|
1244
|
+
| `maxRequests` | number | No limit | `analyze_whole_document`: the most model requests the read may make. A part the model refuses as too large is read as two halves only while this and `maxMapChunks` allow it (the parts, their merges and the answer must fit). Since 0.10.0 the read keeps to it: a read with more parts than this is refused before any request, a round of merges that would pass it is not made ([above](#analyze_whole_document)), and a read that lists items reads a cut list again in halves only within it. `read_document` (since 0.10.0): what a whole read of its file may make on the model's next turn, the first it can call one on; a read cut short of its range points at one (`whole_file`) only when the file's estimated parts are within it. New in 0.6.0. |
|
|
1006
1245
|
| `maxWaitMs` | number | The library's `pageLookWaitMs` (30,000) | `view_pages`: the most milliseconds the look waits for its turn, when that is less than `pageLookWaitMs`. 0: it runs only when a turn is free now, and is told the server is busy if not. New in 0.9.0. |
|
|
1007
1246
|
|
|
1008
1247
|
In `askWithFiles`, `maxFileBytes` is what is left of `maxRequestBytes` after the request so far
|
|
1009
1248
|
and a tenth kept free (256 KiB at least), times 3/4; `maxPages` is what is left of
|
|
1010
1249
|
`reservedTokens / 2 / pageTokens` pages for the question (60 with a `reservedTokens` of 64,000 and
|
|
1011
1250
|
Gemini's 530 tokens a page); `maxRequests`, when `limits.requests` is set, is the read's own
|
|
1012
|
-
requests and a share of what the question has left of it
|
|
1251
|
+
requests and a share of what the question has left of it (for a `read_document` call, what the
|
|
1252
|
+
question has left of it with one request kept for the answer, one for the next turn, which would
|
|
1253
|
+
call a whole read, and those of the whole reads let through in this turn; 0 when the question
|
|
1254
|
+
would not start a whole read of the file on the next turn: since 0.10.0); `maxWaitMs` is 0 for the looks of a
|
|
1013
1255
|
tool turn after one of them was told the server is busy, so that a wait that ends busy comes once
|
|
1014
1256
|
in a turn. See
|
|
1015
1257
|
[Your own adapter and loop](../guides/own-adapter-and-loop.md).
|
|
@@ -1137,3 +1379,8 @@ text, and `view_pages` with its guide when the pages of a PDF can be looked at.
|
|
|
1137
1379
|
by group and paging; searching the bare form of a word) and the closing requests
|
|
1138
1380
|
([`FINAL_ANSWER_REQUEST`](./ask.md#final_answer_request) and the two others), so the cache misses
|
|
1139
1381
|
once after upgrading to it too, the same way.
|
|
1382
|
+
|
|
1383
|
+
0.10.0 changes the arguments of `analyze_whole_document` (`output` and `labels`; its description
|
|
1384
|
+
is 0.9.0's), so a chat where it is declared misses the cache once after the upgrade. The prompts of
|
|
1385
|
+
its part reads, merges and answer changed too: they reach the model that reads the parts, not the
|
|
1386
|
+
chat.
|