llm-large-files 0.4.0 → 0.5.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 +205 -0
- package/README.md +48 -8
- package/dist/anthropic/adapter.d.ts +106 -0
- package/dist/anthropic/adapter.d.ts.map +1 -0
- package/dist/anthropic/adapter.js +391 -0
- package/dist/anthropic/adapter.js.map +1 -0
- package/dist/anthropic/index.d.ts +3 -0
- package/dist/anthropic/index.d.ts.map +1 -0
- package/dist/anthropic/index.js +2 -0
- package/dist/anthropic/index.js.map +1 -0
- package/dist/ask.d.ts +144 -0
- package/dist/ask.d.ts.map +1 -0
- package/dist/ask.js +540 -0
- package/dist/ask.js.map +1 -0
- package/dist/budget.d.ts +23 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +64 -0
- package/dist/budget.js.map +1 -0
- package/dist/cache.d.ts +11 -2
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +36 -7
- package/dist/cache.js.map +1 -1
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +44 -0
- package/dist/errors.js.map +1 -0
- package/dist/evidence.d.ts +40 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +137 -0
- package/dist/evidence.js.map +1 -0
- package/dist/gemini/adapter.d.ts +50 -0
- package/dist/gemini/adapter.d.ts.map +1 -0
- package/dist/gemini/adapter.js +179 -0
- package/dist/gemini/adapter.js.map +1 -0
- package/dist/gemini/chat.d.ts +32 -71
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +38 -284
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/errors.d.ts +11 -0
- package/dist/gemini/errors.d.ts.map +1 -0
- package/dist/gemini/errors.js +14 -0
- package/dist/gemini/errors.js.map +1 -0
- package/dist/gemini/generate.d.ts +12 -13
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +62 -26
- package/dist/gemini/generate.js.map +1 -1
- package/dist/gemini/index.d.ts +3 -1
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/gemini/index.js +2 -1
- package/dist/gemini/index.js.map +1 -1
- package/dist/gemini/sse.d.ts +1 -2
- package/dist/gemini/sse.d.ts.map +1 -1
- package/dist/gemini/sse.js +1 -38
- package/dist/gemini/sse.js.map +1 -1
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +55 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/library.d.ts +50 -5
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +56 -26
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.d.ts +15 -0
- package/dist/map-reduce.d.ts.map +1 -1
- package/dist/map-reduce.js +58 -27
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +196 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +41 -0
- package/dist/model.js.map +1 -0
- package/dist/openai/adapter.d.ts +85 -0
- package/dist/openai/adapter.d.ts.map +1 -0
- package/dist/openai/adapter.js +293 -0
- package/dist/openai/adapter.js.map +1 -0
- package/dist/openai/index.d.ts +3 -0
- package/dist/openai/index.d.ts.map +1 -0
- package/dist/openai/index.js +2 -0
- package/dist/openai/index.js.map +1 -0
- package/dist/output-limit.d.ts +30 -0
- package/dist/output-limit.d.ts.map +1 -0
- package/dist/output-limit.js +92 -0
- package/dist/output-limit.js.map +1 -0
- package/dist/plan.d.ts +20 -4
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +44 -7
- package/dist/plan.js.map +1 -1
- package/dist/ranged.d.ts +2 -2
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +11 -4
- package/dist/ranged.js.map +1 -1
- package/dist/retry.d.ts +54 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +111 -0
- package/dist/retry.js.map +1 -0
- package/dist/search.d.ts +16 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +109 -26
- package/dist/search.js.map +1 -1
- package/dist/sse.d.ts +3 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +39 -0
- package/dist/sse.js.map +1 -0
- package/dist/stores.d.ts +5 -1
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +58 -15
- package/dist/stores.js.map +1 -1
- package/dist/text.d.ts +12 -1
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +43 -15
- package/dist/text.js.map +1 -1
- package/dist/tools.d.ts +23 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +115 -35
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +33 -3
- package/dist/types.d.ts.map +1 -1
- package/docs/api.md +253 -28
- package/docs/configuration.md +89 -10
- package/docs/getting-started.md +69 -16
- package/docs/how-it-works.md +46 -4
- package/docs/security.md +36 -3
- package/package.json +21 -3
- package/src/anthropic/adapter.ts +454 -0
- package/src/anthropic/index.ts +2 -0
- package/src/ask.ts +675 -0
- package/src/budget.ts +71 -0
- package/src/cache.ts +32 -8
- package/src/errors.ts +42 -0
- package/src/evidence.ts +162 -0
- package/src/gemini/adapter.ts +218 -0
- package/src/gemini/chat.ts +62 -333
- package/src/gemini/errors.ts +15 -0
- package/src/gemini/generate.ts +72 -30
- package/src/gemini/index.ts +3 -1
- package/src/gemini/sse.ts +1 -34
- package/src/http.ts +59 -0
- package/src/index.ts +34 -4
- package/src/library.ts +102 -29
- package/src/map-reduce.ts +52 -23
- package/src/model.ts +200 -0
- package/src/openai/adapter.ts +345 -0
- package/src/openai/index.ts +2 -0
- package/src/output-limit.ts +99 -0
- package/src/plan.ts +46 -7
- package/src/ranged.ts +13 -6
- package/src/retry.ts +132 -0
- package/src/search.ts +116 -25
- package/src/sse.ts +34 -0
- package/src/stores.ts +51 -15
- package/src/text.ts +39 -12
- package/src/tools.ts +127 -38
- package/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EAAE,aAAa,KAAK,IAAI,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,sDAAsD;IACtD,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,sDAAsD;IACtD,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,YAAY,CAAC;IACnB,iGAAiG;IACjG,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,mGAAmG;IACnG,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B,CAAC"}
|
package/docs/api.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# API reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Five entry points:
|
|
4
4
|
|
|
5
5
|
| Import | Contents |
|
|
6
6
|
|---|---|
|
|
7
|
-
| `llm-large-files` | Core: `createLargeFiles`, stores, types, helpers. Provider-neutral. |
|
|
8
|
-
| `llm-large-files/gemini` | `askGemini`, endpoints, Gemini
|
|
7
|
+
| `llm-large-files` | Core: `createLargeFiles`, `askWithFiles`, stores, types, helpers. Provider-neutral. |
|
|
8
|
+
| `llm-large-files/gemini` | `gemini()`, `askGemini`, endpoints, Gemini helpers. |
|
|
9
|
+
| `llm-large-files/openai` | `openAiCompatible()` for any Chat Completions endpoint. |
|
|
10
|
+
| `llm-large-files/anthropic` | `anthropic()` for Claude. |
|
|
9
11
|
| `llm-large-files/node` | `createDocumentHandlers` for Node HTTP servers. |
|
|
10
12
|
|
|
11
13
|
## `llm-large-files`
|
|
@@ -15,12 +17,12 @@ Three entry points:
|
|
|
15
17
|
| Option | Type | Default |
|
|
16
18
|
|---|---|---|
|
|
17
19
|
| `store` | `DocumentStore` | required |
|
|
18
|
-
| `budget` | `Partial<Budget>` | see [configuration](configuration.md#budget) |
|
|
19
|
-
| `ttlMs` | `number` | 72 hours |
|
|
20
|
+
| `budget` | `Partial<Budget>` | see [configuration](configuration.md#budget). What is left out follows `contextTokens`; values that cannot work together throw |
|
|
21
|
+
| `ttlMs` | `number` | 72 hours. `Infinity` keeps documents until they are deleted (`expiresAt` is then `NEVER_EXPIRES`) |
|
|
20
22
|
| `maxUploadBytes` | `number` | 100 MB |
|
|
21
23
|
| `extractors` | `Partial<Record<DocumentFormat, Extractor>>` | built-ins |
|
|
22
24
|
| `cacheBytes` | `number` | 256 MB: memory that documents kept ready between tool calls may take. Each use checks the store first. 0 keeps none |
|
|
23
|
-
| `cacheSize` | `number` | no limit: also caps the number of documents kept |
|
|
25
|
+
| `cacheSize` | `number` | no limit: also caps the number of documents kept. The pieces kept of a document read by range are not counted |
|
|
24
26
|
| `wholeDocumentBytes` | `number` | 2 MB: larger documents are read by range when the store can ([details](configuration.md#large-files-many-users-several-servers)). `Infinity` loads all whole |
|
|
25
27
|
| `scanChunkBytes` | `number` | 1 MB: text read and searched at a time, reading by range |
|
|
26
28
|
| `maxConcurrentScans` | `number` | 4: searches of a document read by range that run at once; the others wait |
|
|
@@ -36,8 +38,14 @@ Three entry points:
|
|
|
36
38
|
| `getOriginal(id, { owner }?)` | The uploaded file as a `Uint8Array`, when it was kept. `undefined` otherwise, and for another owner. |
|
|
37
39
|
| `delete(id, { owner }?)` | `true` if deleted. |
|
|
38
40
|
| `sweep()` | Removes expired documents; returns the count. |
|
|
39
|
-
| `prepare(ids, base, { owner?, viewPages? }?)` | Plans one request. `base` is `{ tokens, bytes }` for everything else in the request. Returns `PreparedContext`. `viewPages: true` says that your loop can pass files to the model. |
|
|
40
|
-
| `tools(documents, { generate?, onProgress?, signal?, viewPages? })` | A `ToolSet` scoped to these documents. `generate` enables `analyze_whole_document
|
|
41
|
+
| `prepare(ids, base, { owner?, viewPages?, budget? }?)` | Plans one request. `base` is `{ tokens, bytes }` for everything else in the request. Returns `PreparedContext`. `viewPages: true` says that your loop can pass files to the model. `budget` changes budget fields for this request. |
|
|
42
|
+
| `tools(documents, { generate?, onProgress?, signal?, viewPages?, regexBudgetMs?, maxWholeDocumentReads?, retry?, budget? })` | A `ToolSet` scoped to these documents: make one for each question. `generate` enables `analyze_whole_document`, for documents small enough for it. `viewPages` (`true`, or a list of documents such as `prepared.viewable`) enables `view_pages`. `regexBudgetMs` (default 6,000) is the time the regex searches of the tool set may take together. `maxWholeDocumentReads` (default 1) is how often each document may be read whole. `retry` is how a part read that failed is sent again. |
|
|
43
|
+
| `budgetFor(overrides?, limits?)` | The budget for one request: the library's, with `overrides` in place of its fields, made to fit `limits` (`{ contextTokens?, maxRequestBytes? }` of a model). |
|
|
44
|
+
|
|
45
|
+
`getMeta`, `getOriginal`, `delete`, `prepare` and the tools read the store. When it cannot be read
|
|
46
|
+
(a volume that does not answer, a database that is down) they throw `DocumentStoreError`, and a
|
|
47
|
+
tool call answers with its message. That is not "the document is gone": retry. The message names
|
|
48
|
+
no path and no host; `error.cause` is what the store threw, for your log.
|
|
41
49
|
| `budget`, `maxUploadBytes` | The effective settings. |
|
|
42
50
|
|
|
43
51
|
### `PreparedContext`
|
|
@@ -59,13 +67,19 @@ Three entry points:
|
|
|
59
67
|
declarations: ToolDeclaration[]; // { name, description, parameters: JSON Schema }
|
|
60
68
|
has(name): boolean;
|
|
61
69
|
execute(name, args): Promise<ToolResult>; // errors come back as { error } for the model to read
|
|
62
|
-
executeWithFiles(name, args, { maxFileBytes?, maxPages? }?): Promise<{ result: ToolResult; files: ToolFile[] }>;
|
|
70
|
+
executeWithFiles(name, args, { maxFileBytes?, maxPages?, maxResultCharacters? }?): Promise<{ result: ToolResult; files: ToolFile[] }>;
|
|
63
71
|
describe(name, args): string; // "Search app.log (exact) for “timeout”"
|
|
72
|
+
resultCharacters(name): number; // the most characters a result of this tool can have
|
|
64
73
|
}
|
|
65
74
|
```
|
|
66
75
|
|
|
67
76
|
`executeWithFiles` runs any tool. Its `files` (`{ name, mimeType, bytes }`) are empty for all but
|
|
68
77
|
`view_pages`. `execute("view_pages", …)` returns an error, because it has no place for the file.
|
|
78
|
+
`maxResultCharacters` is the room your request has left for this result, when that is less than
|
|
79
|
+
the tool's own cap: the result is cut to it and says where to go on.
|
|
80
|
+
|
|
81
|
+
A second `analyze_whole_document` of the same document by one tool set answers with an error that
|
|
82
|
+
tells the model to use the first answer (`maxWholeDocumentReads`).
|
|
69
83
|
|
|
70
84
|
| Tool | Arguments | Returns |
|
|
71
85
|
|---|---|---|
|
|
@@ -96,7 +110,15 @@ carry page numbers: `page` on each matching line, `pages` on a passage and on a
|
|
|
96
110
|
- `isDocumentId(value)`, `DOCUMENT_ID_PATTERN`.
|
|
97
111
|
- `estimateTokens(text)`, `utf8Bytes(text)`, `jsonBytes(text)`.
|
|
98
112
|
- `detectFormat(name, mimeType)`, `defaultExtractors`, `TOOL_NAMES`, `DEFAULT_BUDGET`,
|
|
99
|
-
`MAX_VIEW_PAGES` (5).
|
|
113
|
+
`MAX_VIEW_PAGES` (5), `MAX_WHOLE_DOCUMENT_READS` (1).
|
|
114
|
+
- `resolveBudget(partial?, limits?)`: a whole `Budget` from the fields you give
|
|
115
|
+
(see [configuration](configuration.md#budget)).
|
|
116
|
+
- `evidenceOf(call, result)`, `stubResult(call, result)`, `mergeRanges(ranges)`: what a tool call
|
|
117
|
+
showed, the short stand-in for a result that is dropped, and line ranges made one. For a loop of
|
|
118
|
+
your own.
|
|
119
|
+
- `withRetry(run, { retry?, signal?, canRetry?, onRetry? })`, `isRetryableStatus(status)`,
|
|
120
|
+
`retryAfterMs(headers, body?)`: the retry rule of the loop, for an adapter or a loop of your own.
|
|
121
|
+
- `parseSseJson(stream)`: async iterator over the JSON events of a `text/event-stream` body.
|
|
100
122
|
- `createPdfExtractor({ tables?: boolean, pictures?: boolean })`: the built-in PDF extractor with
|
|
101
123
|
an option changed. `tables: false` gives the text in pdf.js order, without rebuilt tables
|
|
102
124
|
(see [PDF tables](configuration.md#pdf-tables)). `pictures: false` leaves out the line that marks
|
|
@@ -121,6 +143,8 @@ type DocumentMeta = {
|
|
|
121
143
|
type GenerateText = (request: {
|
|
122
144
|
system: string; prompt: string; maxOutputTokens: number; signal?: AbortSignal;
|
|
123
145
|
onTruncated?: () => void; // call it when the model stopped at maxOutputTokens
|
|
146
|
+
onUsage?: (usage: { inputTokens?: number; cachedInputTokens?: number; outputTokens?: number; thoughtTokens?: number }) => void;
|
|
147
|
+
// call it once for every request that was answered
|
|
124
148
|
}) => Promise<string>;
|
|
125
149
|
type Extractor = (bytes: Uint8Array, input: { name: string; mimeType: string; format: DocumentFormat; scannedPages?: number }) => Promise<{ text: string; pages?: number }>;
|
|
126
150
|
// scannedPages: set when a PDF without any text is welcome, with the most pages it may have.
|
|
@@ -128,10 +152,155 @@ type Extractor = (bytes: Uint8Array, input: { name: string; mimeType: string; fo
|
|
|
128
152
|
type ToolFile = { name: string; mimeType: string; bytes: Uint8Array };
|
|
129
153
|
```
|
|
130
154
|
|
|
155
|
+
## `askWithFiles(options): Promise<AskResult>`
|
|
156
|
+
|
|
157
|
+
The tool loop, for any model. It plans the documents, offers the tools, runs the calls within the
|
|
158
|
+
limits of the request, and ends with a request that must be answered in text.
|
|
159
|
+
|
|
160
|
+
| Option | Description |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `files`, `model`, `documentIds`, `messages` | Required. `model` is an adapter: `gemini()`, `openAiCompatible()`, `anthropic()`, or [your own](#your-own-adapter). |
|
|
163
|
+
| `explorer` | A second adapter, of any provider. It makes the tool calls and reads whole files in parts, and `model` writes the answer from what the tools returned. See [An explorer model](configuration.md#an-explorer-model). |
|
|
164
|
+
| `messages` | The conversation; the last must be the user's. Plain turns `{ role: "user" \| "assistant", text }`, the `toolTurns` an earlier question returned, and turns with parts in the provider's own form: `{ role, parts: [{ text }, { native: anImagePart }] }`. |
|
|
165
|
+
| `system` | System instruction; the tool guide is appended when needed. |
|
|
166
|
+
| `owner` | Only documents with this owner (or no owner) are used. |
|
|
167
|
+
| `documentPlacement` | `"first"` (default): document text and cards go at the start of the first user turn and stay there, so follow-up questions reuse the provider's prompt cache. `"last"`: appended to the latest user turn. |
|
|
168
|
+
| `limits` | `toolTurns` (12): the most chat requests for one question, counting the answer. `callsPerTurn` (8): the most tool calls of one turn that are run. `wholeDocumentReads` (1): how often each document may be read whole. `inputTokens`, `requests` (none): ceilings for the whole question, part reads included. |
|
|
169
|
+
| `retry` | `{ retries = 3, baseDelayMs = 500, maxDelayMs = 60_000 }`. See [Limits and retries](configuration.md#limits-and-retries). |
|
|
170
|
+
| `budget` | Budget fields for this question, in place of the library's. |
|
|
171
|
+
| `wholeDocumentAnalysis` | Default `true`. Set `false` to withhold the costly whole-file tool. |
|
|
172
|
+
| `viewPages` | Default `true`. Offers `view_pages` for PDFs whose original is kept, when every model of the question can be sent a file. |
|
|
173
|
+
| `onText`, `onActivity`, `onStep` | Answer text as it arrives, transient status, completed steps. |
|
|
174
|
+
| `signal` | Stops the question. |
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
{
|
|
180
|
+
text: string; // everything the answering model wrote
|
|
181
|
+
answered: boolean; // false when its last turn had no text, or the prompt was refused
|
|
182
|
+
blockReason?: string;
|
|
183
|
+
steps: string[]; // "Search app.log (exact) for “timeout” — 12 matching lines"
|
|
184
|
+
evidence: Evidence[]; // per tool call: { tool, documentId, document, lines?, pages?, query?, mode?, totalMatchingLines?, whole? }
|
|
185
|
+
toolTurns: ToolTurn[]; // the tool rounds as plain JSON, to keep with the conversation
|
|
186
|
+
plan: DocumentPlan; // which documents went in whole and which were searched
|
|
187
|
+
budget: Budget; // the budget the question ran with
|
|
188
|
+
turns: number; // chat requests, an explorer's among them; part reads are not counted
|
|
189
|
+
finishReason?: string;
|
|
190
|
+
usage: { // every request that was answered, part reads included
|
|
191
|
+
requests: number; inputTokens: number; cachedInputTokens: number; outputTokens: number; thoughtTokens: number;
|
|
192
|
+
byModel: Record<string, { requests; inputTokens; cachedInputTokens; outputTokens; thoughtTokens }>;
|
|
193
|
+
};
|
|
194
|
+
lastUsage?: Record<string, unknown>; // the provider's own usage object of the last chat response
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`inputTokens` counts every token of the prompts, those read from a cache included, and
|
|
199
|
+
`cachedInputTokens` is the part that was. `outputTokens` includes thoughts.
|
|
200
|
+
|
|
201
|
+
`answered` is `false` when the model's last turn had no text: the prompt was blocked
|
|
202
|
+
(`blockReason` says why), the reply was cut off before any text, or the model produced a malformed
|
|
203
|
+
tool call and the request for the answer came back empty too. `text` is then empty or holds only a
|
|
204
|
+
remark the model made before a tool call, so show your own message:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
const result = await askWithFiles({ ... });
|
|
208
|
+
if (!result.answered) show(result.blockReason ? "The request was blocked." : "No answer this time. Try again.");
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
It throws `DocumentsNotFoundError` (`.ids`) before calling the model, `DocumentStoreError` when the
|
|
212
|
+
store could not be read (retry: the documents are not gone), `ModelRequestError` (`.status`, and
|
|
213
|
+
`.retryAfterMs` when the provider named a wait) for an HTTP error that another try did not mend,
|
|
214
|
+
and `Error` when the last message isn't the user's. `status` is 0 for a connection that failed.
|
|
215
|
+
Each adapter throws its own subclass: `GeminiRequestError`, `OpenAiRequestError`,
|
|
216
|
+
`AnthropicRequestError`.
|
|
217
|
+
|
|
218
|
+
### Keeping what a question read
|
|
219
|
+
|
|
220
|
+
`toolTurns` are the tool rounds of the question, with each result as the model had it. Store them
|
|
221
|
+
between the question and its answer, and pass them back:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
const first = await askWithFiles({ files, model, documentIds, messages: [{ role: "user", text: question }] });
|
|
225
|
+
await saveTurn(sessionId, { question, toolTurns: first.toolTurns, answer: first.text });
|
|
226
|
+
|
|
227
|
+
// The next question of the conversation:
|
|
228
|
+
const messages = [
|
|
229
|
+
{ role: "user", text: question }, ...first.toolTurns, { role: "assistant", text: first.text },
|
|
230
|
+
{ role: "user", text: "And how long did recovery take?" },
|
|
231
|
+
];
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The model then sees what it read before, and a follow-up is often answered without a new search.
|
|
235
|
+
The rounds are plain JSON and belong to no provider. The pages of a PDF are not in them: a stored
|
|
236
|
+
round says that they were shown. They count against the budget like any other part of the
|
|
237
|
+
conversation, and late in a long question the oldest are shortened first.
|
|
238
|
+
|
|
239
|
+
### Your own adapter
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
import type { ModelAdapter } from "llm-large-files";
|
|
243
|
+
|
|
244
|
+
const model: ModelAdapter = {
|
|
245
|
+
id: "my-model", // names the model in usage totals
|
|
246
|
+
capabilities: { toolFiles: "none", pageTokens: 0 }, // and, when you know them: contextTokens, maxRequestBytes, outputTokens, tokenScale, appendOnly
|
|
247
|
+
async send(request, hooks) {
|
|
248
|
+
// request: { system, messages, tools?, toolChoice? }
|
|
249
|
+
// messages: { role: "user" | "assistant", parts: [{ text } | { native }] }
|
|
250
|
+
// | { role: "tools", calls, answers: [{ call, result, files? }], raw? }
|
|
251
|
+
// Turn them into your provider's request, post it with hooks.signal, and call hooks.onText
|
|
252
|
+
// with the text as it arrives.
|
|
253
|
+
return { text, calls: [{ id, name, args }], raw: theTurnAsYourProviderSentIt, finishReason, usage: { inputTokens, outputTokens } };
|
|
254
|
+
},
|
|
255
|
+
generateText: async ({ system, prompt, maxOutputTokens, signal, onUsage, onTruncated }) => "…", // optional: enables whole-file reads
|
|
256
|
+
};
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
- A `tools` message is one round: the model's calls and the results, in call order. `raw` is the
|
|
260
|
+
turn as your `send` returned it, given back only to the adapter that produced it. Without `raw`
|
|
261
|
+
(an explorer of another provider made the calls, or the round was stored), build the turn from
|
|
262
|
+
`calls`.
|
|
263
|
+
- `toolChoice: "none"` means the model must answer in text. The tools are still in `tools`, for a
|
|
264
|
+
provider that wants them declared next to earlier calls.
|
|
265
|
+
- Throw `ModelRequestError(message, status, { retryAfterMs })` for an HTTP error, with status 0
|
|
266
|
+
for a connection that failed. The loop retries the ones worth retrying.
|
|
267
|
+
- Give a call whose arguments did not parse a `problem`: the loop answers it with that message and
|
|
268
|
+
does not run it.
|
|
269
|
+
- `capabilities.toolFiles` says where a file from a tool goes (`"inside"` the result, `"beside"`
|
|
270
|
+
it, or `"none"`: `view_pages` is then not offered). `appendOnly: true` tells the loop never to
|
|
271
|
+
rewrite an earlier turn of the conversation.
|
|
272
|
+
|
|
131
273
|
## `llm-large-files/gemini`
|
|
132
274
|
|
|
275
|
+
### `gemini(endpoint, options?): ModelAdapter`
|
|
276
|
+
|
|
277
|
+
A Gemini model for `askWithFiles`. `endpoint` is `geminiApi()`, `vertexAi()`, or your own
|
|
278
|
+
`{ url, streamUrl?, headers }`; its `explorerUrl` is not used here, because an explorer is an
|
|
279
|
+
adapter of its own.
|
|
280
|
+
|
|
281
|
+
| Option | Description |
|
|
282
|
+
|---|---|
|
|
283
|
+
| `generationConfig` | Sent with every chat request. |
|
|
284
|
+
| `toolFilePlacement` | `"inside"` (default) or `"beside"`: see [Where the pages go](configuration.md#where-the-pages-go-toolfileplacement). |
|
|
285
|
+
| `analysisConfig` | `(maxOutputTokens) => generationConfig` for whole-file part reads. |
|
|
286
|
+
| `contextTokens`, `maxRequestBytes` | The model's window and the largest request, when the budget of a question should follow them. |
|
|
287
|
+
| `pageTokens` | Tokens billed for one PDF page. Default 530. |
|
|
288
|
+
| `id`, `fetch` | The name in usage totals (default: the model in the URL), and a custom fetch. |
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
const model = gemini(geminiApi({ apiKey, model: "gemini-3.8-flash" }), { generationConfig: { temperature: 0.3 } });
|
|
292
|
+
const explorer = gemini(geminiApi({ apiKey, model: "gemini-3.5-flash-lite" }));
|
|
293
|
+
await askWithFiles({ files, model, explorer, documentIds, messages });
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
`fromGeminiContents(contents)` turns Gemini `contents` into `messages`, and
|
|
297
|
+
`geminiToolTurns(toolTurns)` gives stored tool rounds as `contents`.
|
|
298
|
+
|
|
133
299
|
### `askGemini(options): Promise<AskGeminiResult>`
|
|
134
300
|
|
|
301
|
+
`askWithFiles` with a `gemini()` model for the endpoint, and a second one for its explorer model
|
|
302
|
+
when it names one. It takes Gemini `contents` as well as `messages`.
|
|
303
|
+
|
|
135
304
|
| Option | Description |
|
|
136
305
|
|---|---|
|
|
137
306
|
| `files`, `endpoint`, `documentIds` | Required. |
|
|
@@ -142,32 +311,26 @@ type ToolFile = { name: string; mimeType: string; bytes: Uint8Array };
|
|
|
142
311
|
| `explorerGenerationConfig` | The same, for the requests of an [explorer model](configuration.md#an-explorer-model). Defaults to `generationConfig`. Not used without an explorer. |
|
|
143
312
|
| `owner` | Only documents with this owner (or no owner) are used. |
|
|
144
313
|
| `documentPlacement` | `"first"` (default): document text and cards go at the start of the first user turn and stay there, so follow-up questions reuse Gemini's prompt cache. `"last"`: appended to the latest user turn, as in 0.1.0. |
|
|
145
|
-
| `
|
|
314
|
+
| `limits`, `retry`, `budget` | As in `askWithFiles`. |
|
|
315
|
+
| `maxToolTurns` | `limits.toolTurns` under its older name. Default 12. The most requests for one question, counting the answer. If the model is still calling tools on the last one, it is sent with no tools so the model must answer. With an explorer model the answer is always the last request, so the explorer has one less. |
|
|
316
|
+
| `maxToolCallsPerTurn` | `limits.callsPerTurn` under its older name. Default 8. The most tool calls of one model turn that are run. The others are answered with an error that tells the model to send them again if it still needs them. |
|
|
146
317
|
| `wholeDocumentAnalysis` | Default `true`. Set `false` to withhold the costly whole-file tool. |
|
|
147
318
|
| `viewPages` | Default `true`. Offers `view_pages` for PDFs whose original is kept. It changes nothing for a library that keeps no originals. |
|
|
148
319
|
| `toolFilePlacement` | `"inside"` (default): the pages go in the function response itself, which Gemini 3 models read. `"beside"`: in a user turn of their own after the function responses, for Gemini 2.5, which does not see a file inside a function response. See [Where the pages go](configuration.md#where-the-pages-go-toolfileplacement). |
|
|
149
|
-
| `analysisConfig` | `(maxOutputTokens) => generationConfig` for whole-file part reads. The explorer model reads the parts when there is one, so write it for that model. |
|
|
320
|
+
| `analysisConfig` | `(maxOutputTokens) => generationConfig` for whole-file part reads. The explorer model reads the parts when there is one, so write it for that model. Without it a part is asked for with `{ maxOutputTokens, temperature: 0.2 }`. A model that thinks counts its thoughts in that limit: a reply that it cut off that way is asked for again with 32,768, and later parts start there. |
|
|
150
321
|
| `onText`, `onActivity`, `onStep` | Streaming answer text, transient status, completed steps. |
|
|
151
322
|
| `fetch`, `signal` | Custom fetch (proxies, tests) and cancellation. |
|
|
152
323
|
|
|
153
|
-
Returns `
|
|
324
|
+
Returns what `askWithFiles` returns. **`usage` is the total of the question since 0.5.0**; Gemini's
|
|
325
|
+
own `usageMetadata` of the last response, which `usage` was before, is `lastUsage`.
|
|
154
326
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
tool call and the tool-free retry came back empty too. `text` is then empty or holds only a remark
|
|
158
|
-
the model made before a tool call, so show your own message:
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
const result = await askGemini({ ... });
|
|
162
|
-
if (!result.answered) show(result.blockReason ? "The request was blocked." : "No answer this time. Try again.");
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
It throws `DocumentsNotFoundError` (`.ids`) before calling the model, `GeminiRequestError` (`.status`)
|
|
166
|
-
for HTTP errors, and `Error` when the last message isn't the user's.
|
|
327
|
+
It throws what `askWithFiles` throws; the model's errors are `GeminiRequestError` (`.status`, 0
|
|
328
|
+
for a connection that failed).
|
|
167
329
|
|
|
168
330
|
With an [explorer model](configuration.md#an-explorer-model), `text` and `onText` carry only what
|
|
169
|
-
the answering model wrote, `turns` counts the requests of both models,
|
|
170
|
-
`finishReason` are those of the answer. An explorer that
|
|
331
|
+
the answering model wrote, `turns` counts the requests of both models, `usage.byModel` has an
|
|
332
|
+
entry for each, and `finishReason` and `lastUsage` are those of the answer. An explorer that
|
|
333
|
+
fails throws `GeminiRequestError` too.
|
|
171
334
|
|
|
172
335
|
### Endpoints
|
|
173
336
|
|
|
@@ -184,7 +347,7 @@ reads whole files in parts, so that `model` only writes the answer. Left out, em
|
|
|
184
347
|
|
|
185
348
|
### Lower-level helpers
|
|
186
349
|
|
|
187
|
-
- `createGeminiGenerateText({ url, headers, fetchImpl?, generationConfig?, timeoutMs? })`: a `GenerateText` for your own loop.
|
|
350
|
+
- `createGeminiGenerateText({ url, headers, fetchImpl?, generationConfig?, timeoutMs? })`: a `GenerateText` for your own loop. `headers` can be a function, called for every request.
|
|
188
351
|
- `toGeminiTools(declarations)`: `{ functionDeclarations }`.
|
|
189
352
|
- `geminiFunctionResponses([{ call, result, files? }])`: the `user` turn answering function
|
|
190
353
|
calls. Files from `executeWithFiles` go inside their function response, as base64.
|
|
@@ -198,6 +361,68 @@ reads whole files in parts, so that `model` only writes the answer. Left out, em
|
|
|
198
361
|
tool. The second is the line in the explorer's system instruction that says what its part is.
|
|
199
362
|
- `parseSseJson(stream)`: async iterator over a Generate Content SSE stream.
|
|
200
363
|
|
|
364
|
+
## `llm-large-files/openai`
|
|
365
|
+
|
|
366
|
+
### `openAiCompatible(options): ModelAdapter`
|
|
367
|
+
|
|
368
|
+
Any Chat Completions endpoint: OpenAI, Azure OpenAI, DeepSeek, LiteLLM, vLLM, Ollama, OpenRouter,
|
|
369
|
+
Gemini's OpenAI layer.
|
|
370
|
+
|
|
371
|
+
| Option | Description |
|
|
372
|
+
|---|---|
|
|
373
|
+
| `model` | Required: the model name the endpoint knows. |
|
|
374
|
+
| `baseUrl` | `/chat/completions` is added to it. Default `https://api.openai.com/v1`. |
|
|
375
|
+
| `url` | The whole URL, when it is not `baseUrl` + `/chat/completions` (Azure, a gateway). |
|
|
376
|
+
| `apiKey`, `headers` | `Authorization: Bearer …`, and more headers. A function is called for each request. |
|
|
377
|
+
| `body` | More fields for every chat request: `temperature`, `reasoning_effort`, `max_completion_tokens`. |
|
|
378
|
+
| `analysisBody` | `(maxOutputTokens) => fields` for whole-file part reads. |
|
|
379
|
+
| `maxTokensField` | The name of the output limit in a part read. Default `max_completion_tokens` for api.openai.com and Azure OpenAI, `max_tokens` elsewhere. |
|
|
380
|
+
| `answerWithoutTools` | `"tool_choice"` (default): the request for the answer keeps the tools and sends `tool_choice: "none"`. `"omit"`: it leaves them out, for a server that does not know `tool_choice`. |
|
|
381
|
+
| `pdfInput` | Default `false`. Send the pages of `view_pages` as a `file` part in a user message after the tool results. For a model that reads PDF input: many servers behind this API do not (Gemini's layer answers HTTP 400). Not run against OpenAI itself. |
|
|
382
|
+
| `stream`, `systemRole` | `false` for a server without streaming; `"developer"` for one that wants the newer role name. |
|
|
383
|
+
| `contextTokens`, `maxRequestBytes`, `tokenScale`, `pageTokens` | What the model takes, when the budget should follow it. |
|
|
384
|
+
| `id`, `timeoutMs`, `fetch` | The name in usage totals, the time a part read may take (180 s), a custom fetch. |
|
|
385
|
+
|
|
386
|
+
The model's own message goes back to it as it came (a server may want its `reasoning_content` or a
|
|
387
|
+
signature again). `fromOpenAiMessages(history)` returns `{ system, messages }` for a history kept
|
|
388
|
+
as Chat Completions messages, and `openAiToolTurns(toolTurns)` gives stored rounds in that form.
|
|
389
|
+
|
|
390
|
+
## `llm-large-files/anthropic`
|
|
391
|
+
|
|
392
|
+
### `anthropic(options): ModelAdapter`
|
|
393
|
+
|
|
394
|
+
Claude through the Messages API. Not run against the API for this release: it is tested against
|
|
395
|
+
the request and response shapes of its documentation.
|
|
396
|
+
|
|
397
|
+
| Option | Description |
|
|
398
|
+
|---|---|
|
|
399
|
+
| `model` | Required: `"claude-opus-5-5"`. |
|
|
400
|
+
| `apiKey`, `authToken` | `x-api-key`, or `Authorization: Bearer …`. A function is called for each request. |
|
|
401
|
+
| `baseUrl`, `url`, `headers`, `version`, `betas` | For a gateway that speaks the same API: `/v1/messages` is added to `baseUrl`. `version` is the `anthropic-version` header (default `2026-10-21`). |
|
|
402
|
+
| `maxTokens` | `max_tokens` of a chat request. Default 64,000. It comes out of the context window, so the budget of a question keeps it free. |
|
|
403
|
+
| `body` | More fields for every chat request: `thinking`, `output_config`, `context_management`. |
|
|
404
|
+
| `analysisBody` | `(maxOutputTokens) => fields` for whole-file part reads, such as `{ output_config: { effort: "low" } }`. |
|
|
405
|
+
| `fallbacks` | `"default"`, or a list of `{ model }`: another model answers when a safety classifier declines the request. Off unless set: it adds a beta header that Bedrock, Vertex AI and Foundry do not take. |
|
|
406
|
+
| `cache` | Prompt caching. `true` (default) for five minutes, `"1h"`, or `false`. A cache write costs a quarter more than plain input, and a read a tenth. |
|
|
407
|
+
| `toolFilePlacement` | `"inside"` (default): pages go into the tool result as a document block. `"beside"`: after the tool results. `"none"`: `view_pages` is not offered. |
|
|
408
|
+
| `stream` | Default `true`: chat requests are streamed, which keeps a long reply from timing out. |
|
|
409
|
+
| `contextTokens`, `maxRequestBytes`, `pageTokens`, `tokenScale` | Defaults: none, 32 MB, 3,500, and 1.35 (a guess for the current tokenizer, corrected during a question by the count the API reports). |
|
|
410
|
+
| `id`, `timeoutMs`, `fetch` | As above. |
|
|
411
|
+
|
|
412
|
+
What the adapter takes care of:
|
|
413
|
+
|
|
414
|
+
- The model's turn goes back exactly as it came, thinking blocks included, and the conversation is
|
|
415
|
+
never rewritten: Claude checks its thinking blocks against the conversation they were written
|
|
416
|
+
in. So old tool results are not shortened for Claude. When the room runs out, the next request is
|
|
417
|
+
the answer. For long conversations, turn on the API's own clearing of old tool results with
|
|
418
|
+
`body: { context_management: … }` and its beta in `betas`.
|
|
419
|
+
- The request for the answer keeps the tools and sends `tool_choice: { type: "none" }`.
|
|
420
|
+
- A refusal (`stop_reason: "refusal"`) is `blockReason: "refusal: <category>"`.
|
|
421
|
+
- No sampling settings are sent: the API of this version refuses `temperature`.
|
|
422
|
+
|
|
423
|
+
`fromAnthropicMessages(history)` and `anthropicToolTurns(toolTurns)` convert a history kept as
|
|
424
|
+
Messages API messages.
|
|
425
|
+
|
|
201
426
|
## `llm-large-files/node`
|
|
202
427
|
|
|
203
428
|
### `createDocumentHandlers(files, { getOwner? })`
|
package/docs/configuration.md
CHANGED
|
@@ -9,19 +9,89 @@ planner uses them to decide what goes into a request whole.
|
|
|
9
9
|
|---|---|---|
|
|
10
10
|
| `contextTokens` | 1,000,000 | The model's context window. |
|
|
11
11
|
| `maxRequestBytes` | 10,000,000 | The largest request body your connector accepts. Checked separately from tokens: non-English text and JSON escaping make bytes run ahead of tokens. |
|
|
12
|
-
| `inlineTokens` | 200,000 | The most document text sent whole in one request. Lower it to cut cost and latency; raise it to rely on the long context more. |
|
|
13
|
-
| `reservedTokens` | 64,000 | Kept free for the answer, tool results, and growing history. |
|
|
14
|
-
| `mapChunkTokens` | 100,000 | Part size when a whole file is read in parts. Smaller parts give more detailed notes but more model calls. |
|
|
12
|
+
| `inlineTokens` | half the window, 200,000 at most | The most document text sent whole in one request. Lower it to cut cost and latency; raise it to rely on the long context more. |
|
|
13
|
+
| `reservedTokens` | a quarter of the window, 64,000 at most | Kept free for the answer, tool results, and growing history. |
|
|
14
|
+
| `mapChunkTokens` | half the window, 100,000 at most | Part size when a whole file is read in parts. Smaller parts give more detailed notes but more model calls. |
|
|
15
15
|
| `maxMapChunks` | 30 | Refuse whole-file reads needing more model calls than this. 30 parts × 100K tokens = 3M tokens of input. |
|
|
16
|
-
| `toolResultCharacters` | 24,000 | Cap on one tool result, in characters. For a log that can be
|
|
16
|
+
| `toolResultCharacters` | 12% of the window, 24,000 at most | Cap on one tool result, in characters. For a log that can be 12,000 tokens. |
|
|
17
|
+
|
|
18
|
+
For a model with a smaller window, setting the window is enough: the rest follows it.
|
|
17
19
|
|
|
18
20
|
```ts
|
|
19
|
-
createLargeFiles({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
createLargeFiles({ store, budget: { contextTokens: 128_000, maxRequestBytes: 4_000_000 } });
|
|
22
|
+
// → inlineTokens 64,000 · reservedTokens 32,000 · mapChunkTokens 64,000 · toolResultCharacters 15,360
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A field you set stays as you set it. Values that cannot work together are an error when the
|
|
26
|
+
library is created: `reservedTokens` or `mapChunkTokens` at or above `contextTokens`.
|
|
27
|
+
`resolveBudget(partial)` gives the whole budget for any set of fields.
|
|
28
|
+
|
|
29
|
+
### One library, several models
|
|
30
|
+
|
|
31
|
+
The budget of a question is the library's, made to fit the model that is asked. An adapter can say
|
|
32
|
+
what its model takes:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const small = openAiCompatible({ baseUrl, apiKey, model: "small-model", contextTokens: 128_000 });
|
|
36
|
+
const result = await askWithFiles({ files, model: small, documentIds, messages });
|
|
37
|
+
result.budget; // the library's budget, fitted to a window of 128,000 tokens
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- The smaller window holds: the library's `contextTokens`, or the model's. With an explorer, the
|
|
41
|
+
smallest of the three. The same for `maxRequestBytes`.
|
|
42
|
+
- Fields the library left open follow that window. Fields it set are kept, and lowered if they are
|
|
43
|
+
too large for it.
|
|
44
|
+
- `outputTokens` of a model is kept free on top: Claude counts `max_tokens` against the window.
|
|
45
|
+
- `tokenScale` is how many of the model's tokens one token of the library's estimate comes to. The
|
|
46
|
+
estimate is fitted to Gemini, so that is 1 there. For a tokenizer that counts more (the Claude
|
|
47
|
+
adapter says 1.35), the window is that much smaller in the library's terms.
|
|
48
|
+
- `budget` in `askWithFiles` (and in `prepare` and `tools`) changes fields for one question:
|
|
49
|
+
`budget: { inlineTokens: 20_000 }`.
|
|
50
|
+
|
|
51
|
+
### Limits and retries
|
|
52
|
+
|
|
53
|
+
What one question may do, in `limits` of `askWithFiles` and `askGemini`:
|
|
54
|
+
|
|
55
|
+
| Limit | Default | |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `toolTurns` | 12 | Chat requests for one question, counting the answer. |
|
|
58
|
+
| `callsPerTurn` | 8 | Tool calls of one model turn that are run. The others are answered "send it again if you still need it". |
|
|
59
|
+
| `wholeDocumentReads` | 1 | How often each document may be read whole. One read is up to `maxMapChunks` requests. 0 refuses them all. |
|
|
60
|
+
| `inputTokens` | none | Once the question has used this many input tokens, over all its requests, the next request is the answer. A whole-file read that would pass it is refused with the numbers. |
|
|
61
|
+
| `requests` | none | The same, for the number of requests: the chat's and the part reads' together. |
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
await askWithFiles({ files, model, documentIds, messages, limits: { toolTurns: 8, inputTokens: 2_000_000 } });
|
|
23
65
|
```
|
|
24
66
|
|
|
67
|
+
A request that failed is sent again when another try can help: HTTP 408, 409, 429 and 5xx, and a
|
|
68
|
+
connection that failed. It waits 0.25 to 0.5 seconds, then twice and four times that, or as long as
|
|
69
|
+
the provider asks (`Retry-After`, or the `retryDelay` of Gemini's `RetryInfo`). It is not sent
|
|
70
|
+
again once text of the reply was shown, after you stopped the question, or when the provider asks
|
|
71
|
+
for a longer wait than `maxDelayMs`. The part reads of a whole-file read follow the same rule.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
retry: { retries: 3, baseDelayMs: 500, maxDelayMs: 60_000 } // the defaults; retries: 0 turns it off
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Room in the request
|
|
78
|
+
|
|
79
|
+
Every tool result stays in the conversation until the question is answered, and is sent again with
|
|
80
|
+
each later request. The loop counts the request as it grows, by the library's estimate and, once
|
|
81
|
+
the provider has answered, by the provider's own count:
|
|
82
|
+
|
|
83
|
+
- Before the calls of a turn run, each is given the room that is left, up to
|
|
84
|
+
`toolResultCharacters`. A result is cut to its room and says where to go on.
|
|
85
|
+
- When the room runs short, the results of all but the last three tool rounds are replaced by
|
|
86
|
+
stand-ins: `{ document, dropped: true, lines: "1-212", note: "… Read them again with
|
|
87
|
+
read_document if you need them." }`. `steps` then holds "Older tool results were shortened to
|
|
88
|
+
make room in the request". Claude's conversation is never rewritten, so this step is skipped for
|
|
89
|
+
it.
|
|
90
|
+
- A call that still finds no room is answered "no room left, answer now", and the next request is
|
|
91
|
+
the answer.
|
|
92
|
+
|
|
93
|
+
Text tools may fill the window up to half of `reservedTokens`; the other half is the answer's.
|
|
94
|
+
|
|
25
95
|
### How the plan is made
|
|
26
96
|
|
|
27
97
|
For each request, `prepare(ids, base)` takes the size of everything else (`base.tokens`,
|
|
@@ -119,7 +189,11 @@ tokens, and its answer is dropped.
|
|
|
119
189
|
- **`text` and `onText` carry only the answer.** Without an explorer, a remark that the model makes
|
|
120
190
|
before a tool call ("Let me search…") is part of `text`. The explorer's words are not shown.
|
|
121
191
|
`onActivity` and `onStep` report its tool calls as before, and `turns` counts its requests too.
|
|
122
|
-
`usage`
|
|
192
|
+
`usage` is the total of both models, with an entry for each in `usage.byModel`; `finishReason`
|
|
193
|
+
and `lastUsage` are those of the answer.
|
|
194
|
+
- **The explorer need not be a Gemini model.** With `askWithFiles`, `explorer` is any adapter:
|
|
195
|
+
`askWithFiles({ model: gemini(…), explorer: openAiCompatible(…) })`. The answering model gets
|
|
196
|
+
the explorer's calls and results in its own provider's form.
|
|
123
197
|
- **The explorer's requests are not streamed.** Nothing it writes is shown, so each goes to
|
|
124
198
|
`explorerUrl` in one piece. The answer streams as before.
|
|
125
199
|
- **Settings are per model.** `explorerGenerationConfig` is the explorer's `generationConfig`, and
|
|
@@ -204,7 +278,7 @@ interface DocumentStore {
|
|
|
204
278
|
|
|
205
279
|
Keep `getMeta` cheap (store the metadata separately from the text): it is called on every tool
|
|
206
280
|
call. A document ready to search is kept in memory between tool calls, within `cacheBytes`
|
|
207
|
-
(default 256 MB, the least recently used dropped first; `cacheSize` caps
|
|
281
|
+
(default 256 MB, the least recently used dropped first; `cacheSize` caps the number of documents too). Every
|
|
208
282
|
use of a kept document asks the store first, so a document deleted or expired anywhere is gone
|
|
209
283
|
everywhere at once.
|
|
210
284
|
|
|
@@ -236,6 +310,11 @@ Smaller documents are loaded whole and kept in the cache: for them that is faste
|
|
|
236
310
|
- `sweep` removes files of no document (an upload that failed, a server that stopped while writing)
|
|
237
311
|
and temporary files once they are an hour old (`orphanAgeMs`), never younger ones: they may be an
|
|
238
312
|
upload in progress on another server. Run `sweep` from one place, such as a scheduled job.
|
|
313
|
+
- A document whose metadata could not be read during a sweep (the volume did not answer) is left
|
|
314
|
+
alone, whatever its age. Only metadata that is not valid is taken for a broken document.
|
|
315
|
+
- A read that fails for another reason than "no such file" is thrown, and the library passes it
|
|
316
|
+
on as `DocumentStoreError`: a busy volume is not a deleted document. A store of your own should
|
|
317
|
+
do the same: return `undefined` only for a document that is not there.
|
|
239
318
|
- Servers of an older version on the same volume (during a rolling update) read the same files and
|
|
240
319
|
ignore the index. An index left behind when one of them deletes a document is swept an hour later.
|
|
241
320
|
|