llm-large-files 0.4.1 → 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 +127 -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/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 +31 -75
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +38 -300
- 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 +9 -20
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +43 -92
- 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 +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/library.d.ts +29 -3
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +10 -12
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.d.ts +9 -0
- package/dist/map-reduce.d.ts.map +1 -1
- package/dist/map-reduce.js +25 -19
- 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/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/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/tools.d.ts +11 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +85 -31
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +28 -3
- package/dist/types.d.ts.map +1 -1
- package/docs/api.md +245 -27
- package/docs/configuration.md +83 -9
- package/docs/getting-started.md +67 -16
- package/docs/how-it-works.md +38 -2
- package/docs/security.md +18 -0
- 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/evidence.ts +162 -0
- package/src/gemini/adapter.ts +218 -0
- package/src/gemini/chat.ts +61 -353
- package/src/gemini/errors.ts +15 -0
- package/src/gemini/generate.ts +50 -90
- package/src/gemini/index.ts +3 -1
- package/src/gemini/sse.ts +1 -34
- package/src/http.ts +59 -0
- package/src/index.ts +33 -4
- package/src/library.ts +39 -13
- package/src/map-reduce.ts +22 -16
- 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/retry.ts +132 -0
- package/src/sse.ts +34 -0
- package/src/tools.ts +91 -34
- package/src/types.ts +24 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type HeaderSource, type SecretSource } from "../http.js";
|
|
2
|
+
import { ModelRequestError, type ChatMessage, type ModelAdapter, type ToolTurn } from "../model.js";
|
|
3
|
+
/** The endpoint answered with an HTTP error, or could not be reached (`status` 0). */
|
|
4
|
+
export declare class OpenAiRequestError extends ModelRequestError {
|
|
5
|
+
constructor(message: string, status: number, options?: {
|
|
6
|
+
retryAfterMs?: number;
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/** A Chat Completions message, as the API takes and returns it. */
|
|
11
|
+
export type OpenAiMessage = {
|
|
12
|
+
role: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type OpenAiCompatibleOptions = {
|
|
16
|
+
/** The model name the endpoint knows: "gpt-5.5", "deepseek-v4-pro", a deployment name. */
|
|
17
|
+
model: string;
|
|
18
|
+
/**
|
|
19
|
+
* The base of the API: `/chat/completions` is added to it. Defaults to https://api.openai.com/v1.
|
|
20
|
+
* DeepSeek: https://api.deepseek.com/v1. Gemini: https://generativelanguage.googleapis.com/v1beta/openai.
|
|
21
|
+
*/
|
|
22
|
+
baseUrl?: string | undefined;
|
|
23
|
+
/** The whole Chat Completions URL, when it is not `baseUrl` + `/chat/completions` (Azure OpenAI, a gateway). */
|
|
24
|
+
url?: string | undefined;
|
|
25
|
+
/** Sent as `Authorization: Bearer …`. A function is called for each request. */
|
|
26
|
+
apiKey?: SecretSource | undefined;
|
|
27
|
+
/** More headers, or all of them (Azure's `api-key`). A function is called for each request. */
|
|
28
|
+
headers?: HeaderSource | undefined;
|
|
29
|
+
/** More fields for the body of every chat request: `temperature`, `reasoning_effort`, `max_completion_tokens`, and so on. */
|
|
30
|
+
body?: Record<string, unknown> | undefined;
|
|
31
|
+
/** More fields for the body of a whole-document part read, given the output limit it is sent with. */
|
|
32
|
+
analysisBody?: ((maxOutputTokens: number) => Record<string, unknown>) | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The name of the output limit in a part read. `max_completion_tokens` for api.openai.com and
|
|
35
|
+
* Azure OpenAI, whose newer models refuse the other; `max_tokens` anywhere else, where it is the
|
|
36
|
+
* one every server knows.
|
|
37
|
+
*/
|
|
38
|
+
maxTokensField?: "max_tokens" | "max_completion_tokens" | undefined;
|
|
39
|
+
/** "system" (the default), or "developer" for an endpoint that wants the newer name. */
|
|
40
|
+
systemRole?: "system" | "developer" | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* How the request that must be answered in text says so. "tool_choice" (the default) keeps the
|
|
43
|
+
* tools and sends `tool_choice: "none"`. "omit" leaves the tools out, for a server that does not
|
|
44
|
+
* know `tool_choice`.
|
|
45
|
+
*/
|
|
46
|
+
answerWithoutTools?: "tool_choice" | "omit" | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Send the pages of `view_pages` to the model, as a `file` part in a user message after the tool
|
|
49
|
+
* results. Off by default: a tool message holds text only, and many servers behind this API
|
|
50
|
+
* take no PDF at all. Turn it on for a model that reads PDF input.
|
|
51
|
+
*/
|
|
52
|
+
pdfInput?: boolean | undefined;
|
|
53
|
+
/** Stream the answer when the caller listens for text. Defaults to true. False for a server without streaming. */
|
|
54
|
+
stream?: boolean | undefined;
|
|
55
|
+
/** The model's context window in tokens, when the budget of a question should follow it. */
|
|
56
|
+
contextTokens?: number | undefined;
|
|
57
|
+
/** The largest request body the endpoint takes, in bytes. */
|
|
58
|
+
maxRequestBytes?: number | undefined;
|
|
59
|
+
/** Tokens billed for one PDF page, when `pdfInput` is on. Defaults to 1,000. */
|
|
60
|
+
pageTokens?: number | undefined;
|
|
61
|
+
/** This model's tokens for one token of the library's estimate. Defaults to 1. */
|
|
62
|
+
tokenScale?: number | undefined;
|
|
63
|
+
/** Milliseconds a part read may take. Defaults to 180,000. */
|
|
64
|
+
timeoutMs?: number | undefined;
|
|
65
|
+
/** Names the model in usage totals. Defaults to `model`. */
|
|
66
|
+
id?: string | undefined;
|
|
67
|
+
fetch?: typeof fetch | undefined;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Chat Completions messages as the conversation of `askWithFiles`. System messages are returned
|
|
71
|
+
* apart, as `system`. An assistant turn of tool calls and the tool messages that answer it become
|
|
72
|
+
* one stored tool round.
|
|
73
|
+
*/
|
|
74
|
+
export declare function fromOpenAiMessages(history: OpenAiMessage[]): {
|
|
75
|
+
system: string;
|
|
76
|
+
messages: ChatMessage[];
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The tool rounds a question returned (`AskResult.toolTurns`) as Chat Completions messages, for an
|
|
80
|
+
* application that keeps its history in that form: put them between the question and its answer.
|
|
81
|
+
*/
|
|
82
|
+
export declare function openAiToolTurns(turns: ToolTurn[]): OpenAiMessage[];
|
|
83
|
+
/** A model behind a Chat Completions endpoint, for `askWithFiles`. */
|
|
84
|
+
export declare function openAiCompatible(options: OpenAiCompatibleOptions): ModelAdapter;
|
|
85
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/openai/adapter.ts"],"names":[],"mappings":"AAE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;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;IACxD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,kHAAkH;IAClH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,CAAC;CAClC,CAAC;AAyDF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CA+BxG;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAKlE;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,YAAY,CAoK/E"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// Any Chat Completions endpoint as a model of `askWithFiles`: OpenAI, Azure OpenAI, DeepSeek,
|
|
2
|
+
// LiteLLM, vLLM, Ollama, OpenRouter, Gemini's OpenAI layer. No SDK: the caller gives the URL.
|
|
3
|
+
import { base64, parseArguments, readArguments, resolveHeaderSource, resolveSecret, unreachableReason } from "../http.js";
|
|
4
|
+
import { ModelRequestError } from "../model.js";
|
|
5
|
+
import { completeWithinLimit } from "../output-limit.js";
|
|
6
|
+
import { retryAfterMs } from "../retry.js";
|
|
7
|
+
import { parseSseJson } from "../sse.js";
|
|
8
|
+
/** The endpoint answered with an HTTP error, or could not be reached (`status` 0). */
|
|
9
|
+
export class OpenAiRequestError extends ModelRequestError {
|
|
10
|
+
constructor(message, status, options = {}) {
|
|
11
|
+
super(message, status, options);
|
|
12
|
+
this.name = "OpenAiRequestError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const contentText = (content) => {
|
|
16
|
+
if (typeof content === "string")
|
|
17
|
+
return content;
|
|
18
|
+
if (!Array.isArray(content))
|
|
19
|
+
return "";
|
|
20
|
+
return content.map((part) => (part?.type === "text" && typeof part.text === "string" ? part.text : "")).join("");
|
|
21
|
+
};
|
|
22
|
+
const asFunction = (declaration) => ({ type: "function", function: declaration });
|
|
23
|
+
function usageOf(usage) {
|
|
24
|
+
const number = (value) => (typeof value === "number" && Number.isFinite(value) ? value : 0);
|
|
25
|
+
return {
|
|
26
|
+
inputTokens: number(usage?.prompt_tokens),
|
|
27
|
+
cachedInputTokens: number(usage?.prompt_tokens_details?.cached_tokens ?? usage?.prompt_cache_hit_tokens),
|
|
28
|
+
outputTokens: number(usage?.completion_tokens),
|
|
29
|
+
thoughtTokens: number(usage?.completion_tokens_details?.reasoning_tokens),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** The error of a response that is not OK. Gemini's layer wraps its error in an array. */
|
|
33
|
+
async function failure(response) {
|
|
34
|
+
const data = await response.json().catch(() => null);
|
|
35
|
+
const body = Array.isArray(data) ? data[0] : data;
|
|
36
|
+
const message = typeof body?.error === "string" ? body.error : body?.error?.message;
|
|
37
|
+
const wait = retryAfterMs(response.headers, body);
|
|
38
|
+
return new OpenAiRequestError(typeof message === "string" && message ? message : `The model returned HTTP ${response.status}.`, response.status, wait === undefined ? {} : { retryAfterMs: wait });
|
|
39
|
+
}
|
|
40
|
+
const textOf = (message) => message.parts.map((part) => part.text ?? "").filter(Boolean).join("\n\n");
|
|
41
|
+
/** A turn of text. One with nothing but text is a string, which every server takes; native parts make it a list. */
|
|
42
|
+
function textMessage(message) {
|
|
43
|
+
if (message.parts.every((part) => part.native === undefined))
|
|
44
|
+
return { role: message.role, content: textOf(message) };
|
|
45
|
+
return { role: message.role, content: message.parts.map((part) => (part.native !== undefined ? part.native : { type: "text", text: part.text })) };
|
|
46
|
+
}
|
|
47
|
+
/** The messages of one tool round. `number` makes the IDs of calls that came without one. */
|
|
48
|
+
function roundMessages(round, number, pdfInput) {
|
|
49
|
+
const idOf = (call, index) => call.id ?? `call_${number}_${index + 1}`;
|
|
50
|
+
// Its own turn goes back as it came: a server may want what it put there (reasoning, signatures).
|
|
51
|
+
const asked = round.raw !== undefined ? round.raw : {
|
|
52
|
+
role: "assistant",
|
|
53
|
+
content: null,
|
|
54
|
+
tool_calls: round.calls.map((call, index) => ({ id: idOf(call, index), type: "function", function: { name: call.name, arguments: JSON.stringify(call.args) } })),
|
|
55
|
+
};
|
|
56
|
+
const results = round.answers.map((answer, index) => ({ role: "tool", tool_call_id: idOf(answer.call, index), content: JSON.stringify(answer.result) }));
|
|
57
|
+
// A tool message holds text. Files follow in a user turn, each after a line that names it.
|
|
58
|
+
const files = pdfInput ? round.answers.flatMap((answer) => (answer.files ?? []).flatMap((file) => [
|
|
59
|
+
{ type: "text", text: `${file.name} (returned by ${answer.call.name}):` },
|
|
60
|
+
{ type: "file", file: { filename: file.name, file_data: `data:${file.mimeType};base64,${base64(file.bytes)}` } },
|
|
61
|
+
])) : [];
|
|
62
|
+
return [asked, ...results, ...(files.length > 0 ? [{ role: "user", content: files }] : [])];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Chat Completions messages as the conversation of `askWithFiles`. System messages are returned
|
|
66
|
+
* apart, as `system`. An assistant turn of tool calls and the tool messages that answer it become
|
|
67
|
+
* one stored tool round.
|
|
68
|
+
*/
|
|
69
|
+
export function fromOpenAiMessages(history) {
|
|
70
|
+
const system = [];
|
|
71
|
+
const messages = [];
|
|
72
|
+
const open = new Map();
|
|
73
|
+
for (const message of history) {
|
|
74
|
+
if (message.role === "system" || message.role === "developer") {
|
|
75
|
+
const text = contentText(message.content);
|
|
76
|
+
if (text)
|
|
77
|
+
system.push(text);
|
|
78
|
+
}
|
|
79
|
+
else if (message.role === "tool") {
|
|
80
|
+
const call = open.get(String(message.tool_call_id));
|
|
81
|
+
if (!call)
|
|
82
|
+
continue;
|
|
83
|
+
const text = contentText(message.content);
|
|
84
|
+
const parsed = parseArguments(text);
|
|
85
|
+
call.result = Object.keys(parsed).length > 0 || text.trim() === "{}" ? parsed : { text };
|
|
86
|
+
}
|
|
87
|
+
else if (message.role === "assistant" && Array.isArray(message.tool_calls) && message.tool_calls.length > 0) {
|
|
88
|
+
const calls = message.tool_calls.map((call, index) => ({
|
|
89
|
+
id: typeof call.id === "string" ? call.id : `call_${messages.length}_${index + 1}`,
|
|
90
|
+
name: String(call.function?.name ?? ""),
|
|
91
|
+
args: parseArguments(call.function?.arguments),
|
|
92
|
+
result: { error: "No result was kept for this call." },
|
|
93
|
+
}));
|
|
94
|
+
for (const call of calls)
|
|
95
|
+
open.set(call.id, call);
|
|
96
|
+
messages.push({ role: "tools", calls });
|
|
97
|
+
}
|
|
98
|
+
else if (message.role === "user" || message.role === "assistant") {
|
|
99
|
+
const parts = typeof message.content === "string" || !Array.isArray(message.content)
|
|
100
|
+
? [{ text: contentText(message.content) }]
|
|
101
|
+
: message.content.map((part) => (part?.type === "text" && typeof part.text === "string" ? { text: part.text } : { native: part }));
|
|
102
|
+
messages.push({ role: message.role, parts });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { system: system.join("\n\n"), messages };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The tool rounds a question returned (`AskResult.toolTurns`) as Chat Completions messages, for an
|
|
109
|
+
* application that keeps its history in that form: put them between the question and its answer.
|
|
110
|
+
*/
|
|
111
|
+
export function openAiToolTurns(turns) {
|
|
112
|
+
return turns.flatMap((turn, index) => {
|
|
113
|
+
const answers = turn.calls.map(({ result, ...call }) => ({ call, result }));
|
|
114
|
+
return roundMessages({ role: "tools", calls: answers.map((answer) => answer.call), answers }, index + 1, false);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** A model behind a Chat Completions endpoint, for `askWithFiles`. */
|
|
118
|
+
export function openAiCompatible(options) {
|
|
119
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
120
|
+
const url = options.url ?? `${(options.baseUrl ?? "https://api.openai.com/v1").replace(/\/+$/, "")}/chat/completions`;
|
|
121
|
+
const official = /(^|\.)openai\.com$|\.openai\.azure\.com$/.test((() => {
|
|
122
|
+
try {
|
|
123
|
+
return new URL(url).hostname;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return "";
|
|
127
|
+
}
|
|
128
|
+
})());
|
|
129
|
+
const maxTokensField = options.maxTokensField ?? (official ? "max_completion_tokens" : "max_tokens");
|
|
130
|
+
const systemRole = options.systemRole ?? "system";
|
|
131
|
+
const pdfInput = options.pdfInput === true;
|
|
132
|
+
const headersNow = async () => {
|
|
133
|
+
const key = await resolveSecret(options.apiKey);
|
|
134
|
+
return { "Content-Type": "application/json", ...(key ? { Authorization: `Bearer ${key}` } : {}), ...await resolveHeaderSource(options.headers) };
|
|
135
|
+
};
|
|
136
|
+
const built = new WeakMap();
|
|
137
|
+
const toMessages = (messages) => {
|
|
138
|
+
let rounds = 0;
|
|
139
|
+
return messages.flatMap((message) => {
|
|
140
|
+
if (message.role !== "tools")
|
|
141
|
+
return [textMessage(message)];
|
|
142
|
+
const number = ++rounds;
|
|
143
|
+
let known = built.get(message);
|
|
144
|
+
if (!known || known.number !== number) {
|
|
145
|
+
known = { number, messages: roundMessages(message, number, pdfInput) };
|
|
146
|
+
built.set(message, known);
|
|
147
|
+
}
|
|
148
|
+
return known.messages;
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
const bodyOf = (request, stream) => {
|
|
152
|
+
const mustAnswer = request.toolChoice === "none";
|
|
153
|
+
const listTools = Boolean(request.tools?.length) && !(mustAnswer && options.answerWithoutTools === "omit");
|
|
154
|
+
return {
|
|
155
|
+
model: options.model,
|
|
156
|
+
messages: [...(request.system ? [{ role: systemRole, content: request.system }] : []), ...toMessages(request.messages)],
|
|
157
|
+
...(listTools ? { tools: request.tools.map(asFunction), ...(mustAnswer ? { tool_choice: "none" } : {}) } : {}),
|
|
158
|
+
...(stream ? { stream: true, stream_options: { include_usage: true } } : {}),
|
|
159
|
+
...options.body,
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
const post = async (body, signal, stopped) => {
|
|
163
|
+
let response;
|
|
164
|
+
try {
|
|
165
|
+
response = await fetchImpl(url, { method: "POST", headers: await headersNow(), body: JSON.stringify(body), ...(signal ? { signal } : {}) });
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (stopped())
|
|
169
|
+
throw error;
|
|
170
|
+
throw new OpenAiRequestError(`The model could not be reached${unreachableReason(error)}.`, 0, { cause: error });
|
|
171
|
+
}
|
|
172
|
+
if (!response.ok)
|
|
173
|
+
throw await failure(response);
|
|
174
|
+
return response;
|
|
175
|
+
};
|
|
176
|
+
const generateText = ({ system, prompt, maxOutputTokens, signal, onTruncated, onUsage }) => {
|
|
177
|
+
const send = async (limit) => {
|
|
178
|
+
const timeout = AbortSignal.timeout(options.timeoutMs ?? 180_000);
|
|
179
|
+
const response = await post({
|
|
180
|
+
model: options.model,
|
|
181
|
+
messages: [{ role: systemRole, content: system }, { role: "user", content: prompt }],
|
|
182
|
+
[maxTokensField]: limit,
|
|
183
|
+
...options.analysisBody?.(limit),
|
|
184
|
+
}, signal ? AbortSignal.any([signal, timeout]) : timeout, () => Boolean(signal?.aborted) || timeout.aborted);
|
|
185
|
+
const data = await response.json();
|
|
186
|
+
const used = usageOf(data.usage);
|
|
187
|
+
onUsage?.(used);
|
|
188
|
+
const choice = data.choices?.[0];
|
|
189
|
+
return {
|
|
190
|
+
text: contentText(choice?.message?.content),
|
|
191
|
+
cutOff: choice?.finish_reason === "length",
|
|
192
|
+
...(typeof choice?.finish_reason === "string" ? { reason: choice.finish_reason } : {}),
|
|
193
|
+
thoughts: used.thoughtTokens ?? 0,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
return completeWithinLimit(`${url}|${options.model}`, maxOutputTokens, send, { signal, onTruncated });
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
id: options.id ?? options.model,
|
|
200
|
+
capabilities: {
|
|
201
|
+
...(options.contextTokens ? { contextTokens: options.contextTokens } : {}),
|
|
202
|
+
...(options.maxRequestBytes ? { maxRequestBytes: options.maxRequestBytes } : {}),
|
|
203
|
+
toolFiles: pdfInput ? "beside" : "none",
|
|
204
|
+
pageTokens: options.pageTokens ?? 1_000,
|
|
205
|
+
...(options.tokenScale ? { tokenScale: options.tokenScale } : {}),
|
|
206
|
+
},
|
|
207
|
+
requestBytes: (request) => Buffer.byteLength(JSON.stringify(bodyOf(request, false))),
|
|
208
|
+
generateText,
|
|
209
|
+
async send(request, hooks = {}) {
|
|
210
|
+
const stream = Boolean(hooks.onText) && options.stream !== false;
|
|
211
|
+
const response = await post(bodyOf(request, stream), hooks.signal, () => Boolean(hooks.signal?.aborted));
|
|
212
|
+
let message;
|
|
213
|
+
let finish;
|
|
214
|
+
let usage;
|
|
215
|
+
let text = "";
|
|
216
|
+
if (stream && response.body && (response.headers.get("content-type") ?? "").includes("text/event-stream")) {
|
|
217
|
+
let reasoning = "";
|
|
218
|
+
const toolCalls = [];
|
|
219
|
+
try {
|
|
220
|
+
for await (const chunk of parseSseJson(response.body)) {
|
|
221
|
+
const failed = (Array.isArray(chunk) ? chunk[0] : chunk)?.error;
|
|
222
|
+
if (failed)
|
|
223
|
+
throw new OpenAiRequestError(typeof failed === "string" ? failed : String(failed.message ?? "The model reported an error."), typeof failed.code === "number" ? failed.code : response.status);
|
|
224
|
+
if (chunk.usage)
|
|
225
|
+
usage = chunk.usage;
|
|
226
|
+
const choice = chunk.choices?.[0];
|
|
227
|
+
if (!choice)
|
|
228
|
+
continue;
|
|
229
|
+
const delta = (choice.delta ?? {});
|
|
230
|
+
const piece = contentText(delta.content);
|
|
231
|
+
if (piece) {
|
|
232
|
+
text += piece;
|
|
233
|
+
hooks.onText?.(piece);
|
|
234
|
+
}
|
|
235
|
+
if (typeof delta.reasoning_content === "string")
|
|
236
|
+
reasoning += delta.reasoning_content;
|
|
237
|
+
for (const part of (Array.isArray(delta.tool_calls) ? delta.tool_calls : [])) {
|
|
238
|
+
// A call arrives in pieces under its index: first its ID and name, then its arguments, a few characters at a time.
|
|
239
|
+
const at = typeof part.index === "number" ? part.index : part.id || toolCalls.length === 0 ? toolCalls.length : toolCalls.length - 1;
|
|
240
|
+
const call = (toolCalls[at] ??= { type: "function", function: { name: "", arguments: "" } });
|
|
241
|
+
for (const [key, value] of Object.entries(part)) {
|
|
242
|
+
if (key !== "index" && key !== "function" && value !== undefined && value !== null && !(key === "id" && call.id))
|
|
243
|
+
call[key] = value;
|
|
244
|
+
}
|
|
245
|
+
if (typeof part.function?.name === "string")
|
|
246
|
+
call.function.name += part.function.name;
|
|
247
|
+
if (typeof part.function?.arguments === "string")
|
|
248
|
+
call.function.arguments += part.function.arguments;
|
|
249
|
+
}
|
|
250
|
+
finish = choice.finish_reason ?? finish;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
if (hooks.signal?.aborted || error instanceof OpenAiRequestError)
|
|
255
|
+
throw error;
|
|
256
|
+
// The connection went while the answer was on its way.
|
|
257
|
+
throw new OpenAiRequestError(`The model could not be reached${unreachableReason(error)}.`, 0, { cause: error });
|
|
258
|
+
}
|
|
259
|
+
const calls = toolCalls.filter(Boolean);
|
|
260
|
+
message = { role: "assistant", content: text || null, ...(reasoning ? { reasoning_content: reasoning } : {}), ...(calls.length > 0 ? { tool_calls: calls } : {}) };
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// In one piece: no streaming was asked for, or the server answered without it.
|
|
264
|
+
const data = await response.json();
|
|
265
|
+
const choice = data.choices?.[0];
|
|
266
|
+
message = (choice?.message ?? { role: "assistant", content: null });
|
|
267
|
+
finish = choice?.finish_reason;
|
|
268
|
+
usage = data.usage;
|
|
269
|
+
// A refusal is what the model has to say to the user, in a field of its own.
|
|
270
|
+
text = contentText(message.content) || (typeof message.refusal === "string" ? message.refusal : "");
|
|
271
|
+
if (text)
|
|
272
|
+
hooks.onText?.(text);
|
|
273
|
+
}
|
|
274
|
+
// Cut off at the output limit with a call half-written: the call is answered, not run.
|
|
275
|
+
const cutOff = finish === "length" ? "This call was cut off at the output limit before its arguments were complete, and was not run. Send it again." : undefined;
|
|
276
|
+
const calls = (Array.isArray(message.tool_calls) ? message.tool_calls : [])
|
|
277
|
+
.filter((call) => typeof call?.function?.name === "string" && call.function.name)
|
|
278
|
+
.map((call) => {
|
|
279
|
+
const { args, problem = cutOff } = readArguments(call.function.arguments);
|
|
280
|
+
return { ...(typeof call.id === "string" && call.id ? { id: call.id } : {}), name: call.function.name, args, ...(problem ? { problem } : {}) };
|
|
281
|
+
});
|
|
282
|
+
return {
|
|
283
|
+
text,
|
|
284
|
+
calls,
|
|
285
|
+
raw: message,
|
|
286
|
+
...(typeof finish === "string" ? { finishReason: finish } : {}),
|
|
287
|
+
...(finish === "content_filter" && !text && calls.length === 0 ? { blockReason: "content_filter" } : {}),
|
|
288
|
+
...(usage ? { usage: usageOf(usage), providerUsage: usage } : {}),
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/openai/adapter.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,8FAA8F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C,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3J,CAAC,CAAC,CAAC;YACL,OAAO;gBACL,IAAI;gBACJ,KAAK;gBACL,GAAG,EAAE,OAAO;gBACZ,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/D,GAAG,CAAC,MAAM,KAAK,gBAAgB,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/openai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACzG,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model that thinks counts its thoughts in its output limit. Asked for 4,096 tokens of notes on
|
|
3
|
+
* a part of a log, Gemini 3.8 Flash spent 3,931 of them thinking and wrote two lines, and Gemini 4
|
|
4
|
+
* wrote nothing at all (November 2026). A reply that was cut off that way is asked for again with
|
|
5
|
+
* this limit, the least Google recommends for a Gemini 4 model. OpenAI says to keep at least
|
|
6
|
+
* 25,000 for its reasoning models.
|
|
7
|
+
*/
|
|
8
|
+
export declare const THINKING_OUTPUT_TOKENS = 32768;
|
|
9
|
+
/** A reply to a plain completion. */
|
|
10
|
+
export type LimitedReply = {
|
|
11
|
+
text: string;
|
|
12
|
+
/** True when the model stopped because it reached the output limit. */
|
|
13
|
+
cutOff: boolean;
|
|
14
|
+
/** Why it stopped, in the provider's word, for the message when there is no text. */
|
|
15
|
+
reason?: string;
|
|
16
|
+
/** Tokens the model spent thinking, when the provider says. */
|
|
17
|
+
thoughts: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Sends a completion with an output limit, and once more with `THINKING_OUTPUT_TOKENS` when the
|
|
21
|
+
* reply was cut off with nothing written, or with half the limit or more gone on thoughts. What
|
|
22
|
+
* was learned is kept under `model` (a URL, or a URL and a model name): later requests start with
|
|
23
|
+
* the larger limit, and a model that refused it (HTTP 400) is not asked for it again. Requests
|
|
24
|
+
* that arrive while the first one to a model is on its way wait for it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function completeWithinLimit(model: string, maxOutputTokens: number, send: (limit: number) => Promise<LimitedReply>, options?: {
|
|
27
|
+
signal?: AbortSignal | undefined;
|
|
28
|
+
onTruncated?: (() => void) | undefined;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
//# sourceMappingURL=output-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-limit.d.ts","sourceRoot":"","sources":["../src/output-limit.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAkB7C,qCAAqC;AACrC,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;IAChB,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,GAAE;IACzI,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,WAAW,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CACnC,GAAG,OAAO,CAAC,MAAM,CAAC,CAiDvB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// A plain completion on a model that may think its output limit away: shared by the part readers
|
|
2
|
+
// of every adapter.
|
|
3
|
+
/**
|
|
4
|
+
* A model that thinks counts its thoughts in its output limit. Asked for 4,096 tokens of notes on
|
|
5
|
+
* a part of a log, Gemini 3.8 Flash spent 3,931 of them thinking and wrote two lines, and Gemini 4
|
|
6
|
+
* wrote nothing at all (November 2026). A reply that was cut off that way is asked for again with
|
|
7
|
+
* this limit, the least Google recommends for a Gemini 4 model. OpenAI says to keep at least
|
|
8
|
+
* 25,000 for its reasoning models.
|
|
9
|
+
*/
|
|
10
|
+
export const THINKING_OUTPUT_TOKENS = 32_768;
|
|
11
|
+
/**
|
|
12
|
+
* What has been learned about a model, so that a whole-file read does not pay for the wasted
|
|
13
|
+
* request with every part: the output limit it needs, or 0 when it refused that limit.
|
|
14
|
+
*/
|
|
15
|
+
const learnedLimits = new Map();
|
|
16
|
+
/** The first request to a model that is still on its way. Others wait for what it learns. */
|
|
17
|
+
const firstRequests = new Map();
|
|
18
|
+
/** Models that have answered at least once. */
|
|
19
|
+
const answered = new Set();
|
|
20
|
+
const MOST_REMEMBERED = 200;
|
|
21
|
+
function remember(model, limit) {
|
|
22
|
+
if (learnedLimits.size >= MOST_REMEMBERED && !learnedLimits.has(model))
|
|
23
|
+
learnedLimits.clear();
|
|
24
|
+
learnedLimits.set(model, limit);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sends a completion with an output limit, and once more with `THINKING_OUTPUT_TOKENS` when the
|
|
28
|
+
* reply was cut off with nothing written, or with half the limit or more gone on thoughts. What
|
|
29
|
+
* was learned is kept under `model` (a URL, or a URL and a model name): later requests start with
|
|
30
|
+
* the larger limit, and a model that refused it (HTTP 400) is not asked for it again. Requests
|
|
31
|
+
* that arrive while the first one to a model is on its way wait for it.
|
|
32
|
+
*/
|
|
33
|
+
export async function completeWithinLimit(model, maxOutputTokens, send, options = {}) {
|
|
34
|
+
const { signal } = options;
|
|
35
|
+
// The first request to a model finds out whether it thinks its limit away. The parts of a
|
|
36
|
+
// whole-file read are sent four at a time: the others wait for it, and one request is wasted
|
|
37
|
+
// on such a model, not four.
|
|
38
|
+
let learned = () => undefined;
|
|
39
|
+
if (!answered.has(model)) {
|
|
40
|
+
const first = firstRequests.get(model);
|
|
41
|
+
if (first) {
|
|
42
|
+
await first;
|
|
43
|
+
signal?.throwIfAborted();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
firstRequests.set(model, new Promise((resolve) => {
|
|
47
|
+
learned = () => {
|
|
48
|
+
if (answered.size >= MOST_REMEMBERED)
|
|
49
|
+
answered.clear();
|
|
50
|
+
answered.add(model);
|
|
51
|
+
firstRequests.delete(model);
|
|
52
|
+
resolve();
|
|
53
|
+
};
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const known = learnedLimits.get(model);
|
|
59
|
+
const limit = Math.max(maxOutputTokens, known ?? 0);
|
|
60
|
+
let reply = await send(limit);
|
|
61
|
+
// Cut off, with nothing written or with at least half of the limit gone on thoughts: the
|
|
62
|
+
// limit was too low for this model, not the notes too long.
|
|
63
|
+
const starved = reply.cutOff && (!reply.text.trim() || reply.thoughts >= limit / 2);
|
|
64
|
+
if (starved && known !== 0 && limit < THINKING_OUTPUT_TOKENS) {
|
|
65
|
+
remember(model, THINKING_OUTPUT_TOKENS);
|
|
66
|
+
try {
|
|
67
|
+
reply = await send(THINKING_OUTPUT_TOKENS);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (signal?.aborted)
|
|
71
|
+
throw error;
|
|
72
|
+
// A model or a gateway that refuses the larger limit (HTTP 400) is not asked for it again.
|
|
73
|
+
// Any other failure says nothing about the limit: the next request starts with it. What
|
|
74
|
+
// the first reply had is kept; with nothing in it, this error is the one to report.
|
|
75
|
+
if (error?.status === 400)
|
|
76
|
+
remember(model, 0);
|
|
77
|
+
if (!reply.text.trim())
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!reply.text.trim())
|
|
82
|
+
throw new Error(`The model returned no text${reply.reason ? ` (${reply.reason})` : ""}.`);
|
|
83
|
+
// The text stops mid-list when the output limit is reached. Say so instead of passing it off as complete.
|
|
84
|
+
if (reply.cutOff)
|
|
85
|
+
options.onTruncated?.();
|
|
86
|
+
return reply.text;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
learned();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=output-limit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-limit.js","sourceRoot":"","sources":["../src/output-limit.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,oBAAoB;AAEpB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAChD,6FAA6F;AAC7F,MAAM,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAC;AACvD,+CAA+C;AAC/C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;AACnC,MAAM,eAAe,GAAG,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IACpB,CAAC;YAAS,CAAC;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/retry.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** How a model request that failed is sent again. */
|
|
2
|
+
export type RetryOptions = {
|
|
3
|
+
/** How many times a failed request is sent again. Defaults to 3. 0 turns it off. */
|
|
4
|
+
retries?: number;
|
|
5
|
+
/** The first wait in milliseconds. Each later one is twice as long. Defaults to 500. */
|
|
6
|
+
baseDelayMs?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The longest wait in milliseconds. Defaults to 60,000. When the provider asks for a longer one
|
|
9
|
+
* (`Retry-After`), the request is not sent again and the error is reported.
|
|
10
|
+
*/
|
|
11
|
+
maxDelayMs?: number;
|
|
12
|
+
/** For tests: the wait itself. */
|
|
13
|
+
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
14
|
+
/** For tests: the source of the jitter, a number from 0 up to 1. */
|
|
15
|
+
random?: () => number;
|
|
16
|
+
};
|
|
17
|
+
export declare const DEFAULT_RETRIES = 3;
|
|
18
|
+
/** The HTTP status of an error, when it carries one. 0 stands for a connection that failed. */
|
|
19
|
+
export declare function statusOf(error: unknown): number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a request that failed with this status is worth sending again: the model could not be
|
|
22
|
+
* reached, timed out, was busy, or failed on its side. A request it refused (400, 401, 403, 404)
|
|
23
|
+
* would be refused again.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isRetryableStatus(status: number): boolean;
|
|
26
|
+
/** A wait that ends early, with the signal's reason, when the signal aborts. */
|
|
27
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* The wait a provider asked for, in milliseconds: the `retry-after-ms` or `Retry-After` header
|
|
30
|
+
* (seconds, or a date), or the `retryDelay` of a `google.rpc.RetryInfo` in the error body ("17s").
|
|
31
|
+
*/
|
|
32
|
+
export declare function retryAfterMs(headers: Headers | undefined, body?: unknown, now?: () => number): number | undefined;
|
|
33
|
+
export type RetryNotice = {
|
|
34
|
+
error: unknown;
|
|
35
|
+
attempt: number;
|
|
36
|
+
delayMs: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Runs a model request, and runs it again when it failed in a way that another try can mend.
|
|
40
|
+
* - An error with a retryable status (see `isRetryableStatus`) is retried after a wait that doubles
|
|
41
|
+
* each time, with jitter, or after the wait the provider asked for.
|
|
42
|
+
* - An error with another status is not retried.
|
|
43
|
+
* - An error without a status is retried once, at once, when `unknownErrors` is "once"; otherwise not.
|
|
44
|
+
* Nothing is retried after the signal aborted, or once `canRetry` says no.
|
|
45
|
+
*/
|
|
46
|
+
export declare function withRetry<T>(run: () => Promise<T>, options?: {
|
|
47
|
+
retry?: RetryOptions | undefined;
|
|
48
|
+
signal?: AbortSignal | undefined;
|
|
49
|
+
/** False once the attempt did something that must not happen twice: text was shown to the user. */
|
|
50
|
+
canRetry?: () => boolean;
|
|
51
|
+
onRetry?: (notice: RetryNotice) => void;
|
|
52
|
+
unknownErrors?: "once" | "never";
|
|
53
|
+
}): Promise<T>;
|
|
54
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAEA,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG;IACzB,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC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