@mohanscodex/spectra-ai 0.4.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/README.md +189 -0
- package/dist/__tests__/e2e.test.d.ts +2 -0
- package/dist/__tests__/e2e.test.d.ts.map +1 -0
- package/dist/__tests__/e2e.test.js +364 -0
- package/dist/__tests__/e2e.test.js.map +1 -0
- package/dist/__tests__/event-stream.test.d.ts +2 -0
- package/dist/__tests__/event-stream.test.d.ts.map +1 -0
- package/dist/__tests__/event-stream.test.js +87 -0
- package/dist/__tests__/event-stream.test.js.map +1 -0
- package/dist/__tests__/provider.test.d.ts +2 -0
- package/dist/__tests__/provider.test.d.ts.map +1 -0
- package/dist/__tests__/provider.test.js +40 -0
- package/dist/__tests__/provider.test.js.map +1 -0
- package/dist/event-stream.d.ts +19 -0
- package/dist/event-stream.d.ts.map +1 -0
- package/dist/event-stream.js +74 -0
- package/dist/event-stream.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +6 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +16480 -0
- package/dist/models.js.map +1 -0
- package/dist/providers/anthropic.d.ts +8 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +279 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/groq.d.ts +16 -0
- package/dist/providers/groq.d.ts.map +1 -0
- package/dist/providers/groq.js +196 -0
- package/dist/providers/groq.js.map +1 -0
- package/dist/providers/openai-completions.d.ts +17 -0
- package/dist/providers/openai-completions.d.ts.map +1 -0
- package/dist/providers/openai-completions.js +319 -0
- package/dist/providers/openai-completions.js.map +1 -0
- package/dist/providers/openai-responses.d.ts +12 -0
- package/dist/providers/openai-responses.d.ts.map +1 -0
- package/dist/providers/openai-responses.js +335 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/providers/openrouter.d.ts +12 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +42 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/register-builtins.d.ts +2 -0
- package/dist/providers/register-builtins.d.ts.map +1 -0
- package/dist/providers/register-builtins.js +41 -0
- package/dist/providers/register-builtins.js.map +1 -0
- package/dist/providers/shared.d.ts +3 -0
- package/dist/providers/shared.d.ts.map +1 -0
- package/dist/providers/shared.js +12 -0
- package/dist/providers/shared.js.map +1 -0
- package/dist/registry.d.ts +19 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +28 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +164 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
import { AssistantMessageEventStream } from "../event-stream.js";
|
|
3
|
+
function getEnvApiKey(provider) {
|
|
4
|
+
const keys = {
|
|
5
|
+
anthropic: process.env.ANTHROPIC_API_KEY ?? process.env.ANTHROPIC_KEY,
|
|
6
|
+
};
|
|
7
|
+
return keys[provider];
|
|
8
|
+
}
|
|
9
|
+
function sanitizeSurrogates(text) {
|
|
10
|
+
return text.replace(/[\u0080-\uFFFF]/g, (c) => `\\u${c.charCodeAt(0).toString(16)}`);
|
|
11
|
+
}
|
|
12
|
+
function toAnthropicMessage(message) {
|
|
13
|
+
if (message.role === "user") {
|
|
14
|
+
const content = typeof message.content === "string"
|
|
15
|
+
? sanitizeSurrogates(message.content)
|
|
16
|
+
: message.content.map((block) => {
|
|
17
|
+
if (block.type === "text") {
|
|
18
|
+
return { type: "text", text: sanitizeSurrogates(block.text) };
|
|
19
|
+
}
|
|
20
|
+
if (block.type === "image") {
|
|
21
|
+
return {
|
|
22
|
+
type: "image",
|
|
23
|
+
source: {
|
|
24
|
+
type: "base64",
|
|
25
|
+
media_type: block.mimeType,
|
|
26
|
+
data: block.data,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return { type: "text", text: "" };
|
|
31
|
+
});
|
|
32
|
+
return { role: "user", content };
|
|
33
|
+
}
|
|
34
|
+
if (message.role === "assistant") {
|
|
35
|
+
const content = message.content.map((block) => {
|
|
36
|
+
if (block.type === "text") {
|
|
37
|
+
return { type: "text", text: sanitizeSurrogates(block.text) };
|
|
38
|
+
}
|
|
39
|
+
if (block.type === "thinking") {
|
|
40
|
+
return {
|
|
41
|
+
type: "text",
|
|
42
|
+
text: sanitizeSurrogates(block.thinking),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (block.type === "toolCall") {
|
|
46
|
+
let input;
|
|
47
|
+
if (typeof block.arguments === "string") {
|
|
48
|
+
try {
|
|
49
|
+
input = JSON.parse(block.arguments);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
input = {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
input = block.arguments;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
type: "tool_use",
|
|
60
|
+
id: block.id,
|
|
61
|
+
name: block.name,
|
|
62
|
+
input,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { type: "text", text: "" };
|
|
66
|
+
});
|
|
67
|
+
return { role: "assistant", content };
|
|
68
|
+
}
|
|
69
|
+
if (message.role === "toolResult") {
|
|
70
|
+
const content = message.content.map((block) => {
|
|
71
|
+
if (block.type === "text") {
|
|
72
|
+
return {
|
|
73
|
+
type: "tool_result",
|
|
74
|
+
tool_use_id: message.toolCallId,
|
|
75
|
+
content: sanitizeSurrogates(block.text),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (block.type === "image") {
|
|
79
|
+
return {
|
|
80
|
+
type: "tool_result",
|
|
81
|
+
tool_use_id: message.toolCallId,
|
|
82
|
+
content: [{
|
|
83
|
+
type: "image",
|
|
84
|
+
source: {
|
|
85
|
+
type: "base64",
|
|
86
|
+
media_type: block.mimeType,
|
|
87
|
+
data: block.data,
|
|
88
|
+
},
|
|
89
|
+
}],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return { type: "tool_result", tool_use_id: message.toolCallId, content: "" };
|
|
93
|
+
});
|
|
94
|
+
return { role: "user", content };
|
|
95
|
+
}
|
|
96
|
+
return { role: "user", content: "" };
|
|
97
|
+
}
|
|
98
|
+
function toAnthropicTool(tool) {
|
|
99
|
+
const jsonSchema = tool.parameters;
|
|
100
|
+
return {
|
|
101
|
+
name: tool.name,
|
|
102
|
+
description: tool.description,
|
|
103
|
+
input_schema: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: jsonSchema.properties ?? {},
|
|
106
|
+
required: jsonSchema.required ?? [],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function mapStopReason(reason) {
|
|
111
|
+
switch (reason) {
|
|
112
|
+
case "end_turn":
|
|
113
|
+
return "stop";
|
|
114
|
+
case "max_tokens":
|
|
115
|
+
return "length";
|
|
116
|
+
case "tool_use":
|
|
117
|
+
return "toolUse";
|
|
118
|
+
case "refusal":
|
|
119
|
+
case "sensitive":
|
|
120
|
+
return "error";
|
|
121
|
+
default:
|
|
122
|
+
return "stop";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export function createAnthropicProvider() {
|
|
126
|
+
return {
|
|
127
|
+
name: "anthropic",
|
|
128
|
+
listModels: () => import("../models.js").then((m) => m.getProviderModels("anthropic")),
|
|
129
|
+
stream(model, context, options) {
|
|
130
|
+
const stream = new AssistantMessageEventStream();
|
|
131
|
+
const run = async () => {
|
|
132
|
+
const apiKey = options?.apiKey ?? getEnvApiKey(model.provider);
|
|
133
|
+
if (!apiKey) {
|
|
134
|
+
const errorMsg = {
|
|
135
|
+
role: "assistant",
|
|
136
|
+
content: [],
|
|
137
|
+
provider: model.provider,
|
|
138
|
+
model: model.id,
|
|
139
|
+
responseId: undefined,
|
|
140
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 },
|
|
141
|
+
stopReason: "error",
|
|
142
|
+
errorMessage: "ANTHROPIC_API_KEY not set",
|
|
143
|
+
timestamp: Date.now(),
|
|
144
|
+
};
|
|
145
|
+
stream.push({ type: "start", partial: errorMsg });
|
|
146
|
+
stream.push({ type: "error", reason: "error", error: errorMsg });
|
|
147
|
+
stream.end();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const client = new Anthropic({ apiKey });
|
|
151
|
+
const output = {
|
|
152
|
+
role: "assistant",
|
|
153
|
+
content: [],
|
|
154
|
+
provider: model.provider,
|
|
155
|
+
model: model.id,
|
|
156
|
+
responseId: undefined,
|
|
157
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 },
|
|
158
|
+
stopReason: "stop",
|
|
159
|
+
timestamp: Date.now(),
|
|
160
|
+
};
|
|
161
|
+
try {
|
|
162
|
+
const messages = context.messages.map(toAnthropicMessage);
|
|
163
|
+
const tools = context.tools?.map(toAnthropicTool) ?? [];
|
|
164
|
+
const params = {
|
|
165
|
+
model: model.id,
|
|
166
|
+
max_tokens: options?.maxTokens ?? 4096,
|
|
167
|
+
messages,
|
|
168
|
+
tools: tools.length > 0 ? tools : undefined,
|
|
169
|
+
system: context.systemPrompt,
|
|
170
|
+
temperature: options?.temperature,
|
|
171
|
+
stream: true,
|
|
172
|
+
};
|
|
173
|
+
const anthropicStream = client.messages.stream(params, { signal: options?.signal });
|
|
174
|
+
stream.push({ type: "start", partial: output });
|
|
175
|
+
const blocks = output.content;
|
|
176
|
+
for await (const event of anthropicStream) {
|
|
177
|
+
if (event.type === "message_start") {
|
|
178
|
+
output.responseId = event.message.id;
|
|
179
|
+
output.usage.input = event.message.usage.input_tokens || 0;
|
|
180
|
+
output.usage.output = event.message.usage.output_tokens || 0;
|
|
181
|
+
output.usage.cacheRead = event.message.usage.cache_read_input_tokens || 0;
|
|
182
|
+
output.usage.cacheWrite = event.message.usage.cache_creation_input_tokens || 0;
|
|
183
|
+
output.usage.totalTokens = output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
184
|
+
}
|
|
185
|
+
else if (event.type === "content_block_start") {
|
|
186
|
+
if (event.content_block.type === "text") {
|
|
187
|
+
const block = { type: "text", text: "", index: event.index };
|
|
188
|
+
output.content.push(block);
|
|
189
|
+
stream.push({ type: "text_start", contentIndex: output.content.length - 1, partial: output });
|
|
190
|
+
}
|
|
191
|
+
else if (event.content_block.type === "tool_use") {
|
|
192
|
+
const block = { type: "toolCall", id: event.content_block.id, name: event.content_block.name, arguments: event.content_block.input ?? {}, partialJson: "", index: event.index };
|
|
193
|
+
output.content.push(block);
|
|
194
|
+
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (event.type === "content_block_delta") {
|
|
198
|
+
if (event.delta.type === "text_delta") {
|
|
199
|
+
const idx = blocks.findIndex((b) => b.index === event.index);
|
|
200
|
+
const block = blocks[idx];
|
|
201
|
+
if (block && block.type === "text") {
|
|
202
|
+
block.text += event.delta.text;
|
|
203
|
+
stream.push({ type: "text_delta", contentIndex: idx, delta: event.delta.text, partial: output });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (event.delta.type === "input_json_delta") {
|
|
207
|
+
const idx = blocks.findIndex((b) => b.index === event.index);
|
|
208
|
+
const block = blocks[idx];
|
|
209
|
+
if (block && block.type === "toolCall") {
|
|
210
|
+
block.partialJson = (block.partialJson ?? "") + event.delta.partial_json;
|
|
211
|
+
try {
|
|
212
|
+
block.arguments = JSON.parse(block.partialJson);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// incomplete JSON, keep partial
|
|
216
|
+
}
|
|
217
|
+
stream.push({ type: "toolcall_delta", contentIndex: idx, delta: event.delta.partial_json, partial: output });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else if (event.type === "content_block_stop") {
|
|
222
|
+
const idx = blocks.findIndex((b) => b.index === event.index);
|
|
223
|
+
const block = blocks[idx];
|
|
224
|
+
if (block) {
|
|
225
|
+
delete block.index;
|
|
226
|
+
if (block.type === "text") {
|
|
227
|
+
stream.push({ type: "text_end", contentIndex: idx, content: block.text, partial: output });
|
|
228
|
+
}
|
|
229
|
+
else if (block.type === "toolCall") {
|
|
230
|
+
try {
|
|
231
|
+
block.arguments = JSON.parse(block.partialJson ?? "");
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
block.arguments = {};
|
|
235
|
+
}
|
|
236
|
+
delete block.partialJson;
|
|
237
|
+
stream.push({ type: "toolcall_end", contentIndex: idx, toolCall: block, partial: output });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (event.type === "message_delta") {
|
|
242
|
+
if (event.delta.stop_reason) {
|
|
243
|
+
output.stopReason = mapStopReason(event.delta.stop_reason);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (options?.signal?.aborted) {
|
|
248
|
+
throw new Error("Request aborted");
|
|
249
|
+
}
|
|
250
|
+
cleanupBlocks(blocks);
|
|
251
|
+
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
252
|
+
stream.end();
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
cleanupOutputContent(output);
|
|
256
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
257
|
+
output.errorMessage = error instanceof Error ? error.message : String(error);
|
|
258
|
+
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
259
|
+
stream.end();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
run();
|
|
263
|
+
return stream;
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function cleanupBlocks(blocks) {
|
|
268
|
+
for (const block of blocks) {
|
|
269
|
+
delete block.index;
|
|
270
|
+
delete block.partialJson;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function cleanupOutputContent(output) {
|
|
274
|
+
for (const block of output.content) {
|
|
275
|
+
delete block.index;
|
|
276
|
+
delete block.partialJson;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAoB1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAKjE,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,IAAI,GAAuC;QAC/C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa;KACtE,CAAC;IACF,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACvF,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;YACjD,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;YACrC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oB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AAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAC7E,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;oBACzE,MAAM,CAAC,GAAG,EAAE,CAAC;gBACf,CAAC;YACH,CAAC,CAAC;YAEF,GAAG,EAAE,CAAC;YAEN,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAqB;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,KAAK,CAAC;QACnB,OAAO,KAAK,CAAC,WAAW,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAwB;IACpD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnC,OAAQ,KAAqB,CAAC,KAAK,CAAC;QACpC,OAAQ,KAAqB,CAAC,WAAW,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context, Model, StreamOptions } from "../types.js";
|
|
2
|
+
import { AssistantMessageEventStream } from "../event-stream.js";
|
|
3
|
+
export interface GroqOptions extends StreamOptions {
|
|
4
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
5
|
+
type: "function";
|
|
6
|
+
function: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function createGroqProvider(): {
|
|
12
|
+
name: string;
|
|
13
|
+
listModels: () => Promise<import("../models.js").ModelEntry[]>;
|
|
14
|
+
stream(model: Model, context: Context, options?: GroqOptions): AssistantMessageEventStream;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=groq.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groq.d.ts","sourceRoot":"","sources":["../../src/providers/groq.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EACP,KAAK,EACL,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AASjE,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC9F;AAED,wBAAgB,kBAAkB;;;kBAIhB,KAAK,WAAW,OAAO,YAAY,WAAW,GAAG,2BAA2B;EAgJ7F"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import { AssistantMessageEventStream } from "../event-stream.js";
|
|
3
|
+
import { sanitizeSurrogates, parseStreamingJson } from "./shared.js";
|
|
4
|
+
const GROQ_BASE_URL = "https://api.groq.com/openai/v1";
|
|
5
|
+
function getEnvApiKey() {
|
|
6
|
+
return process.env.GROQ_API_KEY;
|
|
7
|
+
}
|
|
8
|
+
export function createGroqProvider() {
|
|
9
|
+
return {
|
|
10
|
+
name: "groq",
|
|
11
|
+
listModels: () => import("../models.js").then((m) => m.getProviderModels("groq")),
|
|
12
|
+
stream(model, context, options) {
|
|
13
|
+
const stream = new AssistantMessageEventStream();
|
|
14
|
+
const run = async () => {
|
|
15
|
+
const output = {
|
|
16
|
+
role: "assistant",
|
|
17
|
+
content: [],
|
|
18
|
+
provider: model.provider,
|
|
19
|
+
model: model.id,
|
|
20
|
+
responseId: undefined,
|
|
21
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 },
|
|
22
|
+
stopReason: "stop",
|
|
23
|
+
timestamp: Date.now(),
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
const apiKey = options?.apiKey ?? getEnvApiKey();
|
|
27
|
+
if (!apiKey) {
|
|
28
|
+
output.stopReason = "error";
|
|
29
|
+
output.errorMessage = `No API key for Groq. Set GROQ_API_KEY environment variable or pass apiKey in options.`;
|
|
30
|
+
stream.push({ type: "start", partial: output });
|
|
31
|
+
stream.push({ type: "error", reason: "error", error: output });
|
|
32
|
+
stream.end();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const client = new OpenAI({
|
|
36
|
+
apiKey,
|
|
37
|
+
baseURL: GROQ_BASE_URL,
|
|
38
|
+
dangerouslyAllowBrowser: true,
|
|
39
|
+
});
|
|
40
|
+
const messages = convertMessages(context);
|
|
41
|
+
const params = {
|
|
42
|
+
model: model.id,
|
|
43
|
+
messages,
|
|
44
|
+
stream: true,
|
|
45
|
+
stream_options: { include_usage: true },
|
|
46
|
+
};
|
|
47
|
+
if (options?.maxTokens) {
|
|
48
|
+
params.max_tokens = options.maxTokens;
|
|
49
|
+
}
|
|
50
|
+
if (options?.temperature !== undefined) {
|
|
51
|
+
params.temperature = options.temperature;
|
|
52
|
+
}
|
|
53
|
+
const tools = context.tools?.map((tool) => ({
|
|
54
|
+
type: "function",
|
|
55
|
+
function: {
|
|
56
|
+
name: tool.name,
|
|
57
|
+
description: tool.description,
|
|
58
|
+
parameters: tool.parameters,
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
if (tools && tools.length > 0) {
|
|
62
|
+
params.tools = tools;
|
|
63
|
+
}
|
|
64
|
+
if (options?.toolChoice) {
|
|
65
|
+
params.tool_choice = options.toolChoice;
|
|
66
|
+
}
|
|
67
|
+
const response = await client.chat.completions.create(params);
|
|
68
|
+
const toolCallFragments = {};
|
|
69
|
+
for await (const chunk of response) {
|
|
70
|
+
if (options?.signal?.aborted)
|
|
71
|
+
break;
|
|
72
|
+
const delta = chunk.choices[0]?.delta;
|
|
73
|
+
const finishReason = chunk.choices[0]?.finish_reason;
|
|
74
|
+
if (chunk.usage) {
|
|
75
|
+
output.usage = {
|
|
76
|
+
input: chunk.usage.prompt_tokens ?? 0,
|
|
77
|
+
output: chunk.usage.completion_tokens ?? 0,
|
|
78
|
+
cacheRead: 0,
|
|
79
|
+
cacheWrite: 0,
|
|
80
|
+
totalTokens: chunk.usage.total_tokens ?? 0,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Handle tool calls
|
|
84
|
+
if (delta?.tool_calls && delta.tool_calls.length > 0) {
|
|
85
|
+
for (const tc of delta.tool_calls) {
|
|
86
|
+
const index = tc.index ?? 0;
|
|
87
|
+
if (!toolCallFragments[index]) {
|
|
88
|
+
toolCallFragments[index] = { id: tc.id ?? "", name: tc.function?.name ?? "", args: "" };
|
|
89
|
+
}
|
|
90
|
+
if (tc.function?.arguments) {
|
|
91
|
+
toolCallFragments[index].args += tc.function.arguments;
|
|
92
|
+
}
|
|
93
|
+
if (tc.id)
|
|
94
|
+
toolCallFragments[index].id = tc.id;
|
|
95
|
+
if (tc.function?.name)
|
|
96
|
+
toolCallFragments[index].name = tc.function.name;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Handle content
|
|
100
|
+
if (delta?.content) {
|
|
101
|
+
const text = sanitizeSurrogates(delta.content);
|
|
102
|
+
stream.push({
|
|
103
|
+
type: "text_delta",
|
|
104
|
+
contentIndex: 0,
|
|
105
|
+
delta: text,
|
|
106
|
+
partial: output,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Handle stop reason
|
|
110
|
+
if (finishReason) {
|
|
111
|
+
output.stopReason = finishReason === "tool_calls" ? "toolUse" : "stop";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Assemble tool calls
|
|
115
|
+
const assembledToolCalls = Object.values(toolCallFragments).map((tc) => ({
|
|
116
|
+
type: "toolCall",
|
|
117
|
+
id: tc.id,
|
|
118
|
+
name: tc.name,
|
|
119
|
+
arguments: parseStreamingJson(tc.args),
|
|
120
|
+
}));
|
|
121
|
+
if (assembledToolCalls.length > 0) {
|
|
122
|
+
output.content = assembledToolCalls;
|
|
123
|
+
output.stopReason = "toolUse";
|
|
124
|
+
}
|
|
125
|
+
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
126
|
+
stream.end();
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
130
|
+
output.errorMessage = err instanceof Error ? err.message : String(err);
|
|
131
|
+
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
132
|
+
stream.end();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
run();
|
|
136
|
+
return stream;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function convertMessages(context) {
|
|
141
|
+
const messages = [];
|
|
142
|
+
if (context.systemPrompt) {
|
|
143
|
+
messages.push({ role: "system", content: context.systemPrompt });
|
|
144
|
+
}
|
|
145
|
+
for (const msg of context.messages) {
|
|
146
|
+
switch (msg.role) {
|
|
147
|
+
case "user":
|
|
148
|
+
messages.push({
|
|
149
|
+
role: "user",
|
|
150
|
+
content: typeof msg.content === "string" ? msg.content : msg.content.map((c) => {
|
|
151
|
+
if (c.type === "text")
|
|
152
|
+
return c.text;
|
|
153
|
+
return "";
|
|
154
|
+
}).join(""),
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
case "assistant":
|
|
158
|
+
if (msg.content.some((c) => c.type === "toolCall")) {
|
|
159
|
+
messages.push({
|
|
160
|
+
role: "assistant",
|
|
161
|
+
content: null,
|
|
162
|
+
tool_calls: msg.content
|
|
163
|
+
.filter((c) => c.type === "toolCall")
|
|
164
|
+
.map((tc) => ({
|
|
165
|
+
id: tc.id,
|
|
166
|
+
type: "function",
|
|
167
|
+
function: {
|
|
168
|
+
name: tc.name,
|
|
169
|
+
arguments: JSON.stringify(tc.arguments),
|
|
170
|
+
},
|
|
171
|
+
})),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
messages.push({
|
|
176
|
+
role: "assistant",
|
|
177
|
+
content: msg.content.map((c) => {
|
|
178
|
+
if (c.type === "text")
|
|
179
|
+
return c.text;
|
|
180
|
+
return "";
|
|
181
|
+
}).join(""),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
case "toolResult":
|
|
186
|
+
messages.push({
|
|
187
|
+
role: "tool",
|
|
188
|
+
tool_call_id: msg.toolCallId,
|
|
189
|
+
content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content),
|
|
190
|
+
});
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return messages;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=groq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groq.js","sourceRoot":"","sources":["../../src/providers/groq.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAO5B,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAErE,MAAM,aAAa,GAAG,gCAAgC,CAAC;AAEvD,SAAS,YAAY;IACnB,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAClC,CAAC;AAMD,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACjF,MAAM,CAAC,KAAY,EAAE,OAAgB,EAAE,OAAqB;YAC1D,MAAM,MAAM,GAAG,IAAI,2BAA2B,EAAE,CAAC;YAEjD,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE;gBACrB,MAAM,MAAM,GAAqB;oBAC/B,IAAI,EAAE,WA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V,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Context, Model, StreamOptions } from "../types.js";
|
|
2
|
+
import { AssistantMessageEventStream } from "../event-stream.js";
|
|
3
|
+
export interface OpenAICompletionsOptions extends StreamOptions {
|
|
4
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
5
|
+
type: "function";
|
|
6
|
+
function: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
11
|
+
}
|
|
12
|
+
export declare function createOpenAICompletionsProvider(): {
|
|
13
|
+
name: string;
|
|
14
|
+
listModels: () => Promise<import("../models.js").ModelEntry[]>;
|
|
15
|
+
stream(model: Model, context: Context, options?: OpenAICompletionsOptions): AssistantMessageEventStream;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=openai-completions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-completions.d.ts","sourceRoot":"","sources":["../../src/providers/openai-completions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,OAAO,EACP,KAAK,EACL,aAAa,EAId,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAgBjE,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC7F,eAAe,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CACnE;AAED,wBAAgB,+BAA+B;;;kBAI7B,KAAK,WAAW,OAAO,YAAY,wBAAwB,GAAG,2BAA2B;EAgN1G"}
|