llm-large-files 0.8.2 → 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 +981 -0
- package/README.md +22 -17
- package/dist/access.d.ts +128 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +234 -0
- package/dist/access.js.map +1 -0
- 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 +159 -14
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +743 -113
- package/dist/ask.js.map +1 -1
- package/dist/cache.d.ts +12 -3
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +18 -5
- package/dist/cache.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/encoding.js +5 -3
- package/dist/encoding.js.map +1 -1
- package/dist/error-info.d.ts +70 -0
- package/dist/error-info.d.ts.map +1 -0
- package/dist/error-info.js +253 -0
- package/dist/error-info.js.map +1 -0
- package/dist/errors.d.ts +74 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +104 -15
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +57 -13
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +42 -11
- package/dist/events.js.map +1 -1
- package/dist/evidence.d.ts +4 -2
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +35 -5
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts +32 -8
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +52 -36
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +54 -7
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +152 -41
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +38 -53
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +20 -25
- 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 +4 -4
- 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 +13 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +78 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +893 -0
- package/dist/ingest.js.map +1 -0
- package/dist/library.d.ts +295 -33
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +458 -650
- 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 +807 -61
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +79 -6
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +80 -4
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +247 -14
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +491 -227
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/ingest-child.d.ts +7 -1
- package/dist/node/ingest-child.d.ts.map +1 -1
- package/dist/node/ingest-child.js +19 -4
- package/dist/node/ingest-child.js.map +1 -1
- package/dist/node/isolated.d.ts +3 -1
- package/dist/node/isolated.d.ts.map +1 -1
- package/dist/node/isolated.js +11 -4
- package/dist/node/isolated.js.map +1 -1
- package/dist/node/originals.d.ts +19 -0
- package/dist/node/originals.d.ts.map +1 -0
- package/dist/node/originals.js +82 -0
- package/dist/node/originals.js.map +1 -0
- package/dist/node/spool.d.ts +106 -0
- package/dist/node/spool.d.ts.map +1 -0
- package/dist/node/spool.js +378 -0
- package/dist/node/spool.js.map +1 -0
- package/dist/node/sse.d.ts +6 -4
- package/dist/node/sse.d.ts.map +1 -1
- package/dist/node/sse.js +9 -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-layout.d.ts.map +1 -1
- package/dist/pdf-layout.js +71 -12
- package/dist/pdf-layout.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 +16 -11
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +56 -12
- package/dist/ranged.js.map +1 -1
- package/dist/retry.d.ts +3 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +6 -2
- package/dist/retry.js.map +1 -1
- package/dist/scope.d.ts +25 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +60 -0
- package/dist/scope.js.map +1 -0
- 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/source.d.ts +60 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +170 -0
- package/dist/source.js.map +1 -0
- package/dist/stores.d.ts +126 -31
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +655 -141
- package/dist/stores.js.map +1 -1
- package/dist/testing/fake-fetch.d.ts +31 -0
- package/dist/testing/fake-fetch.d.ts.map +1 -0
- package/dist/testing/fake-fetch.js +66 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-model.d.ts +38 -0
- package/dist/testing/fake-model.d.ts.map +1 -0
- package/dist/testing/fake-model.js +62 -0
- package/dist/testing/fake-model.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/store-checks.d.ts +72 -0
- package/dist/testing/store-checks.d.ts.map +1 -0
- package/dist/testing/store-checks.js +619 -0
- package/dist/testing/store-checks.js.map +1 -0
- package/dist/tools.d.ts +47 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +440 -71
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +165 -14
- 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 +21 -8
- package/docs/getting-started.md +18 -13
- package/docs/guides/anthropic.md +17 -10
- package/docs/guides/conversations.md +112 -47
- package/docs/guides/costs-and-limits.md +147 -42
- package/docs/guides/deployment.md +380 -86
- package/docs/guides/errors-and-reliability.md +317 -67
- package/docs/guides/explorer-model.md +4 -1
- package/docs/guides/openai-compatible.md +47 -7
- package/docs/guides/own-adapter-and-loop.md +60 -16
- package/docs/guides/pdfs.md +219 -36
- package/docs/guides/storage.md +676 -145
- package/docs/guides/testing.md +149 -129
- package/docs/guides/vertex-and-gemini.md +169 -57
- package/docs/guides/web-app.md +318 -80
- package/docs/how-it-works.md +155 -30
- package/docs/measurements.md +215 -13
- package/docs/publishing.md +185 -37
- package/docs/reference/anthropic.md +12 -7
- package/docs/reference/ask.md +415 -47
- package/docs/reference/errors-and-retries.md +194 -14
- package/docs/reference/events.md +77 -27
- package/docs/reference/gemini.md +252 -87
- package/docs/reference/library.md +886 -178
- package/docs/reference/node.md +659 -111
- package/docs/reference/openai.md +21 -10
- package/docs/reference/testing.md +311 -0
- package/docs/reference/tools.md +285 -30
- package/docs/security.md +404 -78
- package/docs/troubleshooting.md +151 -70
- package/docs/upgrading-0.10.md +472 -0
- package/docs/upgrading-0.9.md +890 -0
- package/package.json +16 -3
- package/src/access.ts +267 -0
- 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 +866 -115
- package/src/cache.ts +20 -5
- package/src/citations.ts +294 -0
- package/src/encoding.ts +6 -4
- package/src/error-info.ts +290 -0
- package/src/errors.ts +131 -15
- package/src/events.ts +112 -24
- package/src/evidence.ts +35 -5
- package/src/extract.ts +56 -34
- package/src/gemini/adapter.ts +196 -43
- package/src/gemini/chat.ts +63 -78
- 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 +4 -4
- package/src/http.ts +65 -4
- package/src/index.ts +13 -8
- package/src/ingest.ts +958 -0
- package/src/library.ts +711 -651
- package/src/map-reduce.ts +858 -70
- package/src/model.ts +113 -9
- package/src/node/handlers.ts +709 -221
- package/src/node/index.ts +14 -2
- package/src/node/ingest-child.ts +24 -6
- package/src/node/isolated.ts +11 -4
- package/src/node/originals.ts +78 -0
- package/src/node/spool.ts +379 -0
- package/src/node/sse.ts +9 -7
- package/src/openai/adapter.ts +56 -13
- package/src/output-limit.ts +5 -2
- package/src/pdf-layout.ts +69 -11
- package/src/pdf-outline.ts +400 -0
- package/src/plan.ts +287 -36
- package/src/prepare.ts +253 -0
- package/src/ranged.ts +48 -14
- package/src/retry.ts +6 -2
- package/src/scope.ts +63 -0
- package/src/search.ts +69 -13
- package/src/source.ts +178 -0
- package/src/stores.ts +702 -142
- package/src/testing/fake-fetch.ts +80 -0
- package/src/testing/fake-model.ts +78 -0
- package/src/testing/index.ts +11 -0
- package/src/testing/store-checks.ts +660 -0
- package/src/tools.ts +461 -73
- package/src/types.ts +151 -14
- package/src/whole-cost.ts +64 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** A JSON body, read loosely: a test reaches into it without a cast. */
|
|
2
|
+
type Json = Record<string, any>;
|
|
3
|
+
|
|
4
|
+
/** A request as the adapter sent it: the URL, the headers as given, and the body parsed as JSON. */
|
|
5
|
+
export type Sent = { url: string; method: string; headers: Record<string, string>; body: Json };
|
|
6
|
+
|
|
7
|
+
/** One entry of a `fakeFetch` script: a reply, or a function that makes one from the request. */
|
|
8
|
+
export type FakeReply = Response | ((sent: Sent, call: number) => Response | Promise<Response>);
|
|
9
|
+
|
|
10
|
+
export type FakeFetch = {
|
|
11
|
+
/** The `fetch` to give an adapter (its `fetch` option). */
|
|
12
|
+
fetch: typeof globalThis.fetch;
|
|
13
|
+
/** Every request, in order: requests sent again too. */
|
|
14
|
+
readonly sent: Sent[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A `fetch` for the real adapters that answers from a script, without the network: each request
|
|
19
|
+
* gets the next reply, and the last one repeats. A `Response` is answered with a copy, since a body
|
|
20
|
+
* can be read only once. Every request is recorded in `sent`. As a real `fetch` does, it rejects with
|
|
21
|
+
* the reason of the request's `signal` once that aborts, also while a reply made by a function waits.
|
|
22
|
+
*/
|
|
23
|
+
export function fakeFetch(replies: FakeReply[]): FakeFetch {
|
|
24
|
+
if (replies.length === 0) throw new TypeError("fakeFetch needs at least one reply.");
|
|
25
|
+
const sent: Sent[] = [];
|
|
26
|
+
const fetch = async (input: string | URL | Request, init?: RequestInit): Promise<Response> => {
|
|
27
|
+
const given = typeof input === "object" && !(input instanceof URL) ? input : undefined;
|
|
28
|
+
const signal = init?.signal ?? given?.signal ?? undefined;
|
|
29
|
+
signal?.throwIfAborted();
|
|
30
|
+
const request: Sent = {
|
|
31
|
+
url: typeof input === "string" ? input : input instanceof URL ? input.href : input.url,
|
|
32
|
+
method: init?.method ?? given?.method ?? "GET",
|
|
33
|
+
// A Request carries its own headers and body when `init` does not.
|
|
34
|
+
headers: init?.headers !== undefined || !given ? headersOf(init?.headers) : Object.fromEntries(given.headers),
|
|
35
|
+
body: init?.body !== undefined || !given ? bodyOf(init?.body) : bodyOf(await given.clone().text()),
|
|
36
|
+
};
|
|
37
|
+
sent.push(request);
|
|
38
|
+
const reply = replies[Math.min(sent.length - 1, replies.length - 1)]!;
|
|
39
|
+
const answer = Promise.resolve(typeof reply === "function" ? reply(request, sent.length) : reply.clone());
|
|
40
|
+
if (!signal) return answer;
|
|
41
|
+
let onAbort: (() => void) | undefined;
|
|
42
|
+
const aborted = new Promise<never>((_, reject) => {
|
|
43
|
+
onAbort = () => reject(signal.reason);
|
|
44
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
return await Promise.race([answer, aborted]);
|
|
48
|
+
} finally {
|
|
49
|
+
signal.removeEventListener("abort", onAbort!);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return { fetch: fetch as typeof globalThis.fetch, sent };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A streamed reply: Server-Sent Events, one `data:` line for each event, each object as JSON. A
|
|
57
|
+
* string is sent as it is (`"[DONE]"`).
|
|
58
|
+
*/
|
|
59
|
+
export const sse = (events: unknown[]): Response => new Response(
|
|
60
|
+
events.map((event) => `data: ${typeof event === "string" ? event : JSON.stringify(event)}\n\n`).join(""),
|
|
61
|
+
{ headers: { "Content-Type": "text/event-stream" } },
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/** The headers as the adapter wrote them: a plain object keeps its names, a `Headers` has them in lower case. */
|
|
65
|
+
function headersOf(headers: RequestInit["headers"]): Record<string, string> {
|
|
66
|
+
if (!headers) return {};
|
|
67
|
+
if (headers instanceof Headers || Array.isArray(headers)) return Object.fromEntries(new Headers(headers));
|
|
68
|
+
return { ...(headers as Record<string, string>) };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The body parsed as JSON, or `{}` when there is none or it is not JSON text. */
|
|
72
|
+
function bodyOf(body: RequestInit["body"]): Json {
|
|
73
|
+
if (typeof body !== "string") return {};
|
|
74
|
+
try {
|
|
75
|
+
const value: unknown = JSON.parse(body);
|
|
76
|
+
return value !== null && typeof value === "object" ? (value as Json) : {};
|
|
77
|
+
} catch {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ModelAdapter, ModelCapabilities, ModelReply, ModelRequest, SendHooks, ToolCall } from "../model.js";
|
|
2
|
+
import type { GenerateText } from "../types.js";
|
|
3
|
+
|
|
4
|
+
/** One entry of a script: a reply, an error to throw, or a function that picks one from the request. */
|
|
5
|
+
export type Scripted =
|
|
6
|
+
| Partial<ModelReply>
|
|
7
|
+
| Error
|
|
8
|
+
| ((request: ModelRequest, call: number, hooks: SendHooks) => Partial<ModelReply> | Error | Promise<Partial<ModelReply> | Error>);
|
|
9
|
+
|
|
10
|
+
export type FakeModel = ModelAdapter & {
|
|
11
|
+
/** Every request `send` was called with, in order: failed attempts too. */
|
|
12
|
+
readonly requests: ModelRequest[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** A reply of text. */
|
|
16
|
+
export const says = (text: string, more: Partial<ModelReply> = {}): Partial<ModelReply> => ({ text, ...more });
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A reply of tool calls. Its `raw` is the turn in a "provider's own form" (`{ own: [names] }`), so
|
|
20
|
+
* that a test can tell where the loop gives that form back.
|
|
21
|
+
*/
|
|
22
|
+
export const calls = (list: ToolCall[], more: Partial<ModelReply> = {}): Partial<ModelReply> => ({ calls: list, raw: { own: list.map((call) => call.name) }, ...more });
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A model that answers each request from a script. The last entry repeats. An entry that is an
|
|
26
|
+
* Error is thrown, as an adapter throws a request that failed. When the loop listens for text
|
|
27
|
+
* (`hooks.onText`), the text is passed on in two pieces, as a stream would arrive.
|
|
28
|
+
*
|
|
29
|
+
* The capabilities are `{ toolFiles: "inside", pageTokens: 500 }` (files inside tool results, as
|
|
30
|
+
* Gemini takes them) unless the options say otherwise: `toolFiles: "none"` for a model that takes
|
|
31
|
+
* no files (no `view_pages`), `appendOnly: true` for one that the loop treats as Claude.
|
|
32
|
+
*/
|
|
33
|
+
export function fakeModel(script: Scripted[], options: Partial<ModelCapabilities> & { id?: string; generateText?: GenerateText } = {}): FakeModel {
|
|
34
|
+
const { id = "fake-model", generateText, ...capabilities } = options;
|
|
35
|
+
const requests: ModelRequest[] = [];
|
|
36
|
+
return {
|
|
37
|
+
id,
|
|
38
|
+
capabilities: { toolFiles: "inside", pageTokens: 500, ...capabilities },
|
|
39
|
+
requests,
|
|
40
|
+
...(generateText ? { generateText } : {}),
|
|
41
|
+
async send(request, hooks = {}) {
|
|
42
|
+
// What was sent, as it was at that moment: the loop goes on changing its own list.
|
|
43
|
+
requests.push({ ...request, messages: [...request.messages] });
|
|
44
|
+
const entry = script[Math.min(requests.length - 1, script.length - 1)]!;
|
|
45
|
+
const reply = typeof entry === "function" ? await entry(request, requests.length, hooks) : entry;
|
|
46
|
+
if (reply instanceof Error) throw reply;
|
|
47
|
+
const text = reply.text ?? "";
|
|
48
|
+
if (text && hooks.onText) {
|
|
49
|
+
const half = Math.ceil(text.length / 2);
|
|
50
|
+
hooks.onText(text.slice(0, half));
|
|
51
|
+
if (text.length > half) hooks.onText(text.slice(half));
|
|
52
|
+
}
|
|
53
|
+
return { text, calls: [], ...reply };
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** An error as an adapter throws it for an HTTP status, with the wait a `Retry-After` asked for. */
|
|
59
|
+
export function httpError(status: number, message = `HTTP ${status}`, retryAfterMs?: number): Error {
|
|
60
|
+
return Object.assign(new Error(message), { status, ...(retryAfterMs === undefined ? {} : { retryAfterMs }) });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A service log of `lines` lines of about 90 characters, the same every time: an `ERROR` line every
|
|
65
|
+
* 97 lines (97, 194, …), a `WARN` line every 13, and `INFO` lines in between.
|
|
66
|
+
*/
|
|
67
|
+
export function serviceLog(lines: number): string {
|
|
68
|
+
const out: string[] = [];
|
|
69
|
+
for (let n = 1; n <= lines; n++) {
|
|
70
|
+
const level = n % 97 === 0 ? "ERROR" : n % 13 === 0 ? "WARN" : "INFO";
|
|
71
|
+
const time = new Date(Date.UTC(2026, 10, 12, 8, 0, 0) + n * 250).toISOString();
|
|
72
|
+
out.push(`${time} ${level} [worker-${n % 8}] req=${(n * 2654435761 >>> 0).toString(16).padStart(8, "0")} GET /api/v2/orders/${n % 5000} took ${(n * 37) % 900}ms`);
|
|
73
|
+
}
|
|
74
|
+
return out.join("\n");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The bytes of a text in UTF-8, as `ingest` takes them. */
|
|
78
|
+
export const utf8 = (text: string): Uint8Array => new TextEncoder().encode(text);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// "llm-large-files/testing": fakes for the tests of an app that uses the library, as the library's
|
|
2
|
+
// own tests use them. A scripted model (fakeModel), a fetch for the real adapters (fakeFetch), and
|
|
3
|
+
// test documents, and the checks of a store (documentStoreChecks). Nothing here depends on a test
|
|
4
|
+
// framework: it works with Vitest, Jest or node:test.
|
|
5
|
+
export { calls, fakeModel, httpError, says, serviceLog, utf8 } from "./fake-model.js";
|
|
6
|
+
export type { FakeModel, Scripted } from "./fake-model.js";
|
|
7
|
+
export { fakeFetch, sse } from "./fake-fetch.js";
|
|
8
|
+
export type { FakeFetch, FakeReply, Sent } from "./fake-fetch.js";
|
|
9
|
+
// The checks a DocumentStore must pass, for the tests of a store of your own. New in 0.9.0.
|
|
10
|
+
export { documentStoreChecks } from "./store-checks.js";
|
|
11
|
+
export type { DocumentStoreCheck, DocumentStoreChecksOptions, StoreCheckEnvironment, StoreCheckPart } from "./store-checks.js";
|