@loomwork/llm 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +80 -2
- package/dist/assembleStream.d.ts +95 -0
- package/dist/assembleStream.d.ts.map +1 -0
- package/dist/assembleStream.js +180 -0
- package/dist/assembleStream.js.map +1 -0
- package/dist/capabilities.d.ts +43 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +77 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/createLlmEffect.d.ts +110 -0
- package/dist/createLlmEffect.d.ts.map +1 -0
- package/dist/createLlmEffect.js +177 -0
- package/dist/createLlmEffect.js.map +1 -0
- package/dist/errors.d.ts +96 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +280 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/parts.d.ts +220 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +231 -0
- package/dist/parts.js.map +1 -0
- package/dist/providers/AnthropicProvider.d.ts +53 -0
- package/dist/providers/AnthropicProvider.d.ts.map +1 -0
- package/dist/providers/AnthropicProvider.js +443 -0
- package/dist/providers/AnthropicProvider.js.map +1 -0
- package/dist/providers/GeminiProvider.d.ts +66 -0
- package/dist/providers/GeminiProvider.d.ts.map +1 -0
- package/dist/providers/GeminiProvider.js +281 -0
- package/dist/providers/GeminiProvider.js.map +1 -0
- package/dist/providers/OpenAiProvider.d.ts +56 -0
- package/dist/providers/OpenAiProvider.d.ts.map +1 -0
- package/dist/providers/OpenAiProvider.js +402 -0
- package/dist/providers/OpenAiProvider.js.map +1 -0
- package/dist/providers/extraHeaders.d.ts +7 -0
- package/dist/providers/extraHeaders.d.ts.map +1 -0
- package/dist/providers/extraHeaders.js +40 -0
- package/dist/providers/extraHeaders.js.map +1 -0
- package/dist/providers/systemPrompt.d.ts +10 -0
- package/dist/providers/systemPrompt.d.ts.map +1 -0
- package/dist/providers/systemPrompt.js +22 -0
- package/dist/providers/systemPrompt.js.map +1 -0
- package/dist/reasoning.d.ts +154 -0
- package/dist/reasoning.d.ts.map +1 -0
- package/dist/reasoning.js +256 -0
- package/dist/reasoning.js.map +1 -0
- package/dist/resolveContent.d.ts +74 -0
- package/dist/resolveContent.d.ts.map +1 -0
- package/dist/resolveContent.js +335 -0
- package/dist/resolveContent.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/untrusted.d.ts +91 -0
- package/dist/untrusted.d.ts.map +1 -0
- package/dist/untrusted.js +385 -0
- package/dist/untrusted.js.map +1 -0
- package/package.json +54 -3
- package/src/assembleStream.ts +219 -0
- package/src/capabilities.ts +96 -0
- package/src/createLlmEffect.ts +287 -0
- package/src/errors.ts +269 -0
- package/src/index.ts +137 -0
- package/src/parts.ts +409 -0
- package/src/providers/AnthropicProvider.ts +550 -0
- package/src/providers/GeminiProvider.ts +380 -0
- package/src/providers/OpenAiProvider.ts +511 -0
- package/src/providers/extraHeaders.ts +41 -0
- package/src/providers/systemPrompt.ts +19 -0
- package/src/reasoning.ts +386 -0
- package/src/resolveContent.ts +425 -0
- package/src/types.ts +175 -0
- package/src/untrusted.ts +440 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeminiProvider = exports.GEMINI_MEDIA_MODELS = exports.GEMINI_CAPABILITIES = void 0;
|
|
4
|
+
exports.mapContents = mapContents;
|
|
5
|
+
const capabilities_1 = require("../capabilities");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const parts_1 = require("../parts");
|
|
8
|
+
const resolveContent_1 = require("../resolveContent");
|
|
9
|
+
const untrusted_1 = require("../untrusted");
|
|
10
|
+
const extraHeaders_1 = require("./extraHeaders");
|
|
11
|
+
const systemPrompt_1 = require("./systemPrompt");
|
|
12
|
+
/** `generateContent` takes any inline mime type the model supports; declare the common ones. */
|
|
13
|
+
exports.GEMINI_CAPABILITIES = {
|
|
14
|
+
image: ["image/png", "image/jpeg", "image/webp", "image/heic", "image/heif"],
|
|
15
|
+
audio: ["audio/wav", "audio/mp3", "audio/mpeg", "audio/aac", "audio/ogg", "audio/flac"],
|
|
16
|
+
file: ["application/pdf", "text/plain"],
|
|
17
|
+
reasoning: true,
|
|
18
|
+
};
|
|
19
|
+
const PROVIDER_ID = "gemini";
|
|
20
|
+
/** Model families that take media: Gemini 1.5 and later, and the `-latest` aliases (1.0 Pro does not). */
|
|
21
|
+
exports.GEMINI_MEDIA_MODELS = [/^gemini-(1\.5|[2-9])/, /^gemini-(flash|pro)(-lite)?-latest$/];
|
|
22
|
+
const GEMINI_DEFAULT_URL = "https://generativelanguage.googleapis.com";
|
|
23
|
+
/** Gemini returns no call id by default; the ones we synthesise carry this prefix and are never sent back. */
|
|
24
|
+
const SYNTHETIC_ID = "gemini-call-";
|
|
25
|
+
function inlineBlock(p) {
|
|
26
|
+
return { inlineData: { mimeType: p.mediaType, data: (0, resolveContent_1.inlineData)(p) } };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* SPI messages → Gemini `contents`. `functionResponse` is matched to its call by NAME, which
|
|
30
|
+
* the SPI's `tool_result` does not carry, so names are recovered from the earlier `tool_use`
|
|
31
|
+
* part with the same id. Media a tool returned rides as extra `inlineData` parts alongside.
|
|
32
|
+
* Exported for tests.
|
|
33
|
+
*/
|
|
34
|
+
function mapContents(messages) {
|
|
35
|
+
const names = new Map();
|
|
36
|
+
const out = [];
|
|
37
|
+
for (const m of messages) {
|
|
38
|
+
if (m.role === "system")
|
|
39
|
+
continue;
|
|
40
|
+
const role = m.role === "assistant" ? "model" : "user";
|
|
41
|
+
if (typeof m.content === "string") {
|
|
42
|
+
out.push({ role, parts: [{ text: m.content }] });
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const parts = [];
|
|
46
|
+
const trailing = [];
|
|
47
|
+
for (const p of (0, untrusted_1.fenceUntrustedMedia)(m.content)) {
|
|
48
|
+
switch (p.type) {
|
|
49
|
+
case "text":
|
|
50
|
+
parts.push({ text: p.text });
|
|
51
|
+
break;
|
|
52
|
+
case "reasoning":
|
|
53
|
+
// Only our own thought parts go back, unchanged; another provider's signature means
|
|
54
|
+
// nothing here. A redacted part has no Gemini form.
|
|
55
|
+
if (p.provider === PROVIDER_ID && p.kind !== "redacted") {
|
|
56
|
+
parts.push({
|
|
57
|
+
text: p.text ?? "",
|
|
58
|
+
thought: true,
|
|
59
|
+
...(p.signature !== undefined && { thoughtSignature: p.signature }),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "image":
|
|
64
|
+
case "audio":
|
|
65
|
+
case "file":
|
|
66
|
+
parts.push(inlineBlock(p));
|
|
67
|
+
break;
|
|
68
|
+
case "tool_use":
|
|
69
|
+
names.set(p.id, p.name);
|
|
70
|
+
parts.push({
|
|
71
|
+
functionCall: {
|
|
72
|
+
...(!p.id.startsWith(SYNTHETIC_ID) && { id: p.id }),
|
|
73
|
+
name: p.name,
|
|
74
|
+
args: p.input ?? {},
|
|
75
|
+
},
|
|
76
|
+
// Gemini 3 400s a current-turn functionCall sent back without its signature.
|
|
77
|
+
...(p.signature !== undefined && { thoughtSignature: p.signature }),
|
|
78
|
+
});
|
|
79
|
+
break;
|
|
80
|
+
case "tool_result": {
|
|
81
|
+
const items = typeof p.content === "string"
|
|
82
|
+
? [{ type: "text", text: p.content }]
|
|
83
|
+
: p.content;
|
|
84
|
+
const text = items.flatMap((r) => (r.type === "text" ? [r.text] : [])).join("\n");
|
|
85
|
+
parts.push({
|
|
86
|
+
functionResponse: {
|
|
87
|
+
...(!p.toolUseId.startsWith(SYNTHETIC_ID) && { id: p.toolUseId }),
|
|
88
|
+
name: names.get(p.toolUseId) ?? p.toolUseId,
|
|
89
|
+
response: p.isError === true ? { error: text } : { output: text },
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
for (const r of items) {
|
|
93
|
+
if (r.type === "text")
|
|
94
|
+
continue;
|
|
95
|
+
// The fence travels with the media into the trailing parts; the functionResponse
|
|
96
|
+
// holds text only.
|
|
97
|
+
for (const q of (0, untrusted_1.fenceUntrustedMedia)([r])) {
|
|
98
|
+
trailing.push(q.type === "text" ? { text: q.text } : inlineBlock(q));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
out.push({ role, parts: [...parts, ...trailing] });
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
const ERROR_INFO_TYPE = "type.googleapis.com/google.rpc.ErrorInfo";
|
|
110
|
+
/**
|
|
111
|
+
* `google.rpc.ErrorInfo.reason` values that mean the API key itself was refused. Only
|
|
112
|
+
* `API_KEY_INVALID` is documented for this (googleapis `google/api/error_reason.proto`; there is no
|
|
113
|
+
* separate documented reason for an expired key); the `API_KEY_*_BLOCKED` reasons are restrictions, not a bad key.
|
|
114
|
+
*/
|
|
115
|
+
function isApiKeyInvalid(body) {
|
|
116
|
+
const details = body?.error?.details;
|
|
117
|
+
return (Array.isArray(details) &&
|
|
118
|
+
details.some((d) => typeof d === "object" &&
|
|
119
|
+
d !== null &&
|
|
120
|
+
d["@type"] === ERROR_INFO_TYPE &&
|
|
121
|
+
d.reason === "API_KEY_INVALID"));
|
|
122
|
+
}
|
|
123
|
+
// A Google Gemini (Generative Language API) provider — the same fetch-based shape as
|
|
124
|
+
// OpenAiProvider / AnthropicProvider, mapping the Loom `LlmRequest`/`LlmResponse` contract
|
|
125
|
+
// onto Gemini's `generateContent`. Gemini uses roles "user" / "model" (no "assistant") and
|
|
126
|
+
// carries the system prompt as a separate `systemInstruction`, so we translate accordingly.
|
|
127
|
+
class GeminiProvider {
|
|
128
|
+
apiKey;
|
|
129
|
+
model;
|
|
130
|
+
baseUrl;
|
|
131
|
+
maxResponseBytes;
|
|
132
|
+
maxStreamBytes;
|
|
133
|
+
maxLineBytes;
|
|
134
|
+
includeThoughts;
|
|
135
|
+
thinkingBudget;
|
|
136
|
+
extraHeaders;
|
|
137
|
+
capabilities;
|
|
138
|
+
constructor(config = {}) {
|
|
139
|
+
this.extraHeaders = (0, extraHeaders_1.validateExtraHeaders)(config.headers, ["x-goog-api-key", "content-type", "authorization"], "GeminiProvider");
|
|
140
|
+
this.includeThoughts = config.includeThoughts;
|
|
141
|
+
if (config.thinkingBudget !== undefined &&
|
|
142
|
+
!(Number.isInteger(config.thinkingBudget) && config.thinkingBudget >= -1))
|
|
143
|
+
throw new RangeError("thinkingBudget must be an integer >= -1 (-1 = dynamic)");
|
|
144
|
+
this.thinkingBudget = config.thinkingBudget;
|
|
145
|
+
const model = config.model ?? "gemini-2.0-flash";
|
|
146
|
+
this.capabilities =
|
|
147
|
+
config.capabilities ??
|
|
148
|
+
(config.baseUrl !== undefined && config.baseUrl !== GEMINI_DEFAULT_URL
|
|
149
|
+
? {}
|
|
150
|
+
: (0, capabilities_1.capabilitiesForModel)(model, exports.GEMINI_CAPABILITIES, exports.GEMINI_MEDIA_MODELS));
|
|
151
|
+
this.apiKey =
|
|
152
|
+
config.apiKey ??
|
|
153
|
+
(typeof process !== "undefined"
|
|
154
|
+
? (process.env.GEMINI_API_KEY ?? process.env.GOOGLE_API_KEY ?? "")
|
|
155
|
+
: "");
|
|
156
|
+
this.model = config.model ?? "gemini-2.0-flash";
|
|
157
|
+
this.baseUrl = config.baseUrl ?? GEMINI_DEFAULT_URL;
|
|
158
|
+
this.maxResponseBytes = (0, errors_1.resolveLimit)(config.maxResponseBytes, errors_1.DEFAULT_MAX_RESPONSE_BYTES, "maxResponseBytes");
|
|
159
|
+
this.maxStreamBytes = (0, errors_1.resolveLimit)(config.maxStreamBytes, errors_1.DEFAULT_MAX_STREAM_BYTES, "maxStreamBytes");
|
|
160
|
+
this.maxLineBytes = (0, errors_1.resolveLimit)(config.maxLineBytes, errors_1.DEFAULT_MAX_LINE_BYTES, "maxLineBytes");
|
|
161
|
+
}
|
|
162
|
+
buildBody(request) {
|
|
163
|
+
// The one system-prompt rule (see `resolveSystem`).
|
|
164
|
+
const systemText = (0, systemPrompt_1.resolveSystem)(request) ?? "";
|
|
165
|
+
const contents = mapContents(request.messages);
|
|
166
|
+
const generationConfig = {};
|
|
167
|
+
if (request.maxTokens !== undefined)
|
|
168
|
+
generationConfig.maxOutputTokens = request.maxTokens;
|
|
169
|
+
if (request.temperature !== undefined)
|
|
170
|
+
generationConfig.temperature = request.temperature;
|
|
171
|
+
const thinking = {};
|
|
172
|
+
if (this.includeThoughts !== undefined)
|
|
173
|
+
thinking.includeThoughts = this.includeThoughts;
|
|
174
|
+
if (this.thinkingBudget !== undefined)
|
|
175
|
+
thinking.thinkingBudget = this.thinkingBudget;
|
|
176
|
+
if (Object.keys(thinking).length > 0)
|
|
177
|
+
generationConfig.thinkingConfig = thinking;
|
|
178
|
+
return {
|
|
179
|
+
contents,
|
|
180
|
+
...(request.tools !== undefined &&
|
|
181
|
+
request.tools.length > 0 && {
|
|
182
|
+
tools: [
|
|
183
|
+
{
|
|
184
|
+
functionDeclarations: request.tools.map((t) => ({
|
|
185
|
+
name: t.name,
|
|
186
|
+
description: t.description,
|
|
187
|
+
parametersJsonSchema: t.inputSchema,
|
|
188
|
+
})),
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
}),
|
|
192
|
+
...(systemText.length > 0 && { systemInstruction: { parts: [{ text: systemText }] } }),
|
|
193
|
+
...(Object.keys(generationConfig).length > 0 && { generationConfig }),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async complete(request) {
|
|
197
|
+
(0, capabilities_1.assertRequestSupported)(request, this.capabilities, "GeminiProvider");
|
|
198
|
+
const body = this.buildBody(request);
|
|
199
|
+
const resp = await fetch(`${this.baseUrl}/v1beta/models/${this.model}:generateContent`, {
|
|
200
|
+
method: "POST",
|
|
201
|
+
headers: {
|
|
202
|
+
...this.extraHeaders,
|
|
203
|
+
"content-type": "application/json",
|
|
204
|
+
"x-goog-api-key": this.apiKey,
|
|
205
|
+
},
|
|
206
|
+
body: JSON.stringify(body),
|
|
207
|
+
...(request.signal !== undefined && { signal: request.signal }),
|
|
208
|
+
// Never follow a redirect (it would re-send the body and credentials to another origin): a 3xx
|
|
209
|
+
// comes back as a response and becomes `LlmHttpError(provider, status)` below.
|
|
210
|
+
redirect: "manual",
|
|
211
|
+
});
|
|
212
|
+
if (!resp.ok) {
|
|
213
|
+
// Google answers a bad/expired API key with a 400 whose ErrorInfo names the reason; the
|
|
214
|
+
// status alone reads as a malformed request. Only a 400 is inspected, bounded, and nothing of
|
|
215
|
+
// the body is kept.
|
|
216
|
+
if (resp.status === 400) {
|
|
217
|
+
// The bounded read consumes or cancels the body itself.
|
|
218
|
+
const kind = isApiKeyInvalid(await (0, errors_1.readBoundedErrorJson)(resp, request.signal))
|
|
219
|
+
? "auth"
|
|
220
|
+
: undefined;
|
|
221
|
+
throw new errors_1.LlmHttpError("gemini", 400, kind);
|
|
222
|
+
}
|
|
223
|
+
await (0, errors_1.drainBody)(resp);
|
|
224
|
+
throw new errors_1.LlmHttpError("gemini", resp.status);
|
|
225
|
+
}
|
|
226
|
+
const data = (await (0, errors_1.readBoundedJson)(resp, "gemini", this.maxResponseBytes));
|
|
227
|
+
const candidate = data.candidates?.[0];
|
|
228
|
+
const parts = candidate?.content?.parts ?? [];
|
|
229
|
+
// A thought part is reasoning, never answer text: it must not leak into `content`.
|
|
230
|
+
const content = parts.map((p) => (p.thought === true ? "" : (p.text ?? ""))).join("");
|
|
231
|
+
const toolCalls = [];
|
|
232
|
+
const reasoning = [];
|
|
233
|
+
// ADR 0133 D5 - the vendor's part order, so thought / text / functionCall positions round-trip.
|
|
234
|
+
const entries = [];
|
|
235
|
+
for (const p of parts) {
|
|
236
|
+
if (p.thought === true) {
|
|
237
|
+
reasoning.push({
|
|
238
|
+
kind: "summary",
|
|
239
|
+
text: p.text ?? "",
|
|
240
|
+
...(p.thoughtSignature !== undefined && { signature: p.thoughtSignature }),
|
|
241
|
+
provider: PROVIDER_ID,
|
|
242
|
+
});
|
|
243
|
+
entries.push("reasoning");
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (p.text !== undefined)
|
|
247
|
+
entries.push({ text: p.text.length });
|
|
248
|
+
if (p.functionCall !== undefined) {
|
|
249
|
+
const id = p.functionCall.id ?? `${SYNTHETIC_ID}${toolCalls.length}`;
|
|
250
|
+
toolCalls.push({
|
|
251
|
+
id,
|
|
252
|
+
name: p.functionCall.name,
|
|
253
|
+
input: p.functionCall.args ?? {},
|
|
254
|
+
...(p.thoughtSignature !== undefined && { signature: p.thoughtSignature }),
|
|
255
|
+
});
|
|
256
|
+
entries.push({ call: id });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const layout = (0, parts_1.layoutOf)(entries);
|
|
260
|
+
const stopReason = toolCalls.length > 0
|
|
261
|
+
? "tool_use"
|
|
262
|
+
: candidate?.finishReason === "MAX_TOKENS"
|
|
263
|
+
? "max_tokens"
|
|
264
|
+
: "end_turn";
|
|
265
|
+
return {
|
|
266
|
+
content,
|
|
267
|
+
...(toolCalls.length > 0 && { toolCalls }),
|
|
268
|
+
stopReason,
|
|
269
|
+
...(data.usageMetadata !== undefined && {
|
|
270
|
+
usage: {
|
|
271
|
+
inputTokens: data.usageMetadata.promptTokenCount ?? 0,
|
|
272
|
+
outputTokens: data.usageMetadata.candidatesTokenCount ?? 0,
|
|
273
|
+
},
|
|
274
|
+
}),
|
|
275
|
+
...(reasoning.length > 0 && { reasoning }),
|
|
276
|
+
...(layout !== undefined && { layout }),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.GeminiProvider = GeminiProvider;
|
|
281
|
+
//# sourceMappingURL=GeminiProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeminiProvider.js","sourceRoot":"","sources":["../../src/providers/GeminiProvider.ts"],"names":[],"mappings":";;;AA6GA,kCAyEC;AAtLD,kDAIyB;AACzB,sCASmB;AACnB,oCAMkB;AAClB,sDAA+C;AAE/C,4CAAmD;AACnD,iDAAsD;AACtD,iDAA+C;AAwC/C,gGAAgG;AACnF,QAAA,mBAAmB,GAAoB;IAClD,KAAK,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;IAC5E,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC;IACvF,IAAI,EAAE,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACvC,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,0GAA0G;AAC7F,QAAA,mBAAmB,GAAG,CAAC,sBAAsB,EAAE,qCAAqC,CAAC,CAAC;AACnG,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AAEvE,8GAA8G;AAC9G,MAAM,YAAY,GAAG,cAAc,CAAC;AAkBpC,SAAS,WAAW,CAAC,CAAe;IAClC,OAAO,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAA,2BAAU,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACxE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,QAA+B;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,MAAM,GAAG,GAA8B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;YAAE,SAAS;QAClC,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AI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,CAAC;QACjC,MAAM,UAAU,GACd,SAAS,CAAC,MAAM,GAAG,CAAC;YAClB,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,SAAS,EAAE,YAAY,KAAK,YAAY;gBACxC,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,UAAU,CAAC;QAEnB,OAAO;YACL,OAAO;YACP,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,UAAU;YACV,GAAG,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI;gBACtC,KAAK,EAAE;oBACL,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,gBAAgB,IAAI,CAAC;oBACrD,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,oBAAoB,IAAI,CAAC;iBAC3D;aACF,CAAC;YACF,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;SACxC,CAAC;IACJ,CAAC;CACF;AA1KD,wCA0KC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type LlmCapabilities } from "../capabilities";
|
|
2
|
+
import type { LlmMessage, LlmProvider, LlmRequest, LlmResponse, LlmStreamChunk } from "../types";
|
|
3
|
+
export interface OpenAiProviderConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Sent as `reasoning_effort` when set; servers that support reasoning return it only when asked.
|
|
6
|
+
* Which values a model accepts varies: `"minimal"` (gpt-5) and `"none"` (gpt-5.1+, Ollama) are
|
|
7
|
+
* not accepted everywhere, and an unsupported value is refused by the server, not by this client.
|
|
8
|
+
*/
|
|
9
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high";
|
|
10
|
+
/**
|
|
11
|
+
* Extra request headers sent on every request (for example `anthropic-workspace-id`). Header
|
|
12
|
+
* names and values must be strings without CR/LF; a header the provider sets itself (auth,
|
|
13
|
+
* protocol, content type) cannot be overridden and throws at construction. Unset, the request
|
|
14
|
+
* is unchanged.
|
|
15
|
+
*/
|
|
16
|
+
headers?: Readonly<Record<string, string>>;
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Cap on a complete response body, in bytes after decompression (default 8 MiB). Over it the
|
|
22
|
+
* body is cancelled and `LlmResponseLimitError` (provider and reason only) is thrown.
|
|
23
|
+
*/
|
|
24
|
+
maxResponseBytes?: number;
|
|
25
|
+
/** Cap on the total bytes read from a stream (default 128 MiB); same error. */
|
|
26
|
+
maxStreamBytes?: number;
|
|
27
|
+
/** Cap on one line of a stream, in UTF-8 bytes (default 1 MiB); same error. */
|
|
28
|
+
maxLineBytes?: number;
|
|
29
|
+
/** Override the declared modalities (e.g. a model without vision or audio input). */
|
|
30
|
+
capabilities?: LlmCapabilities;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* SPI messages → Chat Completions messages. Exported for tests.
|
|
34
|
+
*
|
|
35
|
+
* `tool_result` parts become `role: "tool"` messages (which must directly follow the
|
|
36
|
+
* assistant message that made the calls, hence they come first); a tool message holds text
|
|
37
|
+
* only, so media a tool returned rides in a trailing `user` message. Other user parts become
|
|
38
|
+
* one content-array `user` message; an assistant's `tool_use` parts become `tool_calls`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function mapMessages(messages: readonly LlmMessage[]): Record<string, unknown>[];
|
|
41
|
+
export declare class OpenAiProvider implements LlmProvider {
|
|
42
|
+
private readonly apiKey;
|
|
43
|
+
private readonly model;
|
|
44
|
+
private readonly baseUrl;
|
|
45
|
+
private readonly maxResponseBytes;
|
|
46
|
+
private readonly maxStreamBytes;
|
|
47
|
+
private readonly maxLineBytes;
|
|
48
|
+
private readonly extraHeaders;
|
|
49
|
+
private readonly reasoningEffort;
|
|
50
|
+
readonly capabilities: LlmCapabilities;
|
|
51
|
+
constructor(config?: OpenAiProviderConfig);
|
|
52
|
+
private buildBody;
|
|
53
|
+
complete(request: LlmRequest): Promise<LlmResponse>;
|
|
54
|
+
stream(request: LlmRequest): AsyncIterable<LlmStreamChunk>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=OpenAiProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAiProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,iBAAiB,CAAC;AAczB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,cAAc,EAEf,MAAM,UAAU,CAAC;AAwBlB,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACjE;;;;;OAKG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC;AAiED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE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