llm-large-files 0.4.1 → 0.7.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 +1400 -338
- package/README.md +217 -49
- package/dist/analyze.d.ts +5 -0
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +96 -47
- package/dist/analyze.js.map +1 -1
- package/dist/anthropic/adapter.d.ts +117 -0
- package/dist/anthropic/adapter.d.ts.map +1 -0
- package/dist/anthropic/adapter.js +542 -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 +200 -0
- package/dist/ask.d.ts.map +1 -0
- package/dist/ask.js +1402 -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/encoding.d.ts +17 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +852 -0
- package/dist/encoding.js.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +333 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +159 -0
- package/dist/events.js.map +1 -0
- package/dist/evidence.d.ts +42 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +138 -0
- package/dist/evidence.js.map +1 -0
- package/dist/extract.d.ts +35 -3
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +626 -58
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +59 -0
- package/dist/gemini/adapter.d.ts.map +1 -0
- package/dist/gemini/adapter.js +226 -0
- package/dist/gemini/adapter.js.map +1 -0
- package/dist/gemini/chat.d.ts +53 -77
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +42 -300
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/errors.d.ts +16 -0
- package/dist/gemini/errors.d.ts.map +1 -0
- package/dist/gemini/errors.js +46 -0
- package/dist/gemini/errors.js.map +1 -0
- package/dist/gemini/generate.d.ts +18 -21
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +49 -92
- package/dist/gemini/generate.js.map +1 -1
- package/dist/gemini/index.d.ts +6 -4
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/gemini/index.js +4 -3
- 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 +136 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +401 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/library.d.ts +96 -8
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +414 -96
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.d.ts +37 -1
- package/dist/map-reduce.d.ts.map +1 -1
- package/dist/map-reduce.js +255 -61
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +278 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +222 -0
- package/dist/model.js.map +1 -0
- package/dist/node/handlers.d.ts +20 -4
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +122 -20
- 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/sse.d.ts +59 -0
- package/dist/node/sse.d.ts.map +1 -0
- package/dist/node/sse.js +174 -0
- package/dist/node/sse.js.map +1 -0
- package/dist/openai/adapter.d.ts +109 -0
- package/dist/openai/adapter.d.ts.map +1 -0
- package/dist/openai/adapter.js +567 -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 +42 -0
- package/dist/output-limit.d.ts.map +1 -0
- package/dist/output-limit.js +121 -0
- package/dist/output-limit.js.map +1 -0
- package/dist/pause.d.ts +24 -0
- package/dist/pause.d.ts.map +1 -0
- package/dist/pause.js +38 -0
- package/dist/pause.js.map +1 -0
- package/dist/pdf-pages.d.ts +32 -2
- package/dist/pdf-pages.d.ts.map +1 -1
- package/dist/pdf-pages.js +275 -14
- package/dist/pdf-pages.js.map +1 -1
- package/dist/pdf-pictures.d.ts +30 -3
- package/dist/pdf-pictures.d.ts.map +1 -1
- package/dist/pdf-pictures.js +50 -8
- package/dist/pdf-pictures.js.map +1 -1
- package/dist/pdf-work.d.ts +40 -0
- package/dist/pdf-work.d.ts.map +1 -0
- package/dist/pdf-work.js +734 -0
- package/dist/pdf-work.js.map +1 -0
- package/dist/plan.d.ts +22 -4
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +61 -12
- package/dist/plan.js.map +1 -1
- package/dist/retry.d.ts +76 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +141 -0
- package/dist/retry.js.map +1 -0
- package/dist/search.d.ts +8 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +60 -10
- package/dist/search.js.map +1 -1
- package/dist/sse.d.ts +36 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +153 -0
- package/dist/sse.js.map +1 -0
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +5 -2
- package/dist/stores.js.map +1 -1
- package/dist/text-index.d.ts +6 -0
- package/dist/text-index.d.ts.map +1 -1
- package/dist/text-index.js +25 -8
- package/dist/text-index.js.map +1 -1
- package/dist/text.d.ts +62 -2
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +314 -14
- package/dist/text.js.map +1 -1
- package/dist/tools.d.ts +72 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +341 -60
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +128 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/zip-directory.d.ts +43 -0
- package/dist/zip-directory.d.ts.map +1 -0
- package/dist/zip-directory.js +130 -0
- package/dist/zip-directory.js.map +1 -0
- package/docs/README.md +288 -0
- package/docs/api.md +58 -184
- package/docs/configuration.md +34 -490
- package/docs/getting-started.md +412 -177
- package/docs/guides/anthropic.md +590 -0
- package/docs/guides/conversations.md +629 -0
- package/docs/guides/costs-and-limits.md +726 -0
- package/docs/guides/deployment.md +654 -0
- package/docs/guides/errors-and-reliability.md +735 -0
- package/docs/guides/explorer-model.md +399 -0
- package/docs/guides/openai-compatible.md +602 -0
- package/docs/guides/own-adapter-and-loop.md +1169 -0
- package/docs/guides/pdfs.md +971 -0
- package/docs/guides/storage.md +731 -0
- package/docs/guides/testing.md +1199 -0
- package/docs/guides/vertex-and-gemini.md +717 -0
- package/docs/guides/web-app.md +1589 -0
- package/docs/how-it-works.md +1022 -138
- package/docs/measurements.md +881 -0
- package/docs/publishing.md +274 -46
- package/docs/reference/anthropic.md +427 -0
- package/docs/reference/ask.md +892 -0
- package/docs/reference/errors-and-retries.md +758 -0
- package/docs/reference/events.md +993 -0
- package/docs/reference/gemini.md +823 -0
- package/docs/reference/library.md +1467 -0
- package/docs/reference/node.md +528 -0
- package/docs/reference/openai.md +385 -0
- package/docs/reference/tools.md +883 -0
- package/docs/security.md +902 -90
- package/docs/troubleshooting.md +1390 -0
- package/package.json +22 -4
- package/src/analyze.ts +93 -42
- package/src/anthropic/adapter.ts +611 -0
- package/src/anthropic/index.ts +2 -0
- package/src/ask.ts +1560 -0
- package/src/budget.ts +71 -0
- package/src/encoding.ts +850 -0
- package/src/errors.ts +17 -0
- package/src/events.ts +442 -0
- package/src/evidence.ts +165 -0
- package/src/extract.ts +602 -62
- package/src/gemini/adapter.ts +271 -0
- package/src/gemini/chat.ts +87 -355
- package/src/gemini/errors.ts +48 -0
- package/src/gemini/generate.ts +67 -94
- package/src/gemini/index.ts +6 -4
- package/src/gemini/sse.ts +1 -34
- package/src/http.ts +434 -0
- package/src/index.ts +55 -4
- package/src/library.ts +497 -97
- package/src/map-reduce.ts +266 -59
- package/src/model.ts +433 -0
- package/src/node/handlers.ts +137 -22
- package/src/node/index.ts +2 -0
- package/src/node/sse.ts +198 -0
- package/src/openai/adapter.ts +613 -0
- package/src/openai/index.ts +2 -0
- package/src/output-limit.ts +135 -0
- package/src/pause.ts +41 -0
- package/src/pdf-pages.ts +268 -15
- package/src/pdf-pictures.ts +56 -9
- package/src/pdf-work.ts +722 -0
- package/src/plan.ts +68 -12
- package/src/retry.ts +176 -0
- package/src/search.ts +63 -10
- package/src/sse.ts +159 -0
- package/src/stores.ts +5 -2
- package/src/text-index.ts +26 -7
- package/src/text.ts +323 -13
- package/src/tools.ts +338 -62
- package/src/types.ts +129 -5
- package/src/zip-directory.ts +136 -0
package/docs/getting-started.md
CHANGED
|
@@ -1,257 +1,492 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Getting started
|
|
2
2
|
|
|
3
|
-
This
|
|
4
|
-
|
|
3
|
+
This page takes you from `npm install` to a first answer about a file, then through the steps of
|
|
4
|
+
adding the library to an app. Each step is short and links to the guide that explains it.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Install
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
npm install llm-large-files
|
|
10
|
-
npm install jszip unpdf # optional: DOCX/PPTX and PDF support
|
|
11
|
-
npm install @cantoo/pdf-lib # optional: let the model look at pages of a PDF (pictures, charts)
|
|
12
10
|
```
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
The library needs Node.js 20.19 or later. It is an ES module, and its TypeScript types come with
|
|
13
|
+
it. From CommonJS code, `require("llm-large-files")` works on the Node versions that load ES
|
|
14
|
+
modules with `require()` by default: 20.19 and later in Node 20, 22.12 and later, and 23 and later.
|
|
15
|
+
On Node 21 and on 22.0 to 22.11, load it with `import("llm-large-files")`.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
// large-files.ts
|
|
18
|
-
import { createLargeFiles, FileDocumentStore } from "llm-large-files";
|
|
17
|
+
Text, Markdown, logs, JSON and CSV need nothing more. Three optional packages add the rest:
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npm install jszip unpdf @cantoo/pdf-lib # Node 24 and later
|
|
21
|
+
npm install jszip unpdf@1 @cantoo/pdf-lib # Node 22
|
|
22
|
+
npm install jszip unpdf@1.7.0 @cantoo/pdf-lib # Node 20
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
| Package | What it enables |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `jszip` | DOCX and PPTX files. |
|
|
28
|
+
| `unpdf` | PDF files: their text, with tables rebuilt as rows. |
|
|
29
|
+
| `@cantoo/pdf-lib` | The model can look at the pages of a PDF (`view_pages`, with `keepOriginals`). The text of a PDF also marks the pages that show a picture. |
|
|
30
|
+
|
|
31
|
+
Without the package a format needs, its upload fails with an error that names the package, such
|
|
32
|
+
as `Reading PDF files needs the optional dependency "unpdf".` Install `@cantoo/pdf-lib` before you
|
|
33
|
+
turn on `keepOriginals`: without it, every look at a page fails. The details are in
|
|
34
|
+
[PDFs](./guides/pdfs.md).
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
On Node 24 and later, `npm install unpdf` installs unpdf 2, which asks for Node 24. On Node 22,
|
|
37
|
+
install `unpdf@1`, and on Node 20, `unpdf@1.7.0`. An unpdf that cannot read PDFs on your version
|
|
38
|
+
of Node is refused at the first PDF, with a message that says what to install, such as
|
|
39
|
+
`The unpdf installed cannot read PDF files on Node 20 (…). Install unpdf 1.7.0 (npm install unpdf@1.7.0), or run Node 22 or later.`
|
|
40
|
+
|
|
41
|
+
The Vertex AI samples on this page also use Google's auth library, which is not a dependency of
|
|
42
|
+
this package:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install google-auth-library
|
|
32
46
|
```
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
`DocumentStore` over Redis, S3, or your database (see [configuration](configuration.md#stores)).
|
|
48
|
+
## Quickstart
|
|
36
49
|
|
|
37
|
-
|
|
50
|
+
This script ingests one file and asks one question about it, with Gemini on Vertex AI. You need a
|
|
51
|
+
Google Cloud project with Vertex AI turned on, and Application Default Credentials (on your own
|
|
52
|
+
machine, `gcloud auth application-default login`).
|
|
38
53
|
|
|
39
54
|
```ts
|
|
40
|
-
|
|
41
|
-
import {
|
|
55
|
+
// quickstart.mts
|
|
56
|
+
import { readFile } from "node:fs/promises";
|
|
57
|
+
import { basename } from "node:path";
|
|
58
|
+
import { GoogleAuth } from "google-auth-library";
|
|
59
|
+
import { createLargeFiles, MemoryDocumentStore } from "llm-large-files";
|
|
60
|
+
import { askGemini, vertexAi } from "llm-large-files/gemini";
|
|
42
61
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
const [path, question] = process.argv.slice(2);
|
|
63
|
+
if (!path || !question) throw new Error('Usage: node quickstart.mts <file> "<question>"');
|
|
64
|
+
|
|
65
|
+
// 1. The library. This one keeps documents in memory, for as long as the process runs.
|
|
66
|
+
const files = createLargeFiles({ store: new MemoryDocumentStore() });
|
|
67
|
+
|
|
68
|
+
// 2. Ingest the file: its text is extracted, measured and stored.
|
|
69
|
+
const doc = await files.ingest({ name: basename(path), bytes: await readFile(path) });
|
|
70
|
+
console.log(`${doc.name}: ${doc.format}, ${doc.lines} lines, about ${doc.estimatedTokens} tokens\n`);
|
|
71
|
+
|
|
72
|
+
// 3. Ask. The access token comes from Application Default Credentials.
|
|
73
|
+
const auth = new GoogleAuth({ scopes: "https://www.googleapis.com/auth/cloud-platform" });
|
|
74
|
+
const endpoint = vertexAi({
|
|
75
|
+
project: process.env.GOOGLE_CLOUD_PROJECT!,
|
|
76
|
+
location: "global", // the default; or "us", "eu", or a region such as "europe-west4"
|
|
77
|
+
model: "gemini-3.8-flash",
|
|
78
|
+
accessToken: async () => (await auth.getAccessToken())!,
|
|
47
79
|
});
|
|
48
80
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
81
|
+
const result = await askGemini({
|
|
82
|
+
files,
|
|
83
|
+
endpoint,
|
|
84
|
+
documentIds: [doc.id],
|
|
85
|
+
messages: [{ role: "user", text: question }],
|
|
86
|
+
onText: (delta) => process.stdout.write(delta), // the answer, as it streams
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
console.log(`\n\n${result.plan.inline.length > 0 ? "Read whole" : "Searched with tools"}, ${result.turns} chat request(s)`);
|
|
90
|
+
for (const step of result.steps) console.log(`- ${step}`);
|
|
54
91
|
```
|
|
55
92
|
|
|
56
|
-
|
|
93
|
+
Node 22.18 and later in Node 22, and Node 23.6 and later, run TypeScript files directly:
|
|
57
94
|
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
"bytes": 5082044, "lines": 60000, "estimatedTokens": 1270511, "expiresAt": "2026-11-09T07:43:14.435Z" }
|
|
95
|
+
```bash
|
|
96
|
+
GOOGLE_CLOUD_PROJECT=your-project-id node quickstart.mts ./app.log "What failed first, and when?"
|
|
61
97
|
```
|
|
62
98
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
99
|
+
In PowerShell, set the variable with `$env:GOOGLE_CLOUD_PROJECT = "your-project-id"`, then run
|
|
100
|
+
`node quickstart.mts ./app.log "What failed first, and when?"`. On older versions of Node, compile
|
|
101
|
+
the file first, with `typescript` and `@types/node` installed:
|
|
102
|
+
`npx tsc --module nodenext --target es2022 quickstart.mts`. Then run `node quickstart.mjs` with
|
|
103
|
+
the same arguments.
|
|
104
|
+
|
|
105
|
+
What happened:
|
|
106
|
+
|
|
107
|
+
- `ingest` extracted the text of the file, counted its lines and estimated its tokens, and stored
|
|
108
|
+
it. The `doc.id` it returned is how you name the document from then on.
|
|
109
|
+
- `askGemini` planned the request. A document that fits the budget goes into the prompt whole: by
|
|
110
|
+
default up to 200,000 tokens of document text, in a window of 1,000,000 tokens and a request of
|
|
111
|
+
10 MB. A larger one becomes a short card, and the model gets tools to search it, read lines of
|
|
112
|
+
it, get an overview of it, and read it whole in parts.
|
|
113
|
+
- When the model used tools, the loop ran its calls and sent it what they returned, until it
|
|
114
|
+
answered: at most 12 chat requests by default, the last of which must be answered in text, and
|
|
115
|
+
one more when that answer comes back without text. `result.steps` lists what it did, for example
|
|
116
|
+
`Search app.log (exact) for “timeout” — 12 matching lines`.
|
|
67
117
|
|
|
68
|
-
|
|
69
|
-
`node:http`, Express, Koa (`ctx.req`, `ctx.res`), Fastify (`request.raw`, `reply.raw`), and Next.js
|
|
70
|
-
API routes on the Node runtime. Not using Node HTTP? Call `files.ingest({ name, mimeType, bytes, owner })`
|
|
71
|
-
yourself and return `toDocumentSummary(meta)`.
|
|
118
|
+
The details of the plan and the loop are in [How it works](./how-it-works.md).
|
|
72
119
|
|
|
73
|
-
|
|
120
|
+
The quickstart works the same with other providers. Each sample below replaces its step 3, from
|
|
121
|
+
`const auth` to the end of the `askGemini` call. Put the sample's imports in place of the two
|
|
122
|
+
Vertex AI imports, those of `google-auth-library` and `llm-large-files/gemini`.
|
|
123
|
+
|
|
124
|
+
### With a Gemini API key
|
|
125
|
+
|
|
126
|
+
`askGemini` takes the Gemini Developer API with an API key:
|
|
74
127
|
|
|
75
128
|
```ts
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
const result = await response.json();
|
|
87
|
-
if (!response.ok) throw new Error(result.error);
|
|
88
|
-
return result; // keep result.id with the conversation
|
|
89
|
-
}
|
|
129
|
+
import { askGemini, geminiApi } from "llm-large-files/gemini";
|
|
130
|
+
|
|
131
|
+
const result = await askGemini({
|
|
132
|
+
files,
|
|
133
|
+
endpoint: geminiApi({ apiKey: process.env.GEMINI_API_KEY!, model: "gemini-3.8-flash" }),
|
|
134
|
+
documentIds: [doc.id],
|
|
135
|
+
messages: [{ role: "user", text: question }],
|
|
136
|
+
onText: (delta) => process.stdout.write(delta),
|
|
137
|
+
});
|
|
90
138
|
```
|
|
91
139
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
140
|
+
### With an OpenAI-compatible model
|
|
141
|
+
|
|
142
|
+
`askGemini` is `askWithFiles` with a Gemini model. With any other model, call `askWithFiles` and
|
|
143
|
+
pass the model as an adapter. `openAiCompatible()` speaks Chat Completions: OpenAI, Azure OpenAI,
|
|
144
|
+
DeepSeek, OpenRouter, vLLM, Ollama, LiteLLM, llama.cpp.
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { askWithFiles } from "llm-large-files";
|
|
148
|
+
import { openAiCompatible } from "llm-large-files/openai";
|
|
149
|
+
|
|
150
|
+
const model = openAiCompatible({
|
|
151
|
+
baseUrl: "https://api.openai.com/v1", // the default; DeepSeek, OpenRouter, vLLM, Ollama: their own
|
|
152
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
153
|
+
model: "gpt-5.5",
|
|
154
|
+
contextTokens: 400_000, // your model's context window: the plan follows it
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const result = await askWithFiles({
|
|
158
|
+
files,
|
|
159
|
+
model,
|
|
160
|
+
documentIds: [doc.id],
|
|
161
|
+
messages: [{ role: "user", text: question }],
|
|
162
|
+
onText: (delta) => process.stdout.write(delta),
|
|
163
|
+
});
|
|
164
|
+
```
|
|
97
165
|
|
|
98
|
-
|
|
166
|
+
Set `contextTokens` to the window of your model. Without it, the plan assumes the library's
|
|
167
|
+
window, 1,000,000 tokens unless you set another. The recipe for each server is in
|
|
168
|
+
[OpenAI-compatible endpoints](./guides/openai-compatible.md).
|
|
99
169
|
|
|
100
|
-
### With
|
|
170
|
+
### With Claude
|
|
101
171
|
|
|
102
172
|
```ts
|
|
103
|
-
import {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
generationConfig: { temperature: 0.3, maxOutputTokens: 8192 },
|
|
119
|
-
signal: abort.signal,
|
|
120
|
-
onText: (text) => send("text", text), // answer, streamed
|
|
121
|
-
onActivity: (text) => send("activity", text), // "Searching app.log for “timeout”…"
|
|
122
|
-
onStep: (text) => send("step", text), // "Search app.log … — 12 matching lines"
|
|
123
|
-
});
|
|
124
|
-
send("done", {});
|
|
125
|
-
} catch (error) {
|
|
126
|
-
send("error", error instanceof DocumentsNotFoundError
|
|
127
|
-
? "A file has expired. Please attach it again."
|
|
128
|
-
: String((error as Error).message));
|
|
129
|
-
}
|
|
130
|
-
res.end();
|
|
173
|
+
import { askWithFiles } from "llm-large-files";
|
|
174
|
+
import { anthropic } from "llm-large-files/anthropic";
|
|
175
|
+
|
|
176
|
+
const model = anthropic({
|
|
177
|
+
apiKey: process.env.ANTHROPIC_API_KEY!,
|
|
178
|
+
model: "claude-opus-5-5",
|
|
179
|
+
contextTokens: 1_000_000, // your model's context window: the plan follows it
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const result = await askWithFiles({
|
|
183
|
+
files,
|
|
184
|
+
model,
|
|
185
|
+
documentIds: [doc.id],
|
|
186
|
+
messages: [{ role: "user", text: question }],
|
|
187
|
+
onText: (delta) => process.stdout.write(delta),
|
|
131
188
|
});
|
|
132
189
|
```
|
|
133
190
|
|
|
134
|
-
|
|
191
|
+
Thinking, streaming and gateways for Claude are in [Claude](./guides/anthropic.md).
|
|
192
|
+
|
|
193
|
+
## Integrate it into your app
|
|
194
|
+
|
|
195
|
+
The quickstart holds everything in one process for one question. An app creates the library once,
|
|
196
|
+
takes uploads in one request and questions in others, and keeps the conversation between them.
|
|
197
|
+
The samples below use Gemini on Vertex AI. With another provider, use `askWithFiles` as above:
|
|
198
|
+
the options these samples use are the same, with `model` in place of `endpoint`. Model settings
|
|
199
|
+
that `askGemini` takes (`generationConfig`, `toolFilePlacement`, the waits) are options of the
|
|
200
|
+
adapter there.
|
|
135
201
|
|
|
136
|
-
1.
|
|
137
|
-
2. Plans the documents against your budget. Each one goes in whole, or becomes a card plus tools.
|
|
138
|
-
3. Adds each document's text or card at the start of the first user message, where it stays for
|
|
139
|
-
the whole conversation (so follow-up questions reuse Gemini's prompt cache), and a short tool
|
|
140
|
-
guide to the system prompt.
|
|
141
|
-
4. Runs the tool loop if needed (up to `maxToolTurns` requests, default 12). If the model keeps
|
|
142
|
-
searching, the last request is sent without tools so it has to answer. `result.answered` is
|
|
143
|
-
`false` in the rare case that there is still no answer (a blocked prompt, or an empty reply).
|
|
202
|
+
### 1. Create the library once
|
|
144
203
|
|
|
145
|
-
|
|
204
|
+
Create the library and the endpoint when the server starts, and share them between requests.
|
|
146
205
|
|
|
147
206
|
```ts
|
|
207
|
+
// large-files.ts: created once, when the server starts, and shared by every request.
|
|
148
208
|
import { GoogleAuth } from "google-auth-library";
|
|
209
|
+
import { createLargeFiles, FileDocumentStore } from "llm-large-files";
|
|
149
210
|
import { vertexAi } from "llm-large-files/gemini";
|
|
150
211
|
|
|
212
|
+
export const files = createLargeFiles({
|
|
213
|
+
// Text extracted from uploads is kept here. Several servers need one shared store.
|
|
214
|
+
store: new FileDocumentStore(process.env.LARGE_FILES_DIR ?? "./data/large-files"),
|
|
215
|
+
// The context window of the model that answers (1,000,000 is the default). The rest follows it.
|
|
216
|
+
budget: { contextTokens: 1_000_000 },
|
|
217
|
+
});
|
|
218
|
+
|
|
151
219
|
const auth = new GoogleAuth({ scopes: "https://www.googleapis.com/auth/cloud-platform" });
|
|
152
|
-
const endpoint = vertexAi({
|
|
153
|
-
project:
|
|
154
|
-
location: "global", // or "us", "eu", "europe-west4", …
|
|
220
|
+
export const endpoint = vertexAi({
|
|
221
|
+
project: process.env.GOOGLE_CLOUD_PROJECT!,
|
|
155
222
|
model: "gemini-3.8-flash",
|
|
156
223
|
accessToken: async () => (await auth.getAccessToken())!,
|
|
157
224
|
});
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**An enterprise gateway** that proxies Generate Content:
|
|
161
225
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
headers: { Authorization: `Bearer ${process.env.GATEWAY_TOKEN}`, "Content-Type": "application/json" },
|
|
167
|
-
};
|
|
226
|
+
// An expired document is ignored at once. This frees the space it took.
|
|
227
|
+
setInterval(() => {
|
|
228
|
+
files.sweep().catch((error) => console.error("sweep failed", error));
|
|
229
|
+
}, 60 * 60 * 1000).unref();
|
|
168
230
|
```
|
|
169
231
|
|
|
170
|
-
|
|
232
|
+
Documents are kept for 72 hours (`ttlMs`), and uploads are taken up to 100 MB
|
|
233
|
+
(`maxUploadBytes`). To let the model look at the pages of a PDF, add `keepOriginals: ["pdf"]`
|
|
234
|
+
([PDFs](./guides/pdfs.md)). Every option is in the
|
|
235
|
+
[library reference](./reference/library.md#largefilesoptions).
|
|
171
236
|
|
|
172
|
-
|
|
173
|
-
|
|
237
|
+
Where the documents live is up to your app: a shared volume for `FileDocumentStore`, or a store of
|
|
238
|
+
your own over your database or object storage, laid out per user and per chat session. See
|
|
239
|
+
[Storage](./guides/storage.md), and [Deployment](./guides/deployment.md) for several servers.
|
|
240
|
+
Vertex AI settings for production (credentials, location, quotas) are in
|
|
241
|
+
[Gemini and Vertex AI](./guides/vertex-and-gemini.md).
|
|
174
242
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
243
|
+
### 2. Accept uploads
|
|
244
|
+
|
|
245
|
+
`createDocumentHandlers` gives you upload, get and delete handlers for any Node HTTP server:
|
|
246
|
+
`node:http`, Express, Fastify (`request.raw`, `reply.raw`), and Next.js API routes on the Node
|
|
247
|
+
runtime (Fastify and Next.js need a step first: see
|
|
248
|
+
[Web app](./guides/web-app.md#mount-them-in-plain-nodehttp)).
|
|
178
249
|
|
|
179
250
|
```ts
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
251
|
+
import express from "express";
|
|
252
|
+
import { createDocumentHandlers } from "llm-large-files/node";
|
|
253
|
+
import { files } from "./large-files.js";
|
|
254
|
+
|
|
255
|
+
const app = express();
|
|
256
|
+
const documents = createDocumentHandlers(files, {
|
|
257
|
+
// Uploads become private to this user. undefined: anonymous. currentUserId is your auth.
|
|
258
|
+
getOwner: (request) => currentUserId(request),
|
|
184
259
|
});
|
|
260
|
+
|
|
261
|
+
// Before any body parser: the body of an upload is the raw file.
|
|
262
|
+
app.post("/api/documents", documents.upload);
|
|
263
|
+
app.get("/api/documents/:id", (req, res) => documents.get(req, res, req.params.id));
|
|
264
|
+
app.delete("/api/documents/:id", (req, res) => documents.remove(req, res, req.params.id));
|
|
265
|
+
app.use(express.json());
|
|
185
266
|
```
|
|
186
267
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
268
|
+
The browser posts the raw file, with its name in an `X-File-Name` header (URI-encoded). The
|
|
269
|
+
response is a `201` with a `DocumentSummary`: `id`, `name`, `format`, `lines`, `estimatedTokens`,
|
|
270
|
+
`expiresAt` and more. A text file that was not valid UTF-8 also has `encoding`, the older encoding
|
|
271
|
+
it was read in (`"windows-1255"`), or `replacedCharacters`, the characters stored as �, or both.
|
|
272
|
+
Keep the `id` with the chat session. Not on a Node HTTP server, or taking multipart forms? Call
|
|
273
|
+
`files.ingest({ name, mimeType, bytes, owner })` yourself and return `toDocumentSummary(meta)`.
|
|
190
274
|
|
|
191
|
-
|
|
275
|
+
`getOwner` returns the signed-in user's ID, or `undefined` for an anonymous upload. An empty
|
|
276
|
+
string, a string of spaces or `null` would be one owner shared by every caller without a user, so
|
|
277
|
+
the upload is refused: `500` with `{ "error": "Upload failed (empty owner)." }`. Return the ID
|
|
278
|
+
itself, not the user object (`{ "error": "Upload failed (owner is not a string)." }`). Both come
|
|
279
|
+
before the body is read.
|
|
192
280
|
|
|
193
|
-
The
|
|
194
|
-
|
|
281
|
+
The browser side, every status and other servers are in [Web app](./guides/web-app.md); the
|
|
282
|
+
routes in full are in the [node reference](./reference/node.md).
|
|
283
|
+
|
|
284
|
+
### 3. Ask with the user's history, and stream the answer
|
|
285
|
+
|
|
286
|
+
Send the whole conversation on every turn, with all the documents of the session. The plan is made
|
|
287
|
+
again for each question, because the history grows.
|
|
195
288
|
|
|
196
289
|
```ts
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
290
|
+
// chat.ts
|
|
291
|
+
import type { ChatTurn, ToolTurn } from "llm-large-files";
|
|
292
|
+
import { askGemini } from "llm-large-files/gemini";
|
|
293
|
+
import { endpoint, files } from "./large-files.js";
|
|
294
|
+
|
|
295
|
+
// A chat session as your app stores it: who owns it, its documents, and its turns.
|
|
296
|
+
export type Session = { userId: string; documentIds: string[]; turns: StoredTurn[] };
|
|
297
|
+
export type StoredTurn = { question: string; toolTurns: ToolTurn[]; answer: string };
|
|
298
|
+
|
|
299
|
+
export async function ask(session: Session, question: string, send: (event: string, data: unknown) => void, signal: AbortSignal) {
|
|
300
|
+
// The whole history, on every turn, with the tool rounds of each earlier question in its place.
|
|
301
|
+
const messages: Array<ChatTurn | ToolTurn> = session.turns.flatMap((turn): Array<ChatTurn | ToolTurn> => [
|
|
302
|
+
{ role: "user", text: turn.question },
|
|
303
|
+
...turn.toolTurns,
|
|
304
|
+
{ role: "assistant", text: turn.answer },
|
|
305
|
+
]);
|
|
306
|
+
messages.push({ role: "user", text: question });
|
|
307
|
+
|
|
308
|
+
const result = await askGemini({
|
|
309
|
+
files,
|
|
310
|
+
endpoint,
|
|
311
|
+
messages,
|
|
312
|
+
documentIds: session.documentIds, // every document of the session, on every turn
|
|
313
|
+
owner: session.userId,
|
|
314
|
+
signal,
|
|
315
|
+
onText: (delta) => send("text", delta), // the answer, as it streams
|
|
316
|
+
onActivity: (text) => send("activity", text), // short-lived: "Search app.log (keywords) for “timeout”…"
|
|
317
|
+
onStep: (text) => send("step", text), // done: "Search app.log (exact) for “timeout” — 12 matching lines"
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
if (!result.answered) {
|
|
321
|
+
send("error", "No answer came back. Please ask again.");
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
// Keep what the question read with its answer: the next question starts from it.
|
|
325
|
+
session.turns.push({ question, toolTurns: result.toolTurns, answer: result.text });
|
|
326
|
+
send("done", {});
|
|
327
|
+
}
|
|
201
328
|
```
|
|
202
329
|
|
|
203
|
-
|
|
204
|
-
|
|
330
|
+
- The last message must be the user's question. `"model"` is accepted for `"assistant"`.
|
|
331
|
+
- `owner` must be the owner the documents were uploaded with. A document of another owner is
|
|
332
|
+
treated as missing.
|
|
333
|
+
- `send` stands for your transport: in a web app, a Server-Sent Event. The answer streams when
|
|
334
|
+
`onText` is set and the endpoint has a stream URL, as `vertexAi()` and `geminiApi()` do.
|
|
335
|
+
- Show the steps and activity lines as plain text, never as markdown or HTML: they quote what the
|
|
336
|
+
model sent, which a file can steer ([Security](./security.md#what-the-library-logs)).
|
|
337
|
+
- Abort `signal` when the client goes away, so the question stops.
|
|
338
|
+
- `answered` is `false` when the model's last turn had no text: a blocked prompt, a reply cut off,
|
|
339
|
+
or a tool call that could not be read. An answer that comes back empty, or with a tool call in
|
|
340
|
+
place of the text, is asked for once more first. Show your own message then.
|
|
205
341
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
342
|
+
The route, the browser side and cancelling are in [Web app](./guides/web-app.md). To have a
|
|
343
|
+
second, cheaper model search the files while this one writes the answer, add `explorerModel` to
|
|
344
|
+
`vertexAi()`: see [An explorer model](./guides/explorer-model.md).
|
|
345
|
+
|
|
346
|
+
### 4. Keep `toolTurns` with the answer
|
|
347
|
+
|
|
348
|
+
`result.toolTurns` holds the tool calls of the question and what they returned, as plain JSON.
|
|
349
|
+
Store it with the answer, and put it back between the question and the answer, as `ask()` does
|
|
350
|
+
above. The model then sees what it found before, and a follow-up question often needs no new
|
|
351
|
+
search. A call whose result is still in the conversation in full is not run again: the model gets
|
|
352
|
+
a pointer to it, and the step ends with `— already shown above`.
|
|
209
353
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
costs and the measurements are in [Pictures in PDFs](configuration.md#pictures-in-pdfs), and what
|
|
213
|
-
to think about before turning it on in [Security](security.md#original-files).
|
|
354
|
+
Storing history across servers, keeping it inside the window, and converting history that is in a
|
|
355
|
+
provider's own form are in [Conversations](./guides/conversations.md).
|
|
214
356
|
|
|
215
|
-
###
|
|
357
|
+
### 5. Handle errors
|
|
216
358
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
(
|
|
359
|
+
Before a question fails, the loop sends a failed request again when a wait can mend it, recovers
|
|
360
|
+
from a request too large, and asks once more after an empty or unreadable turn
|
|
361
|
+
([Errors and reliability](./guides/errors-and-reliability.md)). What still fails is thrown:
|
|
220
362
|
|
|
221
363
|
```ts
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
//
|
|
364
|
+
import { DocumentsNotFoundError, DocumentStoreError, errorKindOf, partialResultOf } from "llm-large-files";
|
|
365
|
+
import { ask } from "./chat.js";
|
|
366
|
+
|
|
367
|
+
// session, question, send and signal: as in step 3.
|
|
368
|
+
try {
|
|
369
|
+
await ask(session, question, send, signal);
|
|
370
|
+
} catch (error) {
|
|
371
|
+
if (!signal.aborted) send("error", messageFor(error)); // after an abort, no one is listening
|
|
372
|
+
// What a failed question had found and used, or undefined.
|
|
373
|
+
const partial = partialResultOf(error);
|
|
374
|
+
if (partial) console.warn(`The failed question used ${partial.usage.inputTokens} input tokens`);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function messageFor(error: unknown): string {
|
|
378
|
+
if (error instanceof DocumentsNotFoundError) return "A file is no longer available. Please attach it again.";
|
|
379
|
+
if (error instanceof DocumentStoreError) return "Your files could not be read just now. Please try again.";
|
|
380
|
+
switch (errorKindOf(error)) {
|
|
381
|
+
case "quota":
|
|
382
|
+
return "The assistant is not available right now. Please tell support.";
|
|
383
|
+
case "rate_limit":
|
|
384
|
+
return "The assistant is busy. Please try again in a minute.";
|
|
385
|
+
case "auth":
|
|
386
|
+
case "invalid":
|
|
387
|
+
return "The assistant is not set up correctly. Please tell support.";
|
|
388
|
+
case "context_overflow":
|
|
389
|
+
return "This conversation is too long for the model. Please start a new chat.";
|
|
390
|
+
case undefined:
|
|
391
|
+
return "Something went wrong. Please try again.";
|
|
392
|
+
default:
|
|
393
|
+
return "The model did not answer. Please try again.";
|
|
394
|
+
}
|
|
395
|
+
}
|
|
230
396
|
```
|
|
231
397
|
|
|
232
|
-
`
|
|
233
|
-
|
|
398
|
+
- `DocumentsNotFoundError` (`.ids`): a document expired, was deleted, was never uploaded, or
|
|
399
|
+
belongs to another owner. It is thrown before any model request.
|
|
400
|
+
- `DocumentStoreError`: the store could not be read just now. It does not mean the documents are
|
|
401
|
+
gone: the same request may work a moment later.
|
|
402
|
+
- `ModelRequestError`: the model failed. `.kind` says how (`quota`, `rate_limit`, `timeout`,
|
|
403
|
+
`unreachable`, `server`, `auth`, `invalid`, `context_overflow`), and `.status` is the HTTP
|
|
404
|
+
status, or 0 when no answer came. `errorKindOf(error)` reads the kind of any error that has one.
|
|
405
|
+
- `partialResultOf(error)` gives the steps, `toolTurns` and `usage` of a question that failed
|
|
406
|
+
under way, so you can still keep and count them.
|
|
234
407
|
|
|
235
|
-
|
|
236
|
-
[
|
|
408
|
+
What to tell the user for each case, and how to change the retries and the waits, are in
|
|
409
|
+
[Errors and reliability](./guides/errors-and-reliability.md).
|
|
237
410
|
|
|
238
|
-
|
|
411
|
+
### 6. Set limits
|
|
239
412
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
413
|
+
A question costs what its requests take in. These options bound it:
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
import { askGemini } from "llm-large-files/gemini";
|
|
417
|
+
|
|
418
|
+
// files, endpoint, messages and session: as in step 3.
|
|
419
|
+
const result = await askGemini({
|
|
420
|
+
files,
|
|
421
|
+
endpoint,
|
|
422
|
+
messages,
|
|
423
|
+
documentIds: session.documentIds,
|
|
424
|
+
owner: session.userId,
|
|
425
|
+
limits: {
|
|
426
|
+
toolTurns: 8, // chat requests for one question, the answer included; part reads not counted (default 12)
|
|
427
|
+
inputTokens: 400_000, // input tokens for one question, over all its requests (default: none)
|
|
428
|
+
},
|
|
429
|
+
});
|
|
430
|
+
console.log(result.usage.inputTokens, result.usage.outputTokens, result.usage.requests);
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
- `budget.contextTokens` in `createLargeFiles` is the window the plan fits the request into. With
|
|
434
|
+
`askWithFiles`, an adapter's `contextTokens` applies too, and the smaller wins.
|
|
435
|
+
- `limits` also takes `callsPerTurn` (default 8), `wholeDocumentReads` (default 1 per document)
|
|
436
|
+
and `requests` (default: none). See [`AskLimits`](./reference/ask.md#asklimits). An answer that
|
|
437
|
+
comes back without text is asked for once more, which can be one request past `toolTurns`; it is
|
|
438
|
+
not made once `requests` or `inputTokens` is reached.
|
|
439
|
+
- `result.usage` is what the question used, in all and for each model: input, cached input, output
|
|
440
|
+
and thought tokens, and requests. Store it per user or per session to count costs.
|
|
441
|
+
|
|
442
|
+
What costs most, and how to set the budget for each model, are in
|
|
443
|
+
[Costs and limits](./guides/costs-and-limits.md).
|
|
247
444
|
|
|
248
445
|
## Run the demo
|
|
249
446
|
|
|
447
|
+
The repository has two examples that run as they are, with a Gemini API key:
|
|
448
|
+
|
|
250
449
|
```bash
|
|
251
|
-
git clone https://github.com/renanbazinin/llm-large-files
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
450
|
+
git clone https://github.com/renanbazinin/llm-large-files
|
|
451
|
+
cd llm-large-files
|
|
452
|
+
npm install
|
|
453
|
+
npm run build
|
|
454
|
+
GEMINI_API_KEY=... node examples/server.ts # then open http://localhost:3000
|
|
455
|
+
GEMINI_API_KEY=... node examples/ask-cli.ts ./big.log "What failed first, and when?"
|
|
255
456
|
```
|
|
256
457
|
|
|
257
|
-
|
|
458
|
+
- `examples/server.ts` is a chat server in one file, on `node:http`: an upload route
|
|
459
|
+
(`createDocumentHandlers`), answers streamed as Server-Sent Events, and a small web page. It
|
|
460
|
+
stores uploads in `.data/large-files` and keeps PDFs, so the model can look at their pages.
|
|
461
|
+
`GEMINI_MODEL` picks the model (default `gemini-3.8-flash`), and `GEMINI_EXPLORER_MODEL` adds an
|
|
462
|
+
explorer model. Every upload is anonymous.
|
|
463
|
+
- `examples/ask-cli.ts` asks one question about one file from the command line. Two more
|
|
464
|
+
arguments are optional: the model, and an explorer model.
|
|
465
|
+
|
|
466
|
+
Both need a Node that runs TypeScript directly: 22.18 and later in Node 22, or 23.6 and later.
|
|
467
|
+
Build first: the examples import
|
|
468
|
+
the package by name, which resolves to the repository's own `dist/`. `npm install` in the
|
|
469
|
+
repository also installs the optional packages, so every format works. In PowerShell, set the key
|
|
470
|
+
with `$env:GEMINI_API_KEY = "..."` and then run `node examples/server.ts`.
|
|
471
|
+
|
|
472
|
+
## Next steps
|
|
473
|
+
|
|
474
|
+
- [Gemini and Vertex AI](./guides/vertex-and-gemini.md): endpoints, access tokens, thinking,
|
|
475
|
+
gateways, Vertex quotas and errors.
|
|
476
|
+
- [OpenAI-compatible endpoints](./guides/openai-compatible.md) and [Claude](./guides/anthropic.md):
|
|
477
|
+
the other adapters.
|
|
478
|
+
- [An explorer model](./guides/explorer-model.md): a cheaper model that searches while another
|
|
479
|
+
answers.
|
|
480
|
+
- [Web app](./guides/web-app.md): uploads, streaming over SSE, cancelling.
|
|
481
|
+
- [Conversations](./guides/conversations.md): history, `toolTurns`, converters.
|
|
482
|
+
- [Storage](./guides/storage.md): your own store, per user and per session.
|
|
483
|
+
- [Deployment](./guides/deployment.md): several servers, memory, proxies and timeouts.
|
|
484
|
+
- [Errors and reliability](./guides/errors-and-reliability.md) and
|
|
485
|
+
[Costs and limits](./guides/costs-and-limits.md).
|
|
486
|
+
- [PDFs](./guides/pdfs.md): tables, pictures, scans and page views.
|
|
487
|
+
- [Your own adapter and loop](./guides/own-adapter-and-loop.md) and
|
|
488
|
+
[Testing](./guides/testing.md).
|
|
489
|
+
- [How it works](./how-it-works.md), [Security](./security.md) and
|
|
490
|
+
[Troubleshooting](./troubleshooting.md).
|
|
491
|
+
- [The documentation index](./README.md), with the reference for every export, and the
|
|
492
|
+
[changelog](../CHANGELOG.md).
|