llm-large-files 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +446 -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 +291 -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 +25 -7
- 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 +6 -4
- 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 +132 -36
- package/docs/guides/deployment.md +106 -13
- package/docs/guides/errors-and-reliability.md +157 -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 +262 -35
- package/docs/reference/errors-and-retries.md +30 -2
- package/docs/reference/events.md +27 -10
- package/docs/reference/gemini.md +184 -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 +271 -26
- package/docs/security.md +101 -12
- package/docs/troubleshooting.md +14 -12
- package/docs/upgrading-0.10.md +472 -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 +294 -0
- package/src/error-info.ts +36 -1
- package/src/errors.ts +3 -1
- package/src/events.ts +29 -6
- 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 +6 -4
- 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/security.md
CHANGED
|
@@ -278,6 +278,91 @@ and the request is not sent again. A reply made of many events has no cap on its
|
|
|
278
278
|
time while it keeps arriving. An endpoint you do not trust, such as a gateway run by someone else,
|
|
279
279
|
can still take the memory of your server.
|
|
280
280
|
|
|
281
|
+
## Tool results: `onToolResult`
|
|
282
|
+
|
|
283
|
+
New in 0.10.0. `AskOptions.onToolResult` sees the result of every tool call that ran before the
|
|
284
|
+
model does, and before the evidence, the steps, `toolTurns` and the events. It can let the result
|
|
285
|
+
through (undefined), send a masked copy (`{ result }`, sent with `redacted: true`), or send an error
|
|
286
|
+
in its place (`{ reject: "why" }`). Use it for data loss prevention: Israeli ID numbers (ת.ז.) and
|
|
287
|
+
card numbers that a file holds, and that a user of the chat should not get through the model.
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import { askWithFiles, type AskOptions, type AskResult, type ToolResult } from "llm-large-files";
|
|
291
|
+
|
|
292
|
+
/** An Israeli ID number (9 digits, with its check digit), as it may be written in a file. */
|
|
293
|
+
const ID_CANDIDATE = /(?<!\d)\d{5,9}(?!\d)/g;
|
|
294
|
+
/** A card number: 13 to 19 digits, maybe in groups. */
|
|
295
|
+
const CARD_CANDIDATE = /(?<!\d)\d(?:[ -]?\d){12,18}(?!\d)/g;
|
|
296
|
+
|
|
297
|
+
const israeliId = (digits: string): boolean => {
|
|
298
|
+
const id = digits.padStart(9, "0");
|
|
299
|
+
let sum = 0;
|
|
300
|
+
for (let index = 0; index < 9; index++) {
|
|
301
|
+
const step = Number(id[index]) * (index % 2 === 0 ? 1 : 2);
|
|
302
|
+
sum += step > 9 ? step - 9 : step;
|
|
303
|
+
}
|
|
304
|
+
return sum % 10 === 0;
|
|
305
|
+
};
|
|
306
|
+
const luhn = (digits: string): boolean => {
|
|
307
|
+
let sum = 0;
|
|
308
|
+
for (let index = 0; index < digits.length; index++) {
|
|
309
|
+
let digit = Number(digits[digits.length - 1 - index]);
|
|
310
|
+
if (index % 2 === 1) digit = digit * 2 > 9 ? digit * 2 - 9 : digit * 2;
|
|
311
|
+
sum += digit;
|
|
312
|
+
}
|
|
313
|
+
return sum % 10 === 0;
|
|
314
|
+
};
|
|
315
|
+
const mask = (text: string): string => text
|
|
316
|
+
.replace(CARD_CANDIDATE, (found) => (luhn(found.replace(/\D/g, "")) ? "[מספר כרטיס]" : found))
|
|
317
|
+
.replace(ID_CANDIDATE, (found) => (found.length >= 8 && israeliId(found) ? "[ת.ז.]" : found));
|
|
318
|
+
/** Every string of a result masked; numbers and keys as they are. */
|
|
319
|
+
const masked = (value: unknown): unknown =>
|
|
320
|
+
typeof value === "string" ? mask(value)
|
|
321
|
+
: Array.isArray(value) ? value.map(masked)
|
|
322
|
+
: value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([key, field]) => [key, masked(field)]))
|
|
323
|
+
: value;
|
|
324
|
+
|
|
325
|
+
// options are those of askWithFiles.
|
|
326
|
+
export function askWithDlp(options: AskOptions): Promise<AskResult> {
|
|
327
|
+
return askWithFiles({
|
|
328
|
+
...options,
|
|
329
|
+
onToolResult: ({ result }) => {
|
|
330
|
+
const clean = masked(result) as ToolResult;
|
|
331
|
+
return JSON.stringify(clean) === JSON.stringify(result) ? undefined : { result: clean };
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
- **It may be async.** A call to a DLP service of your own gets the context's `signal`, which
|
|
338
|
+
aborts when the question is stopped or fails; the question does not wait for the hook once its
|
|
339
|
+
own signal aborts. Each call's hook starts as soon as its result is in, so the checks of one turn
|
|
340
|
+
run at the same time; their verdicts are applied in call order.
|
|
341
|
+
- **It fails closed.** What the hook throws, or a value of another shape than `{ result }`,
|
|
342
|
+
`{ reject }` or undefined, ends the question with that error or a `TypeError`, at once: the other
|
|
343
|
+
calls of the turn stop, and no result of the turn reaches the model. A DLP service that is down
|
|
344
|
+
stops the question; the model never gets the unchecked result.
|
|
345
|
+
- **It sees the whole result.** The hook gets what the tool returned, before it is fitted to the
|
|
346
|
+
room in the request. What it lets through is fitted then, a masked copy as the tool's own result
|
|
347
|
+
would be: a copy larger than the room is cut, and is still marked `redacted: true`.
|
|
348
|
+
- **What the model saw is what is kept.** The evidence, the steps, `toolTurns` (stored with the
|
|
349
|
+
conversation, and sent again in later questions) and `tool.end` tell the masked result. A later
|
|
350
|
+
call is never answered with a pointer to a masked result: it runs again, through the hook. The
|
|
351
|
+
same call made twice in one turn gets the first one's verdict: the same masked copy, or the same
|
|
352
|
+
error.
|
|
353
|
+
- **It sees tool results only.** The model gets other text of the files that no tool returns, and
|
|
354
|
+
the hook does not see it:
|
|
355
|
+
- a document small enough to be sent whole goes into the prompt as it is;
|
|
356
|
+
- the card of a searched document holds its first 25 lines, up to 40 outline headings, and for a
|
|
357
|
+
log up to 8 message templates;
|
|
358
|
+
- the parts of a whole-file read (`analyze_whole_document`) go to the model that reads them, in
|
|
359
|
+
full, through `generateText`; only the read's answer is a tool result;
|
|
360
|
+
- the pages of `view_pages` are a PDF next to the result.
|
|
361
|
+
|
|
362
|
+
For data that must never reach a model, redact it before you ingest the file (or keep it out of
|
|
363
|
+
the documents), and use the hook for what a search or a read brings back. To keep whole-file
|
|
364
|
+
reads off, set `wholeDocumentAnalysis: false`.
|
|
365
|
+
|
|
281
366
|
## Prompt injection
|
|
282
367
|
|
|
283
368
|
The model reads text you do not control: the content of the files, their names, the pages it looks
|
|
@@ -1004,7 +1089,7 @@ New in 0.9.0. `createDocumentHandlers` writes no file unless it is asked to: by
|
|
|
1004
1089
|
([Stopping a server](./guides/deployment.md#stopping-a-server)).
|
|
1005
1090
|
- **Bounded.** A body written to a file has the same limits as one in memory: `maxUploadBytes` and
|
|
1006
1091
|
`uploadIdleTimeoutMs`, which also bounds each call to the disk (a volume that stops answering is
|
|
1007
|
-
a `
|
|
1092
|
+
a `503` "Upload failed (ETIMEDOUT).", a `500` before 0.10.0, and gives the upload's room back). `maxSpooledUploadBytes`
|
|
1008
1093
|
(ten times `maxUploadBytes`) bounds the spool's files at once. A full disk (`ENOSPC`, `EDQUOT`) is
|
|
1009
1094
|
answered `503`, and the file removed. The files of `prepareUpload` are bounded by your disk only.
|
|
1010
1095
|
- **Not sent.** The path of a file and its ref are never in an answer, an event, a summary, or a
|
|
@@ -1055,10 +1140,11 @@ question, whatever the model:
|
|
|
1055
1140
|
|
|
1056
1141
|
- **Chat requests:** `limits.toolTurns` (12), counting the answer. Tools run in all but the last,
|
|
1057
1142
|
with at most `limits.callsPerTurn` (8) calls run in each.
|
|
1058
|
-
- **Whole-file reads:** one of each document (`limits.wholeDocumentReads`)
|
|
1059
|
-
`
|
|
1060
|
-
|
|
1061
|
-
|
|
1143
|
+
- **Whole-file reads:** one of each document (`limits.wholeDocumentReads`), and 2 in all
|
|
1144
|
+
(`limits.wholeReadsPerQuestion`, since 0.10.0). A read is up to `maxMapChunks` (30) part
|
|
1145
|
+
requests of up to `mapChunkTokens` each (100,000 at the default window of 1M tokens: 3M input
|
|
1146
|
+
tokens), plus the requests that merge the notes and write the read's answer. With an explorer
|
|
1147
|
+
model, that model reads the parts.
|
|
1062
1148
|
- **Pages:** at most 5 a call, and for the question what half of `reservedTokens` holds at the
|
|
1063
1149
|
adapter's `pageTokens`. They stay in the later requests of the question, which bills them again,
|
|
1064
1150
|
unless room runs out and older results are replaced by a note of what they showed (never for a
|
|
@@ -1068,11 +1154,13 @@ question, whatever the model:
|
|
|
1068
1154
|
model whose conversation may only grow, as Claude's), and a question whose first request is too
|
|
1069
1155
|
large, before any tool ran, is planned again once. None of these takes a tool turn. A retried
|
|
1070
1156
|
request counts once in the usage.
|
|
1071
|
-
- **Ceilings
|
|
1072
|
-
|
|
1073
|
-
`inputTokens`
|
|
1074
|
-
|
|
1075
|
-
|
|
1157
|
+
- **Ceilings:** `limits.inputTokens` and `limits.requests` cover the whole question, part reads
|
|
1158
|
+
included. A whole-file read that would pass one is refused before it starts. Since 0.10.0
|
|
1159
|
+
`inputTokens` has a default: the larger of 1,000,000 and `toolTurns` times the first request,
|
|
1160
|
+
with room for the whole-file reads the question may make (`Infinity` for none). It is checked
|
|
1161
|
+
before each tool request, looking ahead: when the next tool request and the answer would pass it,
|
|
1162
|
+
no more tools run. So a question passes it by about one request at most, the answer. A request
|
|
1163
|
+
that reports no usage counts by the library's estimate. `requests`, unset by default, counts
|
|
1076
1164
|
answered requests and keeps one for the answer.
|
|
1077
1165
|
|
|
1078
1166
|
`result.usage` is what a question used, in all and for each model. A question that fails or is
|
|
@@ -1087,8 +1175,9 @@ piece and 300 s between pieces, and is retried after waits of up to 60 s
|
|
|
1087
1175
|
([Errors and reliability](./guides/errors-and-reliability.md#waits-on-a-silent-model)). A question
|
|
1088
1176
|
is up to 12 chat requests, not counting retries, and part reads besides, so it can run for many
|
|
1089
1177
|
minutes. Give it a deadline with `signal`, and abort it too when the client goes away
|
|
1090
|
-
([Web app](./guides/web-app.md)).
|
|
1091
|
-
|
|
1178
|
+
([Web app](./guides/web-app.md)). Since 0.10.0 the question stops at once when its signal aborts,
|
|
1179
|
+
also while it waits for a store that does not answer, in planning or in a tool call. This sample
|
|
1180
|
+
sets a deadline and logs what each question used, failed ones included:
|
|
1092
1181
|
|
|
1093
1182
|
```ts
|
|
1094
1183
|
import { askWithFiles, partialResultOf, type UsageTotals } from "llm-large-files";
|
package/docs/troubleshooting.md
CHANGED
|
@@ -285,16 +285,17 @@ the client's connection stalled, or a proxy held the body. The connection is clo
|
|
|
285
285
|
the file again. For users on slow or unsteady links, raise `uploadIdleTimeoutMs` of
|
|
286
286
|
`createDocumentHandlers`.
|
|
287
287
|
|
|
288
|
-
### `
|
|
288
|
+
### `503`: "Upload failed (ETIMEDOUT)." and `500`: "Upload failed (ELOOP)."
|
|
289
289
|
|
|
290
290
|
New in 0.9.0, for a body written to a file (the `path` of `prepareUpload`, or `uploadSpool`).
|
|
291
291
|
|
|
292
|
-
- **"ETIMEDOUT"
|
|
293
|
-
a write, closing it) did not end
|
|
294
|
-
answering, such as a network volume whose
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
292
|
+
- **"ETIMEDOUT"**, a `503` with `Retry-After: 5` (a `500` before 0.10.0). A call to the disk
|
|
293
|
+
(checking the folders of a path with a ref, opening the file, a write, closing it) did not end
|
|
294
|
+
within `uploadIdleTimeoutMs` (30 s): the volume stopped answering, such as a network volume whose
|
|
295
|
+
server is gone. The upload's room is given back, and the file is removed once the volume answers.
|
|
296
|
+
**Fix.** Check the volume. The client may send the file again after `Retry-After`. A slow network
|
|
297
|
+
volume can take long to close a file it held writes for: raise `uploadIdleTimeoutMs`.
|
|
298
|
+
- **"ELOOP"**, a `500`. `prepareUpload` gave a path that ends with the ref of its `original`, and a folder
|
|
298
299
|
between that root and the file is a link. `fileOriginals` would never read the file back through
|
|
299
300
|
it, so nothing is written. **Fix.** Replace the link with the folder itself, or mount the other
|
|
300
301
|
disk there. The root itself may be a link.
|
|
@@ -1116,7 +1117,7 @@ import { askGemini } from "llm-large-files/gemini";
|
|
|
1116
1117
|
const result = await askGemini({
|
|
1117
1118
|
files, endpoint, documentIds, messages, owner,
|
|
1118
1119
|
limits: {
|
|
1119
|
-
inputTokens: 1_000_000, // no
|
|
1120
|
+
inputTokens: 1_000_000, // no tool request that, with the answer, would pass it
|
|
1120
1121
|
requests: 20, // chat requests and part reads together
|
|
1121
1122
|
wholeDocumentReads: 0, // no whole-file reads
|
|
1122
1123
|
},
|
|
@@ -1126,10 +1127,11 @@ const { inputTokens, cachedInputTokens, outputTokens, requests, byModel } = resu
|
|
|
1126
1127
|
console.log({ owner, inputTokens, cachedInputTokens, outputTokens, requests, byModel });
|
|
1127
1128
|
```
|
|
1128
1129
|
|
|
1129
|
-
The ceilings are checked before each request that may use tools
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1130
|
+
The ceilings are checked before each request that may use tools, looking ahead: when what the
|
|
1131
|
+
question spent, the next tool request and the answer would pass `inputTokens`, the next request is
|
|
1132
|
+
the answer. So a question can pass `inputTokens` by about one request, the answer's, with the
|
|
1133
|
+
results of the last tool turn in it: set it that far below what must not be passed
|
|
1134
|
+
([Costs and limits](./guides/costs-and-limits.md#the-ceiling-looks-ahead)). A
|
|
1133
1135
|
cheaper [explorer model](./guides/explorer-model.md) takes the searching and the part reads off the
|
|
1134
1136
|
model that answers.
|
|
1135
1137
|
|