llm-large-files 0.7.0 → 0.8.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 +370 -1
- package/README.md +12 -8
- package/dist/aggregate.d.ts +103 -0
- package/dist/aggregate.d.ts.map +1 -0
- package/dist/aggregate.js +651 -0
- package/dist/aggregate.js.map +1 -0
- package/dist/analyze.d.ts +3 -1
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +109 -14
- package/dist/analyze.js.map +1 -1
- package/dist/anthropic/adapter.d.ts.map +1 -1
- package/dist/anthropic/adapter.js +4 -1
- package/dist/anthropic/adapter.js.map +1 -1
- package/dist/ask.d.ts +3 -3
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +72 -17
- package/dist/ask.js.map +1 -1
- package/dist/decode.d.ts +19 -0
- package/dist/decode.d.ts.map +1 -0
- package/dist/decode.js +97 -0
- package/dist/decode.js.map +1 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +65 -0
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +6 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +5 -1
- package/dist/events.js.map +1 -1
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +23 -0
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts +12 -18
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +82 -746
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +9 -5
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/endpoints.d.ts +5 -1
- package/dist/gemini/endpoints.d.ts.map +1 -1
- package/dist/gemini/endpoints.js +11 -2
- package/dist/gemini/endpoints.js.map +1 -1
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +20 -3
- package/dist/gemini/generate.js.map +1 -1
- package/dist/groups.d.ts +54 -0
- package/dist/groups.d.ts.map +1 -0
- package/dist/groups.js +136 -0
- package/dist/groups.js.map +1 -0
- package/dist/html.d.ts +11 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +1112 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +57 -14
- package/dist/library.js.map +1 -1
- package/dist/limiter.d.ts +2 -1
- package/dist/limiter.d.ts.map +1 -1
- package/dist/limiter.js +3 -2
- package/dist/limiter.js.map +1 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +8 -1
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +69 -15
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/ingest-child.d.ts +38 -0
- package/dist/node/ingest-child.d.ts.map +1 -0
- package/dist/node/ingest-child.js +42 -0
- package/dist/node/ingest-child.js.map +1 -0
- package/dist/node/isolated.d.ts +88 -0
- package/dist/node/isolated.d.ts.map +1 -0
- package/dist/node/isolated.js +381 -0
- package/dist/node/isolated.js.map +1 -0
- package/dist/office.d.ts +105 -0
- package/dist/office.d.ts.map +1 -0
- package/dist/office.js +1092 -0
- package/dist/office.js.map +1 -0
- package/dist/openai/adapter.d.ts.map +1 -1
- package/dist/openai/adapter.js +15 -1
- package/dist/openai/adapter.js.map +1 -1
- package/dist/pdf-pages.d.ts.map +1 -1
- package/dist/pdf-pages.js +2 -6
- package/dist/pdf-pages.js.map +1 -1
- package/dist/peers.d.ts +8 -0
- package/dist/peers.d.ts.map +1 -0
- package/dist/peers.js +32 -0
- package/dist/peers.js.map +1 -0
- package/dist/plan.d.ts +3 -1
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +17 -1
- package/dist/plan.js.map +1 -1
- package/dist/quality.d.ts +16 -0
- package/dist/quality.d.ts.map +1 -0
- package/dist/quality.js +157 -0
- package/dist/quality.js.map +1 -0
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +4 -2
- package/dist/ranged.js.map +1 -1
- package/dist/search.d.ts +99 -22
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +744 -140
- package/dist/search.js.map +1 -1
- package/dist/text-index.d.ts +3 -1
- package/dist/text-index.d.ts.map +1 -1
- package/dist/text-index.js +3 -1
- package/dist/text-index.js.map +1 -1
- package/dist/text.d.ts +27 -3
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +225 -23
- package/dist/text.js.map +1 -1
- package/dist/tools.d.ts +9 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +457 -16
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +23 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/word-styles.d.ts +102 -0
- package/dist/word-styles.d.ts.map +1 -0
- package/dist/word-styles.js +419 -0
- package/dist/word-styles.js.map +1 -0
- package/dist/xlsx.d.ts +23 -0
- package/dist/xlsx.d.ts.map +1 -0
- package/dist/xlsx.js +511 -0
- package/dist/xlsx.js.map +1 -0
- package/dist/xml-stream.d.ts +55 -0
- package/dist/xml-stream.d.ts.map +1 -0
- package/dist/xml-stream.js +235 -0
- package/dist/xml-stream.js.map +1 -0
- package/docs/README.md +8 -8
- package/docs/getting-started.md +1 -1
- package/docs/guides/costs-and-limits.md +7 -5
- package/docs/guides/deployment.md +95 -29
- package/docs/guides/errors-and-reliability.md +23 -10
- package/docs/guides/pdfs.md +127 -74
- package/docs/guides/storage.md +1 -1
- package/docs/guides/testing.md +5 -1
- package/docs/guides/web-app.md +10 -9
- package/docs/how-it-works.md +80 -50
- package/docs/reference/ask.md +26 -8
- package/docs/reference/errors-and-retries.md +5 -3
- package/docs/reference/events.md +14 -6
- package/docs/reference/gemini.md +6 -2
- package/docs/reference/library.md +221 -79
- package/docs/reference/node.md +201 -23
- package/docs/reference/openai.md +1 -1
- package/docs/reference/tools.md +269 -23
- package/docs/security.md +114 -69
- package/docs/troubleshooting.md +40 -20
- package/package.json +6 -2
- package/src/aggregate.ts +674 -0
- package/src/analyze.ts +117 -13
- package/src/anthropic/adapter.ts +4 -1
- package/src/ask.ts +73 -17
- package/src/decode.ts +89 -0
- package/src/errors.ts +108 -0
- package/src/events.ts +10 -1
- package/src/evidence.ts +23 -0
- package/src/extract.ts +79 -701
- package/src/gemini/adapter.ts +9 -5
- package/src/gemini/endpoints.ts +12 -2
- package/src/gemini/generate.ts +19 -3
- package/src/groups.ts +162 -0
- package/src/html.ts +1071 -0
- package/src/index.ts +2 -1
- package/src/library.ts +52 -14
- package/src/limiter.ts +6 -1
- package/src/model.ts +8 -1
- package/src/node/handlers.ts +66 -16
- package/src/node/index.ts +2 -0
- package/src/node/ingest-child.ts +61 -0
- package/src/node/isolated.ts +464 -0
- package/src/office.ts +1047 -0
- package/src/openai/adapter.ts +14 -1
- package/src/pdf-pages.ts +2 -5
- package/src/peers.ts +29 -0
- package/src/plan.ts +19 -1
- package/src/quality.ts +146 -0
- package/src/ranged.ts +4 -2
- package/src/search.ts +738 -146
- package/src/text-index.ts +4 -2
- package/src/text.ts +214 -23
- package/src/tools.ts +440 -16
- package/src/types.ts +20 -3
- package/src/word-styles.ts +420 -0
- package/src/xlsx.ts +478 -0
- package/src/xml-stream.ts +224 -0
package/docs/reference/tools.md
CHANGED
|
@@ -38,9 +38,10 @@ the [loop reference](./ask.md).
|
|
|
38
38
|
|
|
39
39
|
| Tool | What it does |
|
|
40
40
|
|---|---|
|
|
41
|
-
| `search_document` | Finds lines that contain a text or match a regex, with an exact count, the first of them and the last one; or the passages that match keywords best. |
|
|
41
|
+
| `search_document` | Finds lines that contain a text or match a regex, with an exact count, the first of them and the last one, the last ones, or a count for each group (hour, code, message shape); or the passages that match keywords best. In all of a file or in a range of its lines. |
|
|
42
42
|
| `read_document` | Reads a range of lines, numbered, up to 600 a call. |
|
|
43
43
|
| `get_document_overview` | The outline, the log profile, the first 30 and last 20 lines, and what a whole-file read would take. |
|
|
44
|
+
| `aggregate_table` | Counts, sums, averages, minimums and maximums over the rows of a table (a CSV file, a sheet of a workbook, a `\| cell \|` table), with filters and groups, reading every row. New in 0.8.1. |
|
|
44
45
|
| `analyze_whole_document` | Reads the whole file in parts with other model calls (map-reduce) and answers a task that needs all of it. |
|
|
45
46
|
| `view_pages` | Up to 5 pages of a PDF, cut out of the uploaded file, as one small PDF the model looks at. |
|
|
46
47
|
|
|
@@ -57,6 +58,8 @@ In [askWithFiles(options)](./ask.md#askwithfilesoptions) (and `askGemini`, which
|
|
|
57
58
|
- `search_document`, `read_document` and `get_document_overview` are offered when at least one
|
|
58
59
|
document is too large for the prompt (`plan.searchable`). They reach only those documents: a
|
|
59
60
|
document whose text is in the prompt is not searched.
|
|
61
|
+
- `aggregate_table` is offered with them when at least one searchable document may hold a table:
|
|
62
|
+
its format is `csv`, `xlsx`, `docx`, `pptx`, `pdf`, `html` or `markdown`. New in 0.8.1.
|
|
60
63
|
- `analyze_whole_document` is offered with them when all of these hold: the model that explores
|
|
61
64
|
(the explorer, or else the model) has `generateText`, `wholeDocumentAnalysis` is not `false`, and
|
|
62
65
|
at least one searchable document is estimated, from its metadata, to need no more than
|
|
@@ -76,6 +79,9 @@ Through `files.tools(documents, options)` (a loop of your own, see [`ToolSet`](#
|
|
|
76
79
|
- The three text tools are declared unless `documents` is empty and there are PDFs to look at.
|
|
77
80
|
With no documents and no PDFs they are still declared, and every call answers that no attached
|
|
78
81
|
file is read with this tool.
|
|
82
|
+
- `aggregate_table` is declared when at least one of `documents` may hold a table (the formats
|
|
83
|
+
above); a call of it is answered for any document, with "This file has no table to aggregate"
|
|
84
|
+
when it has none.
|
|
79
85
|
- `analyze_whole_document` is declared when `options.generate` is given and at least one of
|
|
80
86
|
`documents` is estimated within `maxMapChunks` parts (5% leeway). With `generate` and no such
|
|
81
87
|
document it is not declared, but a call of it is still answered, with the reason. Without
|
|
@@ -92,7 +98,10 @@ whole numbers; a value that is neither a number nor a numeric string takes the d
|
|
|
92
98
|
blank string counts as 0, so it is clamped to the minimum); line numbers and counts out of range
|
|
93
99
|
are clamped, not refused. Page numbers are the exception: `view_pages` refuses a page that is not a
|
|
94
100
|
number of 1 or more. A `mode` other than `"exact"` or `"regex"` is `"keywords"`, and
|
|
95
|
-
`case_sensitive`
|
|
101
|
+
`case_sensitive` and `whole_word` are on only when they are `true`, `1`, or the same as text
|
|
102
|
+
(`"true"` in any case, or `"1"`), and off for any other value. Until 0.8.0, `case_sensitive: "true"`
|
|
103
|
+
was off. An `order` other than `"last"` is `"first"`. A `group_by` that is missing, `null`, `""` or `"none"` counts no groups; any other
|
|
104
|
+
value that is not one of its five is refused.
|
|
96
105
|
|
|
97
106
|
**Scope.** A call reaches only the documents its tool set was made for. A `document_id` outside
|
|
98
107
|
them is refused with the IDs the model may use, so that the next call is right (`view_pages`
|
|
@@ -131,7 +140,9 @@ lower the cap of one call with [`ToolCallLimits.maxResultCharacters`](#toolcalll
|
|
|
131
140
|
not known. Showing K of N results to stay within the size limit. Narrow the query or read
|
|
132
141
|
specific lines."
|
|
133
142
|
- An exact or regex search that read the whole file and has 2 matches or more is cut its own way:
|
|
134
|
-
it loses matches from the end of the first ones, and keeps the last one
|
|
143
|
+
it loses matches from the end of the first ones, and keeps the last one. With `order: "last"` it
|
|
144
|
+
loses the earliest of the last ones, and keeps the very last; with `group_by` it loses the
|
|
145
|
+
smallest groups, and keeps at least one, and by time the groups it keeps stay in time order (see
|
|
135
146
|
[`search_document`](#search_document)).
|
|
136
147
|
- When even one entry is too large, the result becomes
|
|
137
148
|
`{ "truncated": true, "partial": "<the start of the result as JSON text>", "note": "Result cut to the size limit. Ask for a smaller range." }`.
|
|
@@ -150,28 +161,57 @@ The description the model sees:
|
|
|
150
161
|
|
|
151
162
|
> Search a large attached file. mode "keywords" returns the most relevant passages for a question;
|
|
152
163
|
> "exact" finds the lines that contain the text; "regex" finds the lines that match a JavaScript
|
|
153
|
-
> regular expression
|
|
154
|
-
>
|
|
155
|
-
>
|
|
164
|
+
> regular expression (\w and \b know the letters of every language). For exact and regex,
|
|
165
|
+
> total_matching_lines counts every matching line, and the result shows the first max_results of
|
|
166
|
+
> them and the last one; search again from next_from_line for the ones after those shown, or with
|
|
167
|
+
> order "last" for the last ones. To count by group (per hour or day, per error code, per message
|
|
168
|
+
> shape), pass group_by: the result then counts each group, and shows no lines. from_line and
|
|
169
|
+
> to_line search part of the file. Results include line numbers to read further with read_document.
|
|
156
170
|
|
|
157
171
|
Until 0.6.0 it said that `exact` "returns every line containing the text", while the result showed
|
|
158
172
|
the first lines only: a model asked when something last happened named the last line it was shown.
|
|
173
|
+
0.8.0 added `from_line`, `to_line`, `order`, `group_by` and `whole_word`, and the sentences that
|
|
174
|
+
name them.
|
|
159
175
|
|
|
160
176
|
| Argument | Type | Required | Default and limits | Meaning |
|
|
161
177
|
|---|---|---|---|---|
|
|
162
178
|
| `document_id` | string | yes | | The `document_id` from the file's card. |
|
|
163
179
|
| `query` | string | yes | Not blank (`query is required.`) | Keywords, exact text, or a regex, by `mode`. |
|
|
164
180
|
| `mode` | `"keywords"` \| `"exact"` \| `"regex"` | no | `"keywords"` | How to search. |
|
|
165
|
-
| `max_results` | integer | no | keywords: 5, from 1 to 10. exact and regex: 20, from 1 to 50 | Passages,
|
|
166
|
-
| `context_lines` | integer | no | 0, from 0 to 5 | exact and regex: lines shown before and after each match. |
|
|
181
|
+
| `max_results` | integer | no | keywords: 5, from 1 to 10. exact and regex: 20, from 1 to 50. With `group_by`: 50 groups, from 1 to 200 | Passages, matching lines or groups returned. It does not limit the count. exact and regex also show the last matching line after them, when it is not among them. |
|
|
182
|
+
| `context_lines` | integer | no | 0, from 0 to 5 | exact and regex: lines shown before and after each match. None with `group_by`. |
|
|
167
183
|
| `case_sensitive` | boolean | no | `false` | exact and regex: match case. Keywords never do. |
|
|
184
|
+
| `from_line` | integer | no | 1. Past the last line: refused | Search only from this line on, in every mode. Pass a result's `next_from_line` to see the matches after those it shows. New in 0.8.0. |
|
|
185
|
+
| `to_line` | integer | no | The last line. Past it: the last line. Before `from_line`: refused | Search only up to this line, in every mode. New in 0.8.0. |
|
|
186
|
+
| `order` | `"first"` \| `"last"` | no | `"first"` | exact and regex: `"last"` shows the last `max_results` matching lines, in file order, in place of the first ones. New in 0.8.0. |
|
|
187
|
+
| `group_by` | `"capture"` \| `"minute"` \| `"hour"` \| `"day"` \| `"shape"` | no | none | exact and regex: count the matching lines by group, and show none ([below](#counts-by-group-group_by)). `"capture"` needs mode `regex`. `order` and `context_lines` are ignored with it. New in 0.8.0. |
|
|
188
|
+
| `whole_word` | boolean | no | `false` | exact only: match the text only as a whole word, not inside a longer one. Ignored in regex mode, where `\b` does it. New in 0.8.0. |
|
|
189
|
+
|
|
190
|
+
With `from_line` or `to_line`, the counts are of the lines searched, and the result says which in
|
|
191
|
+
`searched_lines` (`"1941-3000"`). In keywords mode, the passages ranked are those with at least one
|
|
192
|
+
line in the range, each with all its lines. The errors of these arguments:
|
|
193
|
+
|
|
194
|
+
| Error | When |
|
|
195
|
+
|---|---|
|
|
196
|
+
| `from_line 9000 is past the end of the file, which has 3000 lines.` | `from_line` is past the last line. |
|
|
197
|
+
| `to_line 20 is before from_line 100.` | `to_line` is before `from_line` (1 when it is not given). |
|
|
198
|
+
| `group_by counts the lines of an exact or regex search: use mode "exact" or "regex".` | `group_by` in keywords mode. |
|
|
199
|
+
| `group_by "capture" counts by the first group of a regex: use mode "regex" with a group, as in PAY-(\d+).` | `group_by: "capture"` in exact mode. |
|
|
200
|
+
| `group_by must be one of "capture", "minute", "hour", "day", "shape".` | Any other `group_by`. |
|
|
168
201
|
|
|
169
202
|
**`keywords`** ranks passages with BM25, computed at query time from substring hits: no index, any
|
|
170
203
|
language.
|
|
171
204
|
|
|
172
|
-
- The query is
|
|
173
|
-
|
|
174
|
-
|
|
205
|
+
- The query is composed (NFC) and folded as exact search folds it (see below), then split at
|
|
206
|
+
anything that is not a letter, a mark, a digit or `_`, so a mark stays with its letter (Hindi,
|
|
207
|
+
Bengali, Tamil, Thai, pointed Hebrew). A run of Chinese, Japanese, Thai, Lao, Khmer or Myanmar
|
|
208
|
+
text is split into words with `Intl.Segmenter`. Terms of fewer than 2 characters (a Han or kana
|
|
209
|
+
word may have one) and common English and Hebrew words are dropped; at most 12 distinct terms are
|
|
210
|
+
kept. A term also matches inside longer words: "timeout" matches "timeouts".
|
|
211
|
+
- A Hebrew term loses its points. One that starts with prefix letters (ו ה ב כ ל מ ש: בחוזה,
|
|
212
|
+
והחוזה) also searches its stem without them (חוזה), up to three letters off while three are
|
|
213
|
+
left, so passages with the word as written rank first. One that ends in a final letter also
|
|
214
|
+
matches its plain form, as inside a longer word: כסף finds כספים. New in 0.8.0.
|
|
175
215
|
- A passage is a run of whole lines of about 1,500 characters, or 40 lines at most. A passage that
|
|
176
216
|
contains the whole query as a phrase (more than one term, up to 200 characters) is ranked higher.
|
|
177
217
|
- Passages come best first. `score` is rounded to two decimals and only orders the results.
|
|
@@ -179,18 +219,28 @@ language.
|
|
|
179
219
|
these keywords. Try other words, synonyms, or exact mode."
|
|
180
220
|
|
|
181
221
|
**`exact`** finds every line that contains the text. A line counts once, however many times it
|
|
182
|
-
contains the text. A text with a line break matches across lines and counts on
|
|
183
|
-
starts
|
|
222
|
+
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). The scan
|
|
224
|
+
stops after 1,000,000 matching lines, and with `whole_word` or `group_by` after 3 seconds. The query is composed (NFC), as the text is at ingest, so
|
|
225
|
+
"é" typed as "e" and an accent finds "é". Without `case_sensitive`, both sides are folded: lower
|
|
226
|
+
case, Greek final sigma as σ, curly quotes and primes as `'` and `"`, dashes and the minus sign as
|
|
227
|
+
`-`, no-break and thin spaces as a space, Hebrew geresh, gershayim and maqaf as `'`, `"` and `-`,
|
|
228
|
+
and full-width forms as ASCII. So "don't" finds "don’t", and צה"ל finds צה״ל (new in 0.8.0). With
|
|
229
|
+
`whole_word`, a match must not touch a letter, mark, digit or `_` of any script where the text
|
|
230
|
+
starts or ends with one.
|
|
184
231
|
|
|
185
232
|
**`regex`** tests a JavaScript regular expression against each line on its own, so a match cannot
|
|
186
233
|
span lines. It runs with the `i` flag unless `case_sensitive` is `true`, and with the `u` flag when
|
|
187
234
|
the pattern is valid with it (so `\p{L}` means a letter); a pattern valid only without it, such as
|
|
188
|
-
`[\w-.]`, runs without it.
|
|
235
|
+
`[\w-.]`, runs without it. With the `u` flag, `\w`, `\W`, `\b` and `\B` know the letters, marks and
|
|
236
|
+
digits of every script: `\bחוזה\b` finds the word, and `\w+` does not stop at "é" (new in 0.8.0;
|
|
237
|
+
a pattern with `\W` inside a class is run as written). The pattern is composed (NFC) first. The
|
|
238
|
+
folds of exact search do not apply. Limits:
|
|
189
239
|
|
|
190
240
|
| Limit | Value | When it is reached |
|
|
191
241
|
|---|---|---|
|
|
192
242
|
| Pattern length | 300 characters | Refused: `Regex is longer than 300 characters.` |
|
|
193
|
-
| Nested quantifier, such as `(a+)+` | Refused up front | `Regex has a nested quantifier like (a+)+, which can hang on large files. Simplify it.` |
|
|
243
|
+
| Nested quantifier, such as `(a+)+` | Refused up front, unless each repeat ends at a literal character that none of its quantified parts can match, as in `(\d{1,3}\.){3}\d{1,3}` or `(\w+\.)+com` (accepted since 0.8.0) | `Regex has a nested quantifier like (a+)+, which can hang on large files. Simplify it.` |
|
|
194
244
|
| Invalid pattern | | `Invalid regex: ` and the engine's message. |
|
|
195
245
|
| One search | 3,000 ms of matching, or what is left of the tool set's time when that is less | The scan stops; the result has the lines found so far and the note below. |
|
|
196
246
|
| A line the pattern cannot get past | Two whole slices of 250 ms on the same line | The scan stops there, the same way. |
|
|
@@ -206,11 +256,16 @@ Results of `exact` and `regex`:
|
|
|
206
256
|
|---|---|---|
|
|
207
257
|
| `document` | string | The file name. |
|
|
208
258
|
| `mode` | `"exact"` \| `"regex"` | The mode that ran. |
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
259
|
+
| `searched_lines` | string, optional | With `from_line` or `to_line`: the lines searched, as `"1941-3000"`. The counts are of those lines. Keyword results have it too. New in 0.8.0. |
|
|
260
|
+
| `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
|
+
| `order` | `"last"`, optional | With `order: "last"` ([below](#the-last-matches-order-last)). |
|
|
262
|
+
| `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. |
|
|
264
|
+
| `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
|
+
| `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. |
|
|
212
266
|
| `matches[].line` | number | The line number. |
|
|
213
267
|
| `matches[].page` | number, optional | The page of the line, for a PDF whose pages can be shown. |
|
|
268
|
+
| `matches[].section` | string, optional | The heading of the outline above the line, up to 80 characters: "2.1 Rent", "Sheet 2: Sales". Absent for logs, JSON and CSV files, and for a document with no outline. New in 0.8.1. |
|
|
214
269
|
| `matches[].text` | string | The line. A line longer than 400 characters is cut to 400 around the match, with `…` where it was cut. |
|
|
215
270
|
| `matches[].before`, `matches[].after` | string[], optional | With `context_lines` above 0: the lines around the match, as `"1202\| text"`, each cut to 400 characters. |
|
|
216
271
|
|
|
@@ -221,7 +276,8 @@ A search with `max_results: 1` and `context_lines: 1`:
|
|
|
221
276
|
"document": "app.log",
|
|
222
277
|
"mode": "exact",
|
|
223
278
|
"total_matching_lines": 51,
|
|
224
|
-
"note": "2 of the 51 matching lines are shown: the first and the last (line 4987). To see the ones in between,
|
|
279
|
+
"note": "2 of the 51 matching lines are shown: the first and the last (line 4987). To see the ones in between, search again with from_line 1204, or count them with group_by.",
|
|
280
|
+
"next_from_line": 1204,
|
|
225
281
|
"matches": [
|
|
226
282
|
{
|
|
227
283
|
"line": 1203,
|
|
@@ -244,7 +300,8 @@ has 2 matches or more loses matches from the end of the first ones, and keeps th
|
|
|
244
300
|
note is then one of:
|
|
245
301
|
|
|
246
302
|
- "Showing N of the M matching lines to stay within the size limit: the first K and the last (line
|
|
247
|
-
L).
|
|
303
|
+
L). To see the ones in between, search again with from_line F, or count them with group_by."
|
|
304
|
+
(N is K + 1; "the first and the last" when K is 1), with `next_from_line` F;
|
|
248
305
|
- "Showing 1 of the M matching lines to stay within the size limit: the last (line L). Narrow the
|
|
249
306
|
query or read specific lines.", when only the last one fits;
|
|
250
307
|
- "Showing 1 of the M matching lines: the last (line L). Narrow the search.", when the last one
|
|
@@ -255,12 +312,99 @@ When not even that fits, the result is cut as text, as any other (see
|
|
|
255
312
|
"Showing " marks a result that was cut: a call made again runs again. A result with the note "N of
|
|
256
313
|
the M matching lines are shown" is whole, and a call made again gets a pointer to it.
|
|
257
314
|
|
|
315
|
+
### The last matches: `order: "last"`
|
|
316
|
+
|
|
317
|
+
New in 0.8.0. With `order: "last"`, an exact or regex search shows the last `max_results` matching
|
|
318
|
+
lines, in file order, and no others: unlike a search in the default order, it adds no match from
|
|
319
|
+
the other end of the file. When not every match is shown, the note names the line of the last
|
|
320
|
+
match and of the first. A search with `max_results: 2`:
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{
|
|
324
|
+
"document": "app.log",
|
|
325
|
+
"mode": "exact",
|
|
326
|
+
"total_matching_lines": 51,
|
|
327
|
+
"order": "last",
|
|
328
|
+
"note": "These are the last 2 of the 51 matching lines, in the order of the file: the last match is on line 4987, and the first on line 1203.",
|
|
329
|
+
"matches": [
|
|
330
|
+
{ "line": 4410, "text": "2026-05-01 13:12:30 ERROR payment-service: timeout after 4410ms calling ledger" },
|
|
331
|
+
{ "line": 4987, "text": "2026-05-01 13:22:47 ERROR payment-service: timeout after 4987ms calling ledger" }
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
To fit its room, it loses the earliest of them first, and keeps the very last. The note is then
|
|
337
|
+
"Showing the last N of the M matching lines to stay within the size limit, in the order of the
|
|
338
|
+
file: the last match is on line L, and the first on line F. Narrow the query or read specific
|
|
339
|
+
lines."
|
|
340
|
+
|
|
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
|
|
342
|
+
those it found, and the line of the first match is not named. The note is then "The scan stopped
|
|
343
|
+
early; the total is a lower bound. These are the last N matching lines it found, in the order of
|
|
344
|
+
the file. There may be later ones, after line L: search again with from_line F." (F is L + 1;
|
|
345
|
+
" and to_line T" follows it when the call gave `to_line`, T being the last line searched). Cut to
|
|
346
|
+
its room, the second sentence is "Showing the last N matching lines it found to stay within the
|
|
347
|
+
size limit, in the order of the file." When L is the last line searched, the last sentence is left
|
|
348
|
+
out. When the scan found no matching line before it stopped (a regex out of time), the note is
|
|
349
|
+
"The scan stopped early, out of time, before it found a matching line: the lines it did not reach
|
|
350
|
+
may have some. Try a simpler pattern, mode "exact", or fewer lines with from_line and to_line."
|
|
351
|
+
Like every note that starts with "The scan stopped early", it marks a result that a call made
|
|
352
|
+
again runs again: a later question has time of its own.
|
|
353
|
+
|
|
354
|
+
### Counts by group: `group_by`
|
|
355
|
+
|
|
356
|
+
New in 0.8.0. With `group_by`, an exact or regex search counts its matching lines by group, and
|
|
357
|
+
shows no line. One call answers "how many errors per hour" or "which codes, how often":
|
|
358
|
+
|
|
359
|
+
| `group_by` | The key of a line |
|
|
360
|
+
|---|---|
|
|
361
|
+
| `"capture"` | The text of the regex's first group: `PAY-(\d+)` counts each code. A line where that group took no part has no key. Regex mode only. |
|
|
362
|
+
| `"minute"`, `"hour"`, `"day"` | The first timestamp on the line, as written there (an offset such as `+02:00` or `Z` is not applied): `"2026-11-10 14:03"`, `"2026-11-10 14:00"`, `"2026-11-10"`. Read: ISO 8601 (`2026-11-10T14:03:17Z`, `2026-11-10 14:03:17,123`), nginx's error log (`2026/11/10 14:03:17`), the access logs of Apache and nginx (`10/Nov/2026:14:03:17 +0000`), epoch times in a JSON field `time`, `ts`, `timestamp` or `@timestamp` (10 or 13 digits, as UTC), `10.11.2026 14:03` (day first), `10/11/2026 14:03` (kept as `"10/11/2026"`, since day and month cannot be told apart), syslog (`Nov 10 14:03:17`) and klog (`I1110 14:03:17.123456`), the last two without a year (`"11-10 14:00"`). A line without one has no key. |
|
|
363
|
+
| `"shape"` | The line with its timestamp taken out, and its UUIDs, IP addresses, hex, quoted values and numbers replaced by `<id>`, `<ip>`, `<hex>`, `<s>` and `<n>`, as the log profile groups problems. |
|
|
364
|
+
|
|
365
|
+
Keys are cut at 120 characters. At most 10,000 groups are counted one by one; the lines of further
|
|
366
|
+
groups are counted together in `other_count`. Results, besides `document`, `mode`, `searched_lines`
|
|
367
|
+
and `total_matching_lines`:
|
|
368
|
+
|
|
369
|
+
| Field | Type | Meaning |
|
|
370
|
+
|---|---|---|
|
|
371
|
+
| `group_by` | string | The grouping that ran. |
|
|
372
|
+
| `total_groups` | number | The groups counted, at most 10,000. |
|
|
373
|
+
| `other_count` | number, optional | Matching lines of groups past the first 10,000, with `other_note`: "Lines of groups past the first 10,000 found." |
|
|
374
|
+
| `lines_without_group` | number, optional | Matching lines with no key: no timestamp, or a regex group that took no part. |
|
|
375
|
+
| `note` | string, optional | When not every group is shown: "K of the N groups are shown, the largest first. Narrow the search, or use from_line and to_line, for the others." By time, "the largest, in time order". A result cut to its room says "Showing K of the N groups to stay within the size limit, …". After the note of a scan that stopped early, when there is one. |
|
|
376
|
+
| `groups` | array | Up to `max_results` groups (50 by default, 200 at most). By `capture` and `shape`, the largest first. By time, in time order; when there are more groups than are shown, the largest of them, in time order. A result cut to its room keeps the largest groups as well: by `capture` and `shape` it loses the end of its list, and by time the smallest groups, keeping the others in time order. |
|
|
377
|
+
| `groups[].key` | string | The group. |
|
|
378
|
+
| `groups[].count` | number | Its matching lines. |
|
|
379
|
+
| `groups[].first_line`, `groups[].last_line` | number | Its first and last matching line, to read with `read_document`. |
|
|
380
|
+
|
|
381
|
+
A search for `PAY-5031` with `group_by: "hour"`:
|
|
382
|
+
|
|
383
|
+
```json
|
|
384
|
+
{
|
|
385
|
+
"document": "payments.log",
|
|
386
|
+
"mode": "exact",
|
|
387
|
+
"total_matching_lines": 214,
|
|
388
|
+
"group_by": "hour",
|
|
389
|
+
"total_groups": 3,
|
|
390
|
+
"groups": [
|
|
391
|
+
{ "key": "2026-11-10 13:00", "count": 9, "first_line": 40211, "last_line": 41876 },
|
|
392
|
+
{ "key": "2026-11-10 14:00", "count": 187, "first_line": 42003, "last_line": 47950 },
|
|
393
|
+
{ "key": "2026-11-10 15:00", "count": 18, "first_line": 48012, "last_line": 48990 }
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Its step reads `Search payments.log (exact) for “PAY-5031”, counted by hour — 214 matching lines in
|
|
399
|
+
3 groups`.
|
|
400
|
+
|
|
258
401
|
Results of `keywords`:
|
|
259
402
|
|
|
260
403
|
| Field | Type | Meaning |
|
|
261
404
|
|---|---|---|
|
|
262
405
|
| `document` | string | The file name. |
|
|
263
406
|
| `mode` | `"keywords"` | |
|
|
407
|
+
| `searched_lines` | string, optional | With `from_line` or `to_line`: the lines searched, as `"1941-3000"`. New in 0.8.0. |
|
|
264
408
|
| `passages` | array | The best passages, best first. |
|
|
265
409
|
| `passages[].lines` | string | `"412-436"`: the passage's first and last line. |
|
|
266
410
|
| `passages[].pages` | string, optional | `"37"` or `"37-38"`, for a PDF whose pages can be shown. |
|
|
@@ -268,6 +412,92 @@ Results of `keywords`:
|
|
|
268
412
|
| `passages[].text` | string | The passage's lines, numbered (`"412\| text"`), one a line. |
|
|
269
413
|
| `note` | string, optional | The no-passage note, or the size-limit note. |
|
|
270
414
|
|
|
415
|
+
## `aggregate_table`
|
|
416
|
+
|
|
417
|
+
New in 0.8.1. Counts, sums, averages, minimums and maximums over the rows of one table of a
|
|
418
|
+
document, with filters and groups, exactly: it reads every row once, and runs no code. A model that
|
|
419
|
+
adds up thousands of rows by reading them needs hundreds of calls and gets it wrong; this answers
|
|
420
|
+
in one. Its description, as the model sees it:
|
|
421
|
+
|
|
422
|
+
> Count, sum, average, or find the minimum or maximum over the rows of a table in an attached file:
|
|
423
|
+
> a CSV or TSV file, a sheet of an Excel workbook, or a table written as | cell | rows (in Word,
|
|
424
|
+
> PowerPoint, PDF or HTML files). It can keep only the rows that match filters, and group them by up
|
|
425
|
+
> to 3 columns (a date column by year, month or day). Its numbers are exact, as it reads every row:
|
|
426
|
+
> use it instead of reading rows to add them up or count them. Columns are named as in the table's
|
|
427
|
+
> header row; a letter (C) or a number (3) works too. Each group lists the lines of its first rows,
|
|
428
|
+
> to cite.
|
|
429
|
+
|
|
430
|
+
| Argument | Type | Required | Default | Meaning |
|
|
431
|
+
|---|---|---|---|---|
|
|
432
|
+
| `document_id` | string | yes | | The document. |
|
|
433
|
+
| `table` | string | no | the first | A sheet's name or number in a workbook; a table's number in other files (1 is the first `\| cell \|` table). |
|
|
434
|
+
| `metrics` | string[] | no | `["count"]` | `"count"`, or an operation and a column: `"sum:Revenue"`, `"avg:Price"`, `"min:Date"`, `"max:Amount"`, `"count_distinct:Customer"`. |
|
|
435
|
+
| `group_by` | string[] | no | none | Up to 3 columns. A column of ISO dates may end in `:year`, `:month` or `:day` (`"Date:month"` groups 2026-03-14 under 2026-03). |
|
|
436
|
+
| `filters` | `{ column, op, value }[]` | no | none | Rows kept: all must match. `op` is `=`, `!=`, `>`, `>=`, `<`, `<=`, `contains`, `not_contains`, `starts_with`, `empty` or `not_empty`. Two numbers compare as numbers, ISO dates and other text as text, ignoring case; a cell that is not a number is neither more nor less than a number. |
|
|
437
|
+
| `order_by` | `"metric"` \| `"key"` | no | `"metric"` | The largest value of the first metric first, or the groups by their values, in order (months in time order). |
|
|
438
|
+
| `limit` | integer | no | 50 | Groups shown, 1 to 200. |
|
|
439
|
+
| `header_rows` | integer | no | found | The rows of the header, 0 to 5, below a title row. Leave it out: the header is found (below). |
|
|
440
|
+
|
|
441
|
+
The tables it reads:
|
|
442
|
+
|
|
443
|
+
- **A CSV or TSV file:** the whole file. The separator is found from the first lines (comma,
|
|
444
|
+
semicolon, tab or `|`); quoted fields may hold separators, quotes and line breaks. Its first line
|
|
445
|
+
is the header, or its second when the first holds one value only (a title).
|
|
446
|
+
- **A sheet of a workbook**, as the XLSX extractor writes it (`Row 7: | a | b |`). Its header is
|
|
447
|
+
the rows above its first row with a number, up to 3, joined column by column with " / " ("Q1 /
|
|
448
|
+
January"), a header cell left empty by a merged cell taking the one to its left; a year (1900 to
|
|
449
|
+
2100) in a header row is a name. A first row with one value over rows of more is a title, left
|
|
450
|
+
out. A first row of numbers means no header: the columns are named by their letters.
|
|
451
|
+
- **A `| cell |` table** of a DOCX, PPTX, PDF, HTML or Markdown file: a run of such lines, numbered
|
|
452
|
+
in the order of the file. Its header is found as for a sheet; a Markdown separator row is
|
|
453
|
+
skipped, and a row the same as the header, found again inside the table (a PDF repeats it on each
|
|
454
|
+
page), is not a row.
|
|
455
|
+
|
|
456
|
+
A column is named as in the header (case and spaces ignored), by its letter (`C`) or number (`3`),
|
|
457
|
+
or by the lower part of a joined header ("הכנסות" for "פברואר / הכנסות") when only one column has
|
|
458
|
+
it. Numbers are read as people write them: `1,234.5`, `-12`, `(1,200)` for a negative, `₪4,750`,
|
|
459
|
+
`$ 12.00`, `12%` (12), `1 234`, `12,5` (a decimal comma), `1.234,56`. A sum or average leaves out
|
|
460
|
+
cells that are not numbers, and says how many (`values_not_numbers`); `min` and `max` of ISO dates
|
|
461
|
+
compare them as text. Up to 10,000 groups are counted one by one; rows of further groups are
|
|
462
|
+
counted in `other_rows`.
|
|
463
|
+
|
|
464
|
+
Result:
|
|
465
|
+
|
|
466
|
+
| Field | Type | Meaning |
|
|
467
|
+
|---|---|---|
|
|
468
|
+
| `document` | string | The file name. |
|
|
469
|
+
| `table` | string | The table read: "the CSV file", "Sheet 2: Sales", "table 3 of 5". |
|
|
470
|
+
| `tables_in_file` | number, optional | Sheets or tables in the file, when more than one. |
|
|
471
|
+
| `header_line` | number | The line of the header's last row (0 with no header). |
|
|
472
|
+
| `header_rows`, `title` | optional | The header's rows, when not one, and a title row left out. |
|
|
473
|
+
| `columns` | string[] | The column names, up to 60. |
|
|
474
|
+
| `rows_read`, `rows_matched` | number | The table's rows, and those the filters kept. |
|
|
475
|
+
| `total_groups` | number, optional | Groups found, with `group_by`. |
|
|
476
|
+
| `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
|
+
| `note` | string, optional | "N of the M groups are shown…", when `limit` cut them. |
|
|
478
|
+
| `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
|
+
|
|
480
|
+
```json
|
|
481
|
+
{
|
|
482
|
+
"document": "orders-2026.csv",
|
|
483
|
+
"table": "the CSV file",
|
|
484
|
+
"header_line": 1,
|
|
485
|
+
"columns": ["OrderId", "Date", "Region", "Product", "Amount"],
|
|
486
|
+
"rows_read": 5000,
|
|
487
|
+
"rows_matched": 1250,
|
|
488
|
+
"total_groups": 5,
|
|
489
|
+
"groups": [
|
|
490
|
+
{ "group": { "Region": "Center" }, "avg:Amount": 535.27, "rows": 250, "lines": [5, 10, 15] },
|
|
491
|
+
{ "group": { "Region": "East" }, "avg:Amount": 530.85, "rows": 250, "lines": [3, 8, 13] }
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Errors say what to change: "No column \"Profit\" in this table. Its columns are: …", "\"הכנסות\"
|
|
497
|
+
names 3 columns of this table: …. Name one of them in full.", "No table \"Budget\" in this file: it
|
|
498
|
+
has 3 sheets…", "This file has no table to aggregate…". `evidence` cites the header line and each
|
|
499
|
+
group's lines; a result dropped to make room keeps its largest 30 groups.
|
|
500
|
+
|
|
271
501
|
## `read_document`
|
|
272
502
|
|
|
273
503
|
The description the model sees:
|
|
@@ -484,6 +714,16 @@ your own adds it to its system prompt). In short, it tells the model:
|
|
|
484
714
|
- what each text tool is for, and this rule: "To count or list what can be matched as text (a word,
|
|
485
715
|
an ID, an error code, a log level, a pattern), use search_document in exact or regex mode: its
|
|
486
716
|
total_matching_lines is exact.";
|
|
717
|
+
- since 0.8.0, how to count by group and see the rest of a list: "To count per group (per hour or
|
|
718
|
+
day, per error code or ID with a regex group, per message shape), pass group_by: one call gives
|
|
719
|
+
every count. For more matches than a result shows, search again from its next_from_line, or with
|
|
720
|
+
order "last" for the last ones.";
|
|
721
|
+
- since 0.8.0, what to search for: "Search for the bare form of a word: a search matches inside
|
|
722
|
+
longer words, so "timeout" also finds "timeouts", and a Hebrew word without its prefix letters
|
|
723
|
+
(חוזה, not בחוזה) finds every form of it.";
|
|
724
|
+
- since 0.8.1, when a searchable file may hold a table: "To add up, average, count or group the
|
|
725
|
+
rows of a table (a CSV, an Excel sheet, a | cell | table), use aggregate_table: it reads every
|
|
726
|
+
row, and its numbers are exact. Do not add numbers up from rows you read.";
|
|
487
727
|
- to read around search hits before relying on them;
|
|
488
728
|
- to use `analyze_whole_document` only when the task needs all of the file and cannot be done by
|
|
489
729
|
matching text (a full summary, a timeline, items judged by meaning), and that it is slow, costly,
|
|
@@ -595,7 +835,7 @@ has no option for it.
|
|
|
595
835
|
|
|
596
836
|
### `TOOL_NAMES`
|
|
597
837
|
|
|
598
|
-
The names of the
|
|
838
|
+
The names of the six tools, as constants.
|
|
599
839
|
|
|
600
840
|
```ts
|
|
601
841
|
const TOOL_NAMES = {
|
|
@@ -604,6 +844,7 @@ const TOOL_NAMES = {
|
|
|
604
844
|
overview: "get_document_overview",
|
|
605
845
|
analyze: "analyze_whole_document",
|
|
606
846
|
view: "view_pages",
|
|
847
|
+
aggregate: "aggregate_table", // new in 0.8.1
|
|
607
848
|
} as const;
|
|
608
849
|
```
|
|
609
850
|
|
|
@@ -640,7 +881,7 @@ throws.
|
|
|
640
881
|
| The result has | The suffix |
|
|
641
882
|
|---|---|
|
|
642
883
|
| `error` | ` — failed:` and the error, as in ` — failed: Unknown tool “do_magic”.` |
|
|
643
|
-
| `total_matching_lines` (exact, regex) | ` — 1,203 matching lines` (numbers in en-US form), ` — 1 matching line` for one |
|
|
884
|
+
| `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 |
|
|
644
885
|
| `passages` (keywords) | ` — 5 passages`, ` — 1 passage` for one |
|
|
645
886
|
| `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` or `answer_cut_short` |
|
|
646
887
|
| `lines` and `total_lines` (read) | ` — got 1200-1342` when the label does not end with the lines shown, else `""` |
|
|
@@ -682,7 +923,7 @@ type ToolSet = {
|
|
|
682
923
|
| `has(name)` | `true` for each declared tool. Also `true` for `analyze_whole_document` when `generate` was given and the text tools are declared, even if it is not declared because no document is small enough: a call then gets the reason. Use it to tell the calls of this tool set from others. |
|
|
683
924
|
| `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. |
|
|
684
925
|
| `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. Only `analyze_whole_document` calls them. |
|
|
685
|
-
| `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), `Read app.log lines 1200-1260` (`-1260` only when `end_line` is a number not below `start_line`), `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. |
|
|
926
|
+
| `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` is a number not below `start_line`), `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. |
|
|
686
927
|
| `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 any other name. What a loop sets aside in its request before it runs a call. |
|
|
687
928
|
|
|
688
929
|
`execute` and `executeWithFiles` throw only when the tool set's `signal` was aborted: the error
|
|
@@ -881,3 +1122,8 @@ a question with files to search, that is nothing where the tools come first (Cla
|
|
|
881
1122
|
OpenAI-compatible endpoints), and at most your own system text on Gemini, where the guide follows
|
|
882
1123
|
it in the system instruction. For a question whose files are all sent whole, it is your own system
|
|
883
1124
|
text, and `view_pages` with its guide when the pages of a PDF can be looked at.
|
|
1125
|
+
|
|
1126
|
+
0.8.0 changed the description of `search_document` (its new arguments), the guide (two lines: counts
|
|
1127
|
+
by group and paging; searching the bare form of a word) and the closing requests
|
|
1128
|
+
([`FINAL_ANSWER_REQUEST`](./ask.md#final_answer_request) and the two others), so the cache misses
|
|
1129
|
+
once after upgrading to it too, the same way.
|