@revojs/ai 0.1.58
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/dist/index.d.ts +617 -0
- package/dist/index.js +76 -0
- package/dist/module/index.d.ts +3 -0
- package/dist/module/index.js +47 -0
- package/dist/protocols/anthropic-messages.d.ts +7 -0
- package/dist/protocols/anthropic-messages.js +377 -0
- package/dist/protocols/google-models.d.ts +7 -0
- package/dist/protocols/google-models.js +331 -0
- package/dist/protocols/openai-chat-completions.d.ts +7 -0
- package/dist/protocols/openai-chat-completions.js +334 -0
- package/dist/protocols/openai-responses.d.ts +7 -0
- package/dist/protocols/openai-responses.js +409 -0
- package/dist/providers/anthropic.d.ts +29 -0
- package/dist/providers/anthropic.js +40 -0
- package/dist/providers/deepseek.d.ts +15 -0
- package/dist/providers/deepseek.js +26 -0
- package/dist/providers/google.d.ts +25 -0
- package/dist/providers/google.js +36 -0
- package/dist/providers/moonshotai.d.ts +21 -0
- package/dist/providers/moonshotai.js +32 -0
- package/dist/providers/openai.d.ts +29 -0
- package/dist/providers/openai.js +40 -0
- package/dist/providers/opencode.d.ts +163 -0
- package/dist/providers/opencode.js +183 -0
- package/dist/providers/xai.d.ts +17 -0
- package/dist/providers/xai.js +28 -0
- package/dist/types/index.d.ts +14 -0
- package/package.json +37 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { mergeHeaders, readDataFrames, toStream } from "../index.js";
|
|
2
|
+
import { toJsonSchema } from "revojs/shared";
|
|
3
|
+
//#region src/protocols/openai-responses.ts
|
|
4
|
+
function toUsage(usage) {
|
|
5
|
+
const input = usage?.input_tokens;
|
|
6
|
+
const output = usage?.output_tokens;
|
|
7
|
+
const cached = usage?.input_tokens_details?.cached_tokens;
|
|
8
|
+
const reasoning = usage?.output_tokens_details?.reasoning_tokens;
|
|
9
|
+
return {
|
|
10
|
+
inputTokens: {
|
|
11
|
+
total: input,
|
|
12
|
+
noCache: input !== void 0 && cached !== void 0 ? Math.max(0, input - cached) : input,
|
|
13
|
+
cacheRead: cached,
|
|
14
|
+
cacheWrite: void 0
|
|
15
|
+
},
|
|
16
|
+
outputTokens: {
|
|
17
|
+
total: output,
|
|
18
|
+
text: output !== void 0 && reasoning !== void 0 ? Math.max(0, output - reasoning) : output,
|
|
19
|
+
reasoning
|
|
20
|
+
},
|
|
21
|
+
raw: usage
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function toFinishReason(status, toolCalls, incomplete) {
|
|
25
|
+
return {
|
|
26
|
+
unified: toolCalls ? "tool-calls" : incomplete === "max_output_tokens" ? "length" : status === "failed" ? "error" : "stop",
|
|
27
|
+
raw: incomplete ?? status ?? void 0
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function toResultValue(output) {
|
|
31
|
+
if (output.type === "text" || output.type === "error-text") return output.value;
|
|
32
|
+
const value = "value" in output ? output.value : void 0;
|
|
33
|
+
return JSON.stringify(value ?? null);
|
|
34
|
+
}
|
|
35
|
+
function toBody(options, stream) {
|
|
36
|
+
let instructions = "";
|
|
37
|
+
const warnings = [];
|
|
38
|
+
const input = [];
|
|
39
|
+
for (const message of options.prompt) {
|
|
40
|
+
if (message.role === "system") {
|
|
41
|
+
instructions += (instructions.length > 0 ? "\n" : "") + message.content;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (message.role === "user") {
|
|
45
|
+
const content = message.content.flatMap((part) => {
|
|
46
|
+
if (part.type === "text") return [{
|
|
47
|
+
type: "input_text",
|
|
48
|
+
text: part.text
|
|
49
|
+
}];
|
|
50
|
+
if (part.data.type === "url") return part.mediaType.startsWith("image/") ? [{
|
|
51
|
+
type: "input_image",
|
|
52
|
+
image_url: part.data.url.toString()
|
|
53
|
+
}] : [{
|
|
54
|
+
type: "input_file",
|
|
55
|
+
file_url: part.data.url.toString()
|
|
56
|
+
}];
|
|
57
|
+
if (part.type === "file" && part.data.type === "data" && typeof part.data.data === "string") {
|
|
58
|
+
const dataUrl = `data:${part.mediaType};base64,${part.data.data}`;
|
|
59
|
+
return part.mediaType.startsWith("image/") ? [{
|
|
60
|
+
type: "input_image",
|
|
61
|
+
image_url: dataUrl
|
|
62
|
+
}] : [{
|
|
63
|
+
type: "input_file",
|
|
64
|
+
file_data: dataUrl,
|
|
65
|
+
filename: part.fileName
|
|
66
|
+
}];
|
|
67
|
+
}
|
|
68
|
+
warnings.push({
|
|
69
|
+
type: "unsupported",
|
|
70
|
+
feature: `user ${part.type === "file" ? `file (${part.mediaType})` : "custom"} message part`
|
|
71
|
+
});
|
|
72
|
+
return [];
|
|
73
|
+
});
|
|
74
|
+
if (content.length > 0) input.push({
|
|
75
|
+
role: "user",
|
|
76
|
+
content
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (message.role === "tool") {
|
|
81
|
+
for (const part of message.content) if (part.type === "tool-result") input.push({
|
|
82
|
+
type: "function_call_output",
|
|
83
|
+
call_id: part.toolCallId,
|
|
84
|
+
output: toResultValue(part.output)
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const text = message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
89
|
+
if (text.length > 0) input.push({
|
|
90
|
+
role: "assistant",
|
|
91
|
+
content: [{
|
|
92
|
+
type: "output_text",
|
|
93
|
+
text
|
|
94
|
+
}]
|
|
95
|
+
});
|
|
96
|
+
for (const part of message.content) {
|
|
97
|
+
if (part.type === "tool-call") {
|
|
98
|
+
input.push({
|
|
99
|
+
type: "function_call",
|
|
100
|
+
call_id: part.toolCallId,
|
|
101
|
+
name: part.toolName,
|
|
102
|
+
arguments: typeof part.input === "string" ? part.input : JSON.stringify(part.input ?? {})
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (part.type === "tool-result") {
|
|
107
|
+
input.push({
|
|
108
|
+
type: "function_call_output",
|
|
109
|
+
call_id: part.toolCallId,
|
|
110
|
+
output: toResultValue(part.output)
|
|
111
|
+
});
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (part.type !== "text") warnings.push({
|
|
115
|
+
type: "compatibility",
|
|
116
|
+
feature: `assistant ${part.type} message part`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (options.stopSequences !== void 0) warnings.push({
|
|
121
|
+
type: "unsupported",
|
|
122
|
+
feature: "stop sequences"
|
|
123
|
+
});
|
|
124
|
+
if (options.presencePenalty !== void 0 || options.frequencyPenalty !== void 0) warnings.push({
|
|
125
|
+
type: "unsupported",
|
|
126
|
+
feature: "presence/frequency penalties"
|
|
127
|
+
});
|
|
128
|
+
return [{
|
|
129
|
+
model: options.model,
|
|
130
|
+
stream,
|
|
131
|
+
...instructions.length > 0 ? { instructions } : {},
|
|
132
|
+
input,
|
|
133
|
+
...options.maxOutputTokens !== void 0 ? { max_output_tokens: options.maxOutputTokens } : {},
|
|
134
|
+
...options.temperature !== void 0 ? { temperature: options.temperature } : {},
|
|
135
|
+
...options.topP !== void 0 ? { top_p: options.topP } : {},
|
|
136
|
+
...options.seed !== void 0 ? { seed: options.seed } : {},
|
|
137
|
+
...options.reasoning !== void 0 && options.reasoning !== "provider-default" ? { reasoning: { effort: options.reasoning === "none" ? "minimal" : options.reasoning } } : {},
|
|
138
|
+
...options.tools !== void 0 && options.tools.length > 0 ? { tools: options.tools.map((tool) => tool.type === "provider" ? {
|
|
139
|
+
type: tool.id,
|
|
140
|
+
...tool.args
|
|
141
|
+
} : {
|
|
142
|
+
type: "function",
|
|
143
|
+
name: tool.name,
|
|
144
|
+
description: tool.description,
|
|
145
|
+
parameters: toJsonSchema(tool.inputSchema),
|
|
146
|
+
strict: tool.strict
|
|
147
|
+
}) } : {},
|
|
148
|
+
...options.toolChoice !== void 0 ? { tool_choice: options.toolChoice.type === "tool" ? {
|
|
149
|
+
type: "function",
|
|
150
|
+
name: options.toolChoice.toolName
|
|
151
|
+
} : options.toolChoice.type } : {},
|
|
152
|
+
...options.responseFormat !== void 0 && options.responseFormat.type === "json" ? { text: { format: options.responseFormat.schema === void 0 ? { type: "json_object" } : {
|
|
153
|
+
type: "json_schema",
|
|
154
|
+
name: options.responseFormat.name ?? "response",
|
|
155
|
+
schema: toJsonSchema(options.responseFormat.schema)
|
|
156
|
+
} } } : {},
|
|
157
|
+
...options.providerOptions?.responses
|
|
158
|
+
}, warnings];
|
|
159
|
+
}
|
|
160
|
+
async function* readParts(response, warnings) {
|
|
161
|
+
yield {
|
|
162
|
+
type: "stream-start",
|
|
163
|
+
warnings
|
|
164
|
+
};
|
|
165
|
+
const text = /* @__PURE__ */ new Set();
|
|
166
|
+
const reasoning = /* @__PURE__ */ new Set();
|
|
167
|
+
const tools = /* @__PURE__ */ new Map();
|
|
168
|
+
let metadataSent = false;
|
|
169
|
+
let hasToolCall = false;
|
|
170
|
+
let status;
|
|
171
|
+
let incomplete;
|
|
172
|
+
let usage;
|
|
173
|
+
for await (const data of readDataFrames(response)) {
|
|
174
|
+
let event;
|
|
175
|
+
try {
|
|
176
|
+
event = JSON.parse(data);
|
|
177
|
+
} catch {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (event.type === "response.created" && !metadataSent) {
|
|
181
|
+
metadataSent = true;
|
|
182
|
+
yield {
|
|
183
|
+
type: "response-metadata",
|
|
184
|
+
id: event.response?.id,
|
|
185
|
+
modelId: event.response?.model
|
|
186
|
+
};
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (event.type === "response.output_item.added" && event.item?.type === "function_call") {
|
|
190
|
+
const streamId = event.item.id ?? event.item.call_id ?? `responses-tool-${event.output_index ?? tools.size}`;
|
|
191
|
+
const record = {
|
|
192
|
+
streamId,
|
|
193
|
+
callId: event.item.call_id ?? "",
|
|
194
|
+
name: event.item.name ?? "",
|
|
195
|
+
arguments: ""
|
|
196
|
+
};
|
|
197
|
+
tools.set(streamId, record);
|
|
198
|
+
yield {
|
|
199
|
+
type: "tool-input-start",
|
|
200
|
+
id: streamId,
|
|
201
|
+
toolName: record.name
|
|
202
|
+
};
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (event.type === "response.content_part.added" && event.part?.type === "output_text" && event.item_id !== void 0 && !text.has(event.item_id)) {
|
|
206
|
+
text.add(event.item_id);
|
|
207
|
+
yield {
|
|
208
|
+
type: "text-start",
|
|
209
|
+
id: event.item_id
|
|
210
|
+
};
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (event.type === "response.output_text.delta" && typeof event.delta === "string" && event.item_id !== void 0) {
|
|
214
|
+
if (!text.has(event.item_id)) {
|
|
215
|
+
text.add(event.item_id);
|
|
216
|
+
yield {
|
|
217
|
+
type: "text-start",
|
|
218
|
+
id: event.item_id
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
yield {
|
|
222
|
+
type: "text-delta",
|
|
223
|
+
id: event.item_id,
|
|
224
|
+
delta: event.delta
|
|
225
|
+
};
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (event.type === "response.output_text.done" && event.item_id !== void 0 && text.has(event.item_id)) {
|
|
229
|
+
text.delete(event.item_id);
|
|
230
|
+
yield {
|
|
231
|
+
type: "text-end",
|
|
232
|
+
id: event.item_id
|
|
233
|
+
};
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if ((event.type === "response.reasoning_summary_text.delta" || event.type === "response.reasoning_text.delta") && typeof event.delta === "string" && event.item_id !== void 0) {
|
|
237
|
+
if (!reasoning.has(event.item_id)) {
|
|
238
|
+
reasoning.add(event.item_id);
|
|
239
|
+
yield {
|
|
240
|
+
type: "reasoning-start",
|
|
241
|
+
id: event.item_id
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
yield {
|
|
245
|
+
type: "reasoning-delta",
|
|
246
|
+
id: event.item_id,
|
|
247
|
+
delta: event.delta
|
|
248
|
+
};
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (event.type === "response.function_call_arguments.delta" && typeof event.delta === "string" && event.item_id !== void 0) {
|
|
252
|
+
const record = tools.get(event.item_id);
|
|
253
|
+
if (record !== void 0) {
|
|
254
|
+
record.arguments += event.delta;
|
|
255
|
+
yield {
|
|
256
|
+
type: "tool-input-delta",
|
|
257
|
+
id: event.item_id,
|
|
258
|
+
delta: event.delta
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (event.type === "response.output_item.done" && event.item !== void 0) {
|
|
264
|
+
const itemId = event.item.id ?? "";
|
|
265
|
+
if (event.item.type === "function_call") {
|
|
266
|
+
const record = tools.get(itemId);
|
|
267
|
+
const streamId = record?.streamId ?? itemId;
|
|
268
|
+
tools.delete(itemId);
|
|
269
|
+
hasToolCall = true;
|
|
270
|
+
yield {
|
|
271
|
+
type: "tool-input-end",
|
|
272
|
+
id: streamId
|
|
273
|
+
};
|
|
274
|
+
yield {
|
|
275
|
+
type: "tool-call",
|
|
276
|
+
toolCallId: event.item.call_id ?? streamId,
|
|
277
|
+
toolName: event.item.name ?? record?.name ?? "",
|
|
278
|
+
input: event.item.arguments ?? record?.arguments ?? ""
|
|
279
|
+
};
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (reasoning.has(itemId)) {
|
|
283
|
+
reasoning.delete(itemId);
|
|
284
|
+
yield {
|
|
285
|
+
type: "reasoning-end",
|
|
286
|
+
id: itemId
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (event.type === "response.completed" || event.type === "response.incomplete") {
|
|
292
|
+
status = event.response?.status;
|
|
293
|
+
incomplete = event.response?.incomplete_details?.reason;
|
|
294
|
+
usage = toUsage(event.response?.usage);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (event.type === "response.failed") throw new Error(event.response?.error?.message ?? "Unknown AI provider error");
|
|
298
|
+
if (event.type === "error") throw new Error(event.message ?? "Unknown AI provider error");
|
|
299
|
+
}
|
|
300
|
+
for (const id of text) yield {
|
|
301
|
+
type: "text-end",
|
|
302
|
+
id
|
|
303
|
+
};
|
|
304
|
+
for (const id of reasoning) yield {
|
|
305
|
+
type: "reasoning-end",
|
|
306
|
+
id
|
|
307
|
+
};
|
|
308
|
+
for (const [id, record] of tools) {
|
|
309
|
+
yield {
|
|
310
|
+
type: "tool-input-end",
|
|
311
|
+
id: record.streamId
|
|
312
|
+
};
|
|
313
|
+
hasToolCall = true;
|
|
314
|
+
yield {
|
|
315
|
+
type: "tool-call",
|
|
316
|
+
toolCallId: record.callId || id,
|
|
317
|
+
toolName: record.name,
|
|
318
|
+
input: record.arguments
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
yield {
|
|
322
|
+
type: "finish",
|
|
323
|
+
usage: usage ?? toUsage(void 0),
|
|
324
|
+
finishReason: toFinishReason(status, hasToolCall, incomplete)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function responsesGenerateProtocol(config) {
|
|
328
|
+
return async (options) => {
|
|
329
|
+
const [body, warnings] = toBody(options, false);
|
|
330
|
+
const response = await fetch(`${config.baseURL.replace(/\/+$/, "")}/responses`, {
|
|
331
|
+
method: "POST",
|
|
332
|
+
headers: {
|
|
333
|
+
"Content-Type": "application/json",
|
|
334
|
+
...mergeHeaders(config.apiKey === void 0 ? {} : { Authorization: `Bearer ${config.apiKey}` }, options.headers)
|
|
335
|
+
},
|
|
336
|
+
body: JSON.stringify(body),
|
|
337
|
+
signal: options.abortSignal
|
|
338
|
+
});
|
|
339
|
+
if (!response.ok) throw new Error(`AI provider responded with ${response.status}: ${(await response.text()).slice(0, 500)}`);
|
|
340
|
+
const data = await response.json();
|
|
341
|
+
const content = [];
|
|
342
|
+
let toolCalls = false;
|
|
343
|
+
for (const item of data.output ?? []) {
|
|
344
|
+
if (item.type === "message") {
|
|
345
|
+
for (const part of item.content ?? []) if (part.type === "output_text" && typeof part.text === "string" && part.text.length > 0) content.push({
|
|
346
|
+
type: "text",
|
|
347
|
+
text: part.text
|
|
348
|
+
});
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
if (item.type === "reasoning") {
|
|
352
|
+
const text = [...item.summary ?? [], ...item.content ?? []].map((part) => part.text ?? "").join("");
|
|
353
|
+
if (text.length > 0) content.push({
|
|
354
|
+
type: "reasoning",
|
|
355
|
+
text
|
|
356
|
+
});
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (item.type === "function_call") {
|
|
360
|
+
toolCalls = true;
|
|
361
|
+
content.push({
|
|
362
|
+
type: "tool-call",
|
|
363
|
+
toolCallId: item.call_id ?? "",
|
|
364
|
+
toolName: item.name ?? "",
|
|
365
|
+
input: item.arguments ?? ""
|
|
366
|
+
});
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
warnings.push({
|
|
370
|
+
type: "compatibility",
|
|
371
|
+
feature: `output item ${item.type ?? "unknown"}`
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
content,
|
|
376
|
+
finishReason: toFinishReason(data.status, toolCalls, data.incomplete_details?.reason),
|
|
377
|
+
usage: toUsage(data.usage),
|
|
378
|
+
request: { body },
|
|
379
|
+
response: {
|
|
380
|
+
id: data.id,
|
|
381
|
+
modelId: data.model,
|
|
382
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
383
|
+
},
|
|
384
|
+
warnings
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function responsesStreamProtocol(config) {
|
|
389
|
+
return async (options) => {
|
|
390
|
+
const [body, warnings] = toBody(options, true);
|
|
391
|
+
const response = await fetch(`${config.baseURL.replace(/\/+$/, "")}/responses`, {
|
|
392
|
+
method: "POST",
|
|
393
|
+
headers: {
|
|
394
|
+
"Content-Type": "application/json",
|
|
395
|
+
...mergeHeaders(config.apiKey === void 0 ? {} : { Authorization: `Bearer ${config.apiKey}` }, options.headers)
|
|
396
|
+
},
|
|
397
|
+
body: JSON.stringify(body),
|
|
398
|
+
signal: options.abortSignal
|
|
399
|
+
});
|
|
400
|
+
if (!response.ok) throw new Error(`AI provider responded with ${response.status}: ${(await response.text()).slice(0, 500)}`);
|
|
401
|
+
return {
|
|
402
|
+
request: { body },
|
|
403
|
+
response: { headers: Object.fromEntries(response.headers.entries()) },
|
|
404
|
+
stream: toStream(() => readParts(response, warnings))
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
export { responsesGenerateProtocol, responsesStreamProtocol };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
setup: (scope: import("revojs").Scope) => {
|
|
3
|
+
textGenerate: {
|
|
4
|
+
"claude-sonnet-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
5
|
+
"claude-opus-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
6
|
+
"claude-fable-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
7
|
+
"claude-opus-4-8": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
+
"claude-opus-4-7": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
+
"claude-opus-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
+
"claude-opus-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
11
|
+
"claude-sonnet-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
12
|
+
"claude-sonnet-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
13
|
+
"claude-haiku-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
14
|
+
};
|
|
15
|
+
textStream: {
|
|
16
|
+
"claude-sonnet-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
+
"claude-opus-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
+
"claude-fable-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
19
|
+
"claude-opus-4-8": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
20
|
+
"claude-opus-4-7": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
21
|
+
"claude-opus-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
22
|
+
"claude-opus-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
23
|
+
"claude-sonnet-4-6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
24
|
+
"claude-sonnet-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
25
|
+
"claude-haiku-4-5": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineProvider } from "../index.js";
|
|
2
|
+
import { messagesGenerateProtocol, messagesStreamProtocol } from "../protocols/anthropic-messages.js";
|
|
3
|
+
import { useVariables } from "revojs";
|
|
4
|
+
//#region src/providers/anthropic.ts
|
|
5
|
+
var anthropic_default = defineProvider({ setup: (scope) => {
|
|
6
|
+
const config = {
|
|
7
|
+
baseURL: "https://api.anthropic.com/v1",
|
|
8
|
+
apiKey: useVariables(scope).anthropicApiKey
|
|
9
|
+
};
|
|
10
|
+
const messagesGenerate = messagesGenerateProtocol(config);
|
|
11
|
+
const messagesStream = messagesStreamProtocol(config);
|
|
12
|
+
return {
|
|
13
|
+
textGenerate: {
|
|
14
|
+
"claude-sonnet-5": messagesGenerate,
|
|
15
|
+
"claude-opus-5": messagesGenerate,
|
|
16
|
+
"claude-fable-5": messagesGenerate,
|
|
17
|
+
"claude-opus-4-8": messagesGenerate,
|
|
18
|
+
"claude-opus-4-7": messagesGenerate,
|
|
19
|
+
"claude-opus-4-6": messagesGenerate,
|
|
20
|
+
"claude-opus-4-5": messagesGenerate,
|
|
21
|
+
"claude-sonnet-4-6": messagesGenerate,
|
|
22
|
+
"claude-sonnet-4-5": messagesGenerate,
|
|
23
|
+
"claude-haiku-4-5": messagesGenerate
|
|
24
|
+
},
|
|
25
|
+
textStream: {
|
|
26
|
+
"claude-sonnet-5": messagesStream,
|
|
27
|
+
"claude-opus-5": messagesStream,
|
|
28
|
+
"claude-fable-5": messagesStream,
|
|
29
|
+
"claude-opus-4-8": messagesStream,
|
|
30
|
+
"claude-opus-4-7": messagesStream,
|
|
31
|
+
"claude-opus-4-6": messagesStream,
|
|
32
|
+
"claude-opus-4-5": messagesStream,
|
|
33
|
+
"claude-sonnet-4-6": messagesStream,
|
|
34
|
+
"claude-sonnet-4-5": messagesStream,
|
|
35
|
+
"claude-haiku-4-5": messagesStream
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
} });
|
|
39
|
+
//#endregion
|
|
40
|
+
export { anthropic_default as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
setup: (scope: import("revojs").Scope) => {
|
|
3
|
+
textGenerate: {
|
|
4
|
+
"deepseek-v4-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
5
|
+
"deepseek-v4-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
6
|
+
"deepseek-v4-flash-vision-exp": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
7
|
+
};
|
|
8
|
+
textStream: {
|
|
9
|
+
"deepseek-v4-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
10
|
+
"deepseek-v4-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
11
|
+
"deepseek-v4-flash-vision-exp": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineProvider } from "../index.js";
|
|
2
|
+
import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
|
|
3
|
+
import { useVariables } from "revojs";
|
|
4
|
+
//#region src/providers/deepseek.ts
|
|
5
|
+
var deepseek_default = defineProvider({ setup: (scope) => {
|
|
6
|
+
const config = {
|
|
7
|
+
baseURL: "https://api.deepseek.com/v1",
|
|
8
|
+
apiKey: useVariables(scope).deepseekApiKey
|
|
9
|
+
};
|
|
10
|
+
const chatCompletionsGenerate = chatCompletionsGenerateProtocol(config);
|
|
11
|
+
const chatCompletionsStream = chatCompletionsStreamProtocol(config);
|
|
12
|
+
return {
|
|
13
|
+
textGenerate: {
|
|
14
|
+
"deepseek-v4-pro": chatCompletionsGenerate,
|
|
15
|
+
"deepseek-v4-flash": chatCompletionsGenerate,
|
|
16
|
+
"deepseek-v4-flash-vision-exp": chatCompletionsGenerate
|
|
17
|
+
},
|
|
18
|
+
textStream: {
|
|
19
|
+
"deepseek-v4-pro": chatCompletionsStream,
|
|
20
|
+
"deepseek-v4-flash": chatCompletionsStream,
|
|
21
|
+
"deepseek-v4-flash-vision-exp": chatCompletionsStream
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
} });
|
|
25
|
+
//#endregion
|
|
26
|
+
export { deepseek_default as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
setup: (scope: import("revojs").Scope) => {
|
|
3
|
+
textGenerate: {
|
|
4
|
+
"gemini-3.7-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
5
|
+
"gemini-3.6-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
6
|
+
"gemini-3.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
7
|
+
"gemini-3.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
+
"gemini-3.1-pro-preview": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
+
"gemini-2.5-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
+
"gemini-2.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
11
|
+
"gemini-2.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
12
|
+
};
|
|
13
|
+
textStream: {
|
|
14
|
+
"gemini-3.7-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
15
|
+
"gemini-3.6-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
16
|
+
"gemini-3.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
+
"gemini-3.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
+
"gemini-3.1-pro-preview": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
19
|
+
"gemini-2.5-pro": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
20
|
+
"gemini-2.5-flash": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
21
|
+
"gemini-2.5-flash-lite": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineProvider } from "../index.js";
|
|
2
|
+
import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
|
|
3
|
+
import { useVariables } from "revojs";
|
|
4
|
+
//#region src/providers/google.ts
|
|
5
|
+
var google_default = defineProvider({ setup: (scope) => {
|
|
6
|
+
const config = {
|
|
7
|
+
baseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
8
|
+
apiKey: useVariables(scope).googleApiKey
|
|
9
|
+
};
|
|
10
|
+
const chatCompletionsGenerate = chatCompletionsGenerateProtocol(config);
|
|
11
|
+
const chatCompletionsStream = chatCompletionsStreamProtocol(config);
|
|
12
|
+
return {
|
|
13
|
+
textGenerate: {
|
|
14
|
+
"gemini-3.7-flash": chatCompletionsGenerate,
|
|
15
|
+
"gemini-3.6-flash": chatCompletionsGenerate,
|
|
16
|
+
"gemini-3.5-flash": chatCompletionsGenerate,
|
|
17
|
+
"gemini-3.5-flash-lite": chatCompletionsGenerate,
|
|
18
|
+
"gemini-3.1-pro-preview": chatCompletionsGenerate,
|
|
19
|
+
"gemini-2.5-pro": chatCompletionsGenerate,
|
|
20
|
+
"gemini-2.5-flash": chatCompletionsGenerate,
|
|
21
|
+
"gemini-2.5-flash-lite": chatCompletionsGenerate
|
|
22
|
+
},
|
|
23
|
+
textStream: {
|
|
24
|
+
"gemini-3.7-flash": chatCompletionsStream,
|
|
25
|
+
"gemini-3.6-flash": chatCompletionsStream,
|
|
26
|
+
"gemini-3.5-flash": chatCompletionsStream,
|
|
27
|
+
"gemini-3.5-flash-lite": chatCompletionsStream,
|
|
28
|
+
"gemini-3.1-pro-preview": chatCompletionsStream,
|
|
29
|
+
"gemini-2.5-pro": chatCompletionsStream,
|
|
30
|
+
"gemini-2.5-flash": chatCompletionsStream,
|
|
31
|
+
"gemini-2.5-flash-lite": chatCompletionsStream
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
} });
|
|
35
|
+
//#endregion
|
|
36
|
+
export { google_default as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
setup: (scope: import("revojs").Scope) => {
|
|
3
|
+
textGenerate: {
|
|
4
|
+
"kimi-k3": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
5
|
+
"kimi-k2.7-code": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
6
|
+
"kimi-k2.7-code-highspeed": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
7
|
+
"kimi-k2.6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
8
|
+
"kimi-k2-thinking": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
9
|
+
"kimi-k2-thinking-turbo": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelGenerateResult>;
|
|
10
|
+
};
|
|
11
|
+
textStream: {
|
|
12
|
+
"kimi-k3": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
13
|
+
"kimi-k2.7-code": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
14
|
+
"kimi-k2.7-code-highspeed": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
15
|
+
"kimi-k2.6": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
16
|
+
"kimi-k2-thinking": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
17
|
+
"kimi-k2-thinking-turbo": import("../index").Protocol<import("../index").LanguageModelCallOptions<string>, import("../index").LanguageModelStreamResult>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineProvider } from "../index.js";
|
|
2
|
+
import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
|
|
3
|
+
import { useVariables } from "revojs";
|
|
4
|
+
//#region src/providers/moonshotai.ts
|
|
5
|
+
var moonshotai_default = defineProvider({ setup: (scope) => {
|
|
6
|
+
const config = {
|
|
7
|
+
baseURL: "https://api.moonshot.ai/v1",
|
|
8
|
+
apiKey: useVariables(scope).moonshotaiApiKey
|
|
9
|
+
};
|
|
10
|
+
const chatCompletionsGenerate = chatCompletionsGenerateProtocol(config);
|
|
11
|
+
const chatCompletionsStream = chatCompletionsStreamProtocol(config);
|
|
12
|
+
return {
|
|
13
|
+
textGenerate: {
|
|
14
|
+
"kimi-k3": chatCompletionsGenerate,
|
|
15
|
+
"kimi-k2.7-code": chatCompletionsGenerate,
|
|
16
|
+
"kimi-k2.7-code-highspeed": chatCompletionsGenerate,
|
|
17
|
+
"kimi-k2.6": chatCompletionsGenerate,
|
|
18
|
+
"kimi-k2-thinking": chatCompletionsGenerate,
|
|
19
|
+
"kimi-k2-thinking-turbo": chatCompletionsGenerate
|
|
20
|
+
},
|
|
21
|
+
textStream: {
|
|
22
|
+
"kimi-k3": chatCompletionsStream,
|
|
23
|
+
"kimi-k2.7-code": chatCompletionsStream,
|
|
24
|
+
"kimi-k2.7-code-highspeed": chatCompletionsStream,
|
|
25
|
+
"kimi-k2.6": chatCompletionsStream,
|
|
26
|
+
"kimi-k2-thinking": chatCompletionsStream,
|
|
27
|
+
"kimi-k2-thinking-turbo": chatCompletionsStream
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
} });
|
|
31
|
+
//#endregion
|
|
32
|
+
export { moonshotai_default as default };
|