@yeshwanthyk/ai 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/README.md +1142 -0
- package/dist/agent/agent-loop.d.ts +16 -0
- package/dist/agent/agent-loop.d.ts.map +1 -0
- package/dist/agent/agent-loop.js +307 -0
- package/dist/agent/agent-loop.js.map +1 -0
- package/dist/agent/index.d.ts +4 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +3 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/tools/calculate.d.ts +15 -0
- package/dist/agent/tools/calculate.d.ts.map +1 -0
- package/dist/agent/tools/calculate.js +23 -0
- package/dist/agent/tools/calculate.js.map +1 -0
- package/dist/agent/tools/get-current-time.d.ts +15 -0
- package/dist/agent/tools/get-current-time.d.ts.map +1 -0
- package/dist/agent/tools/get-current-time.js +38 -0
- package/dist/agent/tools/get-current-time.js.map +1 -0
- package/dist/agent/tools/index.d.ts +3 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +3 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/types.d.ts +69 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +2 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +11 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.generated.d.ts +7406 -0
- package/dist/models.generated.d.ts.map +1 -0
- package/dist/models.generated.js +7268 -0
- package/dist/models.generated.js.map +1 -0
- package/dist/models.js +35 -0
- package/dist/models.js.map +1 -0
- package/dist/providers/anthropic.d.ts +12 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +538 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/google.d.ts +12 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +427 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai-completions.d.ts +12 -0
- package/dist/providers/openai-completions.d.ts.map +1 -0
- package/dist/providers/openai-completions.js +540 -0
- package/dist/providers/openai-completions.js.map +1 -0
- package/dist/providers/openai-responses.d.ts +14 -0
- package/dist/providers/openai-responses.d.ts.map +1 -0
- package/dist/providers/openai-responses.js +553 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/providers/transform-messages.d.ts +3 -0
- package/dist/providers/transform-messages.d.ts.map +1 -0
- package/dist/providers/transform-messages.js +111 -0
- package/dist/providers/transform-messages.js.map +1 -0
- package/dist/stream.d.ts +11 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +204 -0
- package/dist/stream.js.map +1 -0
- package/dist/types.d.ts +203 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/event-stream.d.ts +19 -0
- package/dist/utils/event-stream.d.ts.map +1 -0
- package/dist/utils/event-stream.js +77 -0
- package/dist/utils/event-stream.js.map +1 -0
- package/dist/utils/json-parse.d.ts +9 -0
- package/dist/utils/json-parse.d.ts.map +1 -0
- package/dist/utils/json-parse.js +29 -0
- package/dist/utils/json-parse.js.map +1 -0
- package/dist/utils/oauth/anthropic.d.ts +20 -0
- package/dist/utils/oauth/anthropic.d.ts.map +1 -0
- package/dist/utils/oauth/anthropic.js +103 -0
- package/dist/utils/oauth/anthropic.js.map +1 -0
- package/dist/utils/overflow.d.ts +51 -0
- package/dist/utils/overflow.d.ts.map +1 -0
- package/dist/utils/overflow.js +106 -0
- package/dist/utils/overflow.js.map +1 -0
- package/dist/utils/sanitize-unicode.d.ts +22 -0
- package/dist/utils/sanitize-unicode.d.ts.map +1 -0
- package/dist/utils/sanitize-unicode.js +26 -0
- package/dist/utils/sanitize-unicode.js.map +1 -0
- package/dist/utils/typebox-helpers.d.ts +17 -0
- package/dist/utils/typebox-helpers.d.ts.map +1 -0
- package/dist/utils/typebox-helpers.js +21 -0
- package/dist/utils/typebox-helpers.js.map +1 -0
- package/dist/utils/validation.d.ts +18 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +69 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import { calculateCost } from "../models.js";
|
|
3
|
+
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
4
|
+
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
5
|
+
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
6
|
+
import { transformMessages } from "./transform-messages.js";
|
|
7
|
+
/**
|
|
8
|
+
* Normalize tool call ID for Mistral.
|
|
9
|
+
* Mistral requires tool IDs to be exactly 9 alphanumeric characters (a-z, A-Z, 0-9).
|
|
10
|
+
*/
|
|
11
|
+
function normalizeMistralToolId(id, isMistral) {
|
|
12
|
+
if (!isMistral)
|
|
13
|
+
return id;
|
|
14
|
+
// Remove non-alphanumeric characters
|
|
15
|
+
let normalized = id.replace(/[^a-zA-Z0-9]/g, "");
|
|
16
|
+
// Mistral requires exactly 9 characters
|
|
17
|
+
if (normalized.length < 9) {
|
|
18
|
+
// Pad with deterministic characters based on original ID to ensure matching
|
|
19
|
+
const padding = "ABCDEFGHI";
|
|
20
|
+
normalized = normalized + padding.slice(0, 9 - normalized.length);
|
|
21
|
+
}
|
|
22
|
+
else if (normalized.length > 9) {
|
|
23
|
+
normalized = normalized.slice(0, 9);
|
|
24
|
+
}
|
|
25
|
+
return normalized;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if conversation messages contain tool calls or tool results.
|
|
29
|
+
* This is needed because Anthropic (via proxy) requires the tools param
|
|
30
|
+
* to be present when messages include tool_calls or tool role messages.
|
|
31
|
+
*/
|
|
32
|
+
function hasToolHistory(messages) {
|
|
33
|
+
for (const msg of messages) {
|
|
34
|
+
if (msg.role === "toolResult") {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (msg.role === "assistant") {
|
|
38
|
+
if (msg.content.some((block) => block.type === "toolCall")) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
export const streamOpenAICompletions = (model, context, options) => {
|
|
46
|
+
const stream = new AssistantMessageEventStream();
|
|
47
|
+
(async () => {
|
|
48
|
+
const output = {
|
|
49
|
+
role: "assistant",
|
|
50
|
+
content: [],
|
|
51
|
+
api: model.api,
|
|
52
|
+
provider: model.provider,
|
|
53
|
+
model: model.id,
|
|
54
|
+
usage: {
|
|
55
|
+
input: 0,
|
|
56
|
+
output: 0,
|
|
57
|
+
cacheRead: 0,
|
|
58
|
+
cacheWrite: 0,
|
|
59
|
+
totalTokens: 0,
|
|
60
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
61
|
+
},
|
|
62
|
+
stopReason: "stop",
|
|
63
|
+
timestamp: Date.now(),
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
const client = createClient(model, context, options?.apiKey);
|
|
67
|
+
const params = buildParams(model, context, options);
|
|
68
|
+
const openaiStream = await client.chat.completions.create(params, { signal: options?.signal });
|
|
69
|
+
stream.push({ type: "start", partial: output });
|
|
70
|
+
let currentBlock = null;
|
|
71
|
+
const blocks = output.content;
|
|
72
|
+
const blockIndex = () => blocks.length - 1;
|
|
73
|
+
const finishCurrentBlock = (block) => {
|
|
74
|
+
if (block) {
|
|
75
|
+
if (block.type === "text") {
|
|
76
|
+
stream.push({
|
|
77
|
+
type: "text_end",
|
|
78
|
+
contentIndex: blockIndex(),
|
|
79
|
+
content: block.text,
|
|
80
|
+
partial: output,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (block.type === "thinking") {
|
|
84
|
+
stream.push({
|
|
85
|
+
type: "thinking_end",
|
|
86
|
+
contentIndex: blockIndex(),
|
|
87
|
+
content: block.thinking,
|
|
88
|
+
partial: output,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else if (block.type === "toolCall") {
|
|
92
|
+
block.arguments = JSON.parse(block.partialArgs || "{}");
|
|
93
|
+
delete block.partialArgs;
|
|
94
|
+
stream.push({
|
|
95
|
+
type: "toolcall_end",
|
|
96
|
+
contentIndex: blockIndex(),
|
|
97
|
+
toolCall: block,
|
|
98
|
+
partial: output,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
for await (const chunk of openaiStream) {
|
|
104
|
+
if (chunk.usage) {
|
|
105
|
+
const cachedTokens = chunk.usage.prompt_tokens_details?.cached_tokens || 0;
|
|
106
|
+
const reasoningTokens = chunk.usage.completion_tokens_details?.reasoning_tokens || 0;
|
|
107
|
+
const input = (chunk.usage.prompt_tokens || 0) - cachedTokens;
|
|
108
|
+
const outputTokens = (chunk.usage.completion_tokens || 0) + reasoningTokens;
|
|
109
|
+
output.usage = {
|
|
110
|
+
// OpenAI includes cached tokens in prompt_tokens, so subtract to get non-cached input
|
|
111
|
+
input,
|
|
112
|
+
output: outputTokens,
|
|
113
|
+
cacheRead: cachedTokens,
|
|
114
|
+
cacheWrite: 0,
|
|
115
|
+
// Compute totalTokens ourselves since we add reasoning_tokens to output
|
|
116
|
+
// and some providers (e.g., Groq) don't include them in total_tokens
|
|
117
|
+
totalTokens: input + outputTokens + cachedTokens,
|
|
118
|
+
cost: {
|
|
119
|
+
input: 0,
|
|
120
|
+
output: 0,
|
|
121
|
+
cacheRead: 0,
|
|
122
|
+
cacheWrite: 0,
|
|
123
|
+
total: 0,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
calculateCost(model, output.usage);
|
|
127
|
+
}
|
|
128
|
+
const choice = chunk.choices[0];
|
|
129
|
+
if (!choice)
|
|
130
|
+
continue;
|
|
131
|
+
if (choice.finish_reason) {
|
|
132
|
+
output.stopReason = mapStopReason(choice.finish_reason);
|
|
133
|
+
}
|
|
134
|
+
if (choice.delta) {
|
|
135
|
+
if (choice.delta.content !== null &&
|
|
136
|
+
choice.delta.content !== undefined &&
|
|
137
|
+
choice.delta.content.length > 0) {
|
|
138
|
+
if (!currentBlock || currentBlock.type !== "text") {
|
|
139
|
+
finishCurrentBlock(currentBlock);
|
|
140
|
+
currentBlock = { type: "text", text: "" };
|
|
141
|
+
output.content.push(currentBlock);
|
|
142
|
+
stream.push({ type: "text_start", contentIndex: blockIndex(), partial: output });
|
|
143
|
+
}
|
|
144
|
+
if (currentBlock.type === "text") {
|
|
145
|
+
currentBlock.text += choice.delta.content;
|
|
146
|
+
stream.push({
|
|
147
|
+
type: "text_delta",
|
|
148
|
+
contentIndex: blockIndex(),
|
|
149
|
+
delta: choice.delta.content,
|
|
150
|
+
partial: output,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Some endpoints return reasoning in reasoning_content (llama.cpp),
|
|
155
|
+
// or reasoning (other openai compatible endpoints)
|
|
156
|
+
const reasoningFields = ["reasoning_content", "reasoning"];
|
|
157
|
+
for (const field of reasoningFields) {
|
|
158
|
+
if (choice.delta[field] !== null &&
|
|
159
|
+
choice.delta[field] !== undefined &&
|
|
160
|
+
choice.delta[field].length > 0) {
|
|
161
|
+
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
162
|
+
finishCurrentBlock(currentBlock);
|
|
163
|
+
currentBlock = {
|
|
164
|
+
type: "thinking",
|
|
165
|
+
thinking: "",
|
|
166
|
+
thinkingSignature: field,
|
|
167
|
+
};
|
|
168
|
+
output.content.push(currentBlock);
|
|
169
|
+
stream.push({ type: "thinking_start", contentIndex: blockIndex(), partial: output });
|
|
170
|
+
}
|
|
171
|
+
if (currentBlock.type === "thinking") {
|
|
172
|
+
const delta = choice.delta[field];
|
|
173
|
+
currentBlock.thinking += delta;
|
|
174
|
+
stream.push({
|
|
175
|
+
type: "thinking_delta",
|
|
176
|
+
contentIndex: blockIndex(),
|
|
177
|
+
delta,
|
|
178
|
+
partial: output,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (choice?.delta?.tool_calls) {
|
|
184
|
+
for (const toolCall of choice.delta.tool_calls) {
|
|
185
|
+
if (!currentBlock ||
|
|
186
|
+
currentBlock.type !== "toolCall" ||
|
|
187
|
+
(toolCall.id && currentBlock.id !== toolCall.id)) {
|
|
188
|
+
finishCurrentBlock(currentBlock);
|
|
189
|
+
currentBlock = {
|
|
190
|
+
type: "toolCall",
|
|
191
|
+
id: toolCall.id || "",
|
|
192
|
+
name: toolCall.function?.name || "",
|
|
193
|
+
arguments: {},
|
|
194
|
+
partialArgs: "",
|
|
195
|
+
};
|
|
196
|
+
output.content.push(currentBlock);
|
|
197
|
+
stream.push({ type: "toolcall_start", contentIndex: blockIndex(), partial: output });
|
|
198
|
+
}
|
|
199
|
+
if (currentBlock.type === "toolCall") {
|
|
200
|
+
if (toolCall.id)
|
|
201
|
+
currentBlock.id = toolCall.id;
|
|
202
|
+
if (toolCall.function?.name)
|
|
203
|
+
currentBlock.name = toolCall.function.name;
|
|
204
|
+
let delta = "";
|
|
205
|
+
if (toolCall.function?.arguments) {
|
|
206
|
+
delta = toolCall.function.arguments;
|
|
207
|
+
currentBlock.partialArgs += toolCall.function.arguments;
|
|
208
|
+
currentBlock.arguments = parseStreamingJson(currentBlock.partialArgs);
|
|
209
|
+
}
|
|
210
|
+
stream.push({
|
|
211
|
+
type: "toolcall_delta",
|
|
212
|
+
contentIndex: blockIndex(),
|
|
213
|
+
delta,
|
|
214
|
+
partial: output,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
finishCurrentBlock(currentBlock);
|
|
222
|
+
if (options?.signal?.aborted) {
|
|
223
|
+
throw new Error("Request was aborted");
|
|
224
|
+
}
|
|
225
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
226
|
+
throw new Error("An unknown error occurred");
|
|
227
|
+
}
|
|
228
|
+
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
229
|
+
stream.end();
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
for (const block of output.content)
|
|
233
|
+
delete block.index;
|
|
234
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
235
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
236
|
+
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
237
|
+
stream.end();
|
|
238
|
+
}
|
|
239
|
+
})();
|
|
240
|
+
return stream;
|
|
241
|
+
};
|
|
242
|
+
function createClient(model, context, apiKey) {
|
|
243
|
+
if (!apiKey) {
|
|
244
|
+
if (!process.env.OPENAI_API_KEY) {
|
|
245
|
+
throw new Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");
|
|
246
|
+
}
|
|
247
|
+
apiKey = process.env.OPENAI_API_KEY;
|
|
248
|
+
}
|
|
249
|
+
const headers = { ...model.headers };
|
|
250
|
+
if (model.provider === "github-copilot") {
|
|
251
|
+
// Copilot expects X-Initiator to indicate whether the request is user-initiated
|
|
252
|
+
// or agent-initiated. It's an agent call if ANY message in history has assistant/tool role.
|
|
253
|
+
const messages = context.messages || [];
|
|
254
|
+
const isAgentCall = messages.some((msg) => msg.role === "assistant" || msg.role === "toolResult");
|
|
255
|
+
headers["X-Initiator"] = isAgentCall ? "agent" : "user";
|
|
256
|
+
headers["Openai-Intent"] = "conversation-edits";
|
|
257
|
+
}
|
|
258
|
+
return new OpenAI({
|
|
259
|
+
apiKey,
|
|
260
|
+
baseURL: model.baseUrl,
|
|
261
|
+
dangerouslyAllowBrowser: true,
|
|
262
|
+
defaultHeaders: headers,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function buildParams(model, context, options) {
|
|
266
|
+
const compat = getCompat(model);
|
|
267
|
+
const messages = convertMessages(model, context, compat);
|
|
268
|
+
const params = {
|
|
269
|
+
model: model.id,
|
|
270
|
+
messages,
|
|
271
|
+
stream: true,
|
|
272
|
+
stream_options: { include_usage: true },
|
|
273
|
+
};
|
|
274
|
+
if (compat.supportsStore) {
|
|
275
|
+
params.store = false;
|
|
276
|
+
}
|
|
277
|
+
if (options?.maxTokens) {
|
|
278
|
+
if (compat.maxTokensField === "max_tokens") {
|
|
279
|
+
params.max_tokens = options.maxTokens;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
params.max_completion_tokens = options.maxTokens;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (options?.temperature !== undefined) {
|
|
286
|
+
params.temperature = options.temperature;
|
|
287
|
+
}
|
|
288
|
+
if (context.tools) {
|
|
289
|
+
params.tools = convertTools(context.tools);
|
|
290
|
+
}
|
|
291
|
+
else if (hasToolHistory(context.messages)) {
|
|
292
|
+
// Anthropic (via LiteLLM/proxy) requires tools param when conversation has tool_calls/tool_results
|
|
293
|
+
params.tools = [];
|
|
294
|
+
}
|
|
295
|
+
if (options?.toolChoice) {
|
|
296
|
+
params.tool_choice = options.toolChoice;
|
|
297
|
+
}
|
|
298
|
+
if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
|
|
299
|
+
params.reasoning_effort = options.reasoningEffort;
|
|
300
|
+
}
|
|
301
|
+
return params;
|
|
302
|
+
}
|
|
303
|
+
function convertMessages(model, context, compat) {
|
|
304
|
+
const params = [];
|
|
305
|
+
const transformedMessages = transformMessages(context.messages, model);
|
|
306
|
+
if (context.systemPrompt) {
|
|
307
|
+
const useDeveloperRole = model.reasoning && compat.supportsDeveloperRole;
|
|
308
|
+
const role = useDeveloperRole ? "developer" : "system";
|
|
309
|
+
params.push({ role: role, content: sanitizeSurrogates(context.systemPrompt) });
|
|
310
|
+
}
|
|
311
|
+
let lastRole = null;
|
|
312
|
+
for (const msg of transformedMessages) {
|
|
313
|
+
// Some providers (e.g. Mistral/Devstral) don't allow user messages directly after tool results
|
|
314
|
+
// Insert a synthetic assistant message to bridge the gap
|
|
315
|
+
if (compat.requiresAssistantAfterToolResult && lastRole === "toolResult" && msg.role === "user") {
|
|
316
|
+
params.push({
|
|
317
|
+
role: "assistant",
|
|
318
|
+
content: "I have processed the tool results.",
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (msg.role === "user") {
|
|
322
|
+
if (typeof msg.content === "string") {
|
|
323
|
+
params.push({
|
|
324
|
+
role: "user",
|
|
325
|
+
content: sanitizeSurrogates(msg.content),
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
const content = msg.content.map((item) => {
|
|
330
|
+
if (item.type === "text") {
|
|
331
|
+
return {
|
|
332
|
+
type: "text",
|
|
333
|
+
text: sanitizeSurrogates(item.text),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
return {
|
|
338
|
+
type: "image_url",
|
|
339
|
+
image_url: {
|
|
340
|
+
url: `data:${item.mimeType};base64,${item.data}`,
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
const filteredContent = !model.input.includes("image")
|
|
346
|
+
? content.filter((c) => c.type !== "image_url")
|
|
347
|
+
: content;
|
|
348
|
+
if (filteredContent.length === 0)
|
|
349
|
+
continue;
|
|
350
|
+
params.push({
|
|
351
|
+
role: "user",
|
|
352
|
+
content: filteredContent,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else if (msg.role === "assistant") {
|
|
357
|
+
// Some providers (e.g. Mistral) don't accept null content, use empty string instead
|
|
358
|
+
const assistantMsg = {
|
|
359
|
+
role: "assistant",
|
|
360
|
+
content: compat.requiresAssistantAfterToolResult ? "" : null,
|
|
361
|
+
};
|
|
362
|
+
const textBlocks = msg.content.filter((b) => b.type === "text");
|
|
363
|
+
if (textBlocks.length > 0) {
|
|
364
|
+
// GitHub Copilot requires assistant content as a string, not an array.
|
|
365
|
+
// Sending as array causes Claude models to re-answer all previous prompts.
|
|
366
|
+
if (model.provider === "github-copilot") {
|
|
367
|
+
assistantMsg.content = textBlocks.map((b) => sanitizeSurrogates(b.text)).join("");
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
assistantMsg.content = textBlocks.map((b) => {
|
|
371
|
+
return { type: "text", text: sanitizeSurrogates(b.text) };
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
// Handle thinking blocks
|
|
376
|
+
const thinkingBlocks = msg.content.filter((b) => b.type === "thinking");
|
|
377
|
+
if (thinkingBlocks.length > 0) {
|
|
378
|
+
if (compat.requiresThinkingAsText) {
|
|
379
|
+
// Convert thinking blocks to text with <thinking> delimiters
|
|
380
|
+
const thinkingText = thinkingBlocks.map((b) => `<thinking>\n${b.thinking}\n</thinking>`).join("\n");
|
|
381
|
+
const textContent = assistantMsg.content;
|
|
382
|
+
if (textContent) {
|
|
383
|
+
textContent.unshift({ type: "text", text: thinkingText });
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
assistantMsg.content = [{ type: "text", text: thinkingText }];
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
// Use the signature from the first thinking block if available (for llama.cpp server + gpt-oss)
|
|
391
|
+
const signature = thinkingBlocks[0].thinkingSignature;
|
|
392
|
+
if (signature && signature.length > 0) {
|
|
393
|
+
assistantMsg[signature] = thinkingBlocks.map((b) => b.thinking).join("\n");
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const toolCalls = msg.content.filter((b) => b.type === "toolCall");
|
|
398
|
+
if (toolCalls.length > 0) {
|
|
399
|
+
assistantMsg.tool_calls = toolCalls.map((tc) => ({
|
|
400
|
+
id: normalizeMistralToolId(tc.id, compat.requiresMistralToolIds),
|
|
401
|
+
type: "function",
|
|
402
|
+
function: {
|
|
403
|
+
name: tc.name,
|
|
404
|
+
arguments: JSON.stringify(tc.arguments),
|
|
405
|
+
},
|
|
406
|
+
}));
|
|
407
|
+
}
|
|
408
|
+
// Skip assistant messages that have no content and no tool calls.
|
|
409
|
+
// Mistral explicitly requires "either content or tool_calls, but not none".
|
|
410
|
+
// Other providers also don't accept empty assistant messages.
|
|
411
|
+
// This handles aborted assistant responses that got no content.
|
|
412
|
+
const content = assistantMsg.content;
|
|
413
|
+
const hasContent = content !== null &&
|
|
414
|
+
content !== undefined &&
|
|
415
|
+
(typeof content === "string" ? content.length > 0 : content.length > 0);
|
|
416
|
+
if (!hasContent && !assistantMsg.tool_calls) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
params.push(assistantMsg);
|
|
420
|
+
}
|
|
421
|
+
else if (msg.role === "toolResult") {
|
|
422
|
+
// Extract text and image content
|
|
423
|
+
const textResult = msg.content
|
|
424
|
+
.filter((c) => c.type === "text")
|
|
425
|
+
.map((c) => c.text)
|
|
426
|
+
.join("\n");
|
|
427
|
+
const hasImages = msg.content.some((c) => c.type === "image");
|
|
428
|
+
// Always send tool result with text (or placeholder if only images)
|
|
429
|
+
const hasText = textResult.length > 0;
|
|
430
|
+
// Some providers (e.g. Mistral) require the 'name' field in tool results
|
|
431
|
+
const toolResultMsg = {
|
|
432
|
+
role: "tool",
|
|
433
|
+
content: sanitizeSurrogates(hasText ? textResult : "(see attached image)"),
|
|
434
|
+
tool_call_id: normalizeMistralToolId(msg.toolCallId, compat.requiresMistralToolIds),
|
|
435
|
+
};
|
|
436
|
+
if (compat.requiresToolResultName && msg.toolName) {
|
|
437
|
+
toolResultMsg.name = msg.toolName;
|
|
438
|
+
}
|
|
439
|
+
params.push(toolResultMsg);
|
|
440
|
+
// If there are images and model supports them, send a follow-up user message with images
|
|
441
|
+
if (hasImages && model.input.includes("image")) {
|
|
442
|
+
const contentBlocks = [];
|
|
443
|
+
// Add text prefix
|
|
444
|
+
contentBlocks.push({
|
|
445
|
+
type: "text",
|
|
446
|
+
text: "Attached image(s) from tool result:",
|
|
447
|
+
});
|
|
448
|
+
// Add images
|
|
449
|
+
for (const block of msg.content) {
|
|
450
|
+
if (block.type === "image") {
|
|
451
|
+
contentBlocks.push({
|
|
452
|
+
type: "image_url",
|
|
453
|
+
image_url: {
|
|
454
|
+
url: `data:${block.mimeType};base64,${block.data}`,
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
params.push({
|
|
460
|
+
role: "user",
|
|
461
|
+
content: contentBlocks,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
lastRole = msg.role;
|
|
466
|
+
}
|
|
467
|
+
return params;
|
|
468
|
+
}
|
|
469
|
+
function convertTools(tools) {
|
|
470
|
+
return tools.map((tool) => ({
|
|
471
|
+
type: "function",
|
|
472
|
+
function: {
|
|
473
|
+
name: tool.name,
|
|
474
|
+
description: tool.description,
|
|
475
|
+
parameters: tool.parameters, // TypeBox already generates JSON Schema
|
|
476
|
+
},
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
function mapStopReason(reason) {
|
|
480
|
+
if (reason === null)
|
|
481
|
+
return "stop";
|
|
482
|
+
switch (reason) {
|
|
483
|
+
case "stop":
|
|
484
|
+
return "stop";
|
|
485
|
+
case "length":
|
|
486
|
+
return "length";
|
|
487
|
+
case "function_call":
|
|
488
|
+
case "tool_calls":
|
|
489
|
+
return "toolUse";
|
|
490
|
+
case "content_filter":
|
|
491
|
+
return "error";
|
|
492
|
+
default: {
|
|
493
|
+
const _exhaustive = reason;
|
|
494
|
+
throw new Error(`Unhandled stop reason: ${_exhaustive}`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Detect compatibility settings from baseUrl for known providers.
|
|
500
|
+
* Returns a fully resolved OpenAICompat object with all fields set.
|
|
501
|
+
*/
|
|
502
|
+
function detectCompatFromUrl(baseUrl) {
|
|
503
|
+
const isNonStandard = baseUrl.includes("cerebras.ai") ||
|
|
504
|
+
baseUrl.includes("api.x.ai") ||
|
|
505
|
+
baseUrl.includes("mistral.ai") ||
|
|
506
|
+
baseUrl.includes("chutes.ai");
|
|
507
|
+
const useMaxTokens = baseUrl.includes("mistral.ai") || baseUrl.includes("chutes.ai");
|
|
508
|
+
const isGrok = baseUrl.includes("api.x.ai");
|
|
509
|
+
const isMistral = baseUrl.includes("mistral.ai");
|
|
510
|
+
return {
|
|
511
|
+
supportsStore: !isNonStandard,
|
|
512
|
+
supportsDeveloperRole: !isNonStandard,
|
|
513
|
+
supportsReasoningEffort: !isGrok,
|
|
514
|
+
maxTokensField: useMaxTokens ? "max_tokens" : "max_completion_tokens",
|
|
515
|
+
requiresToolResultName: isMistral,
|
|
516
|
+
requiresAssistantAfterToolResult: false, // Mistral no longer requires this as of Dec 2024
|
|
517
|
+
requiresThinkingAsText: isMistral,
|
|
518
|
+
requiresMistralToolIds: isMistral,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Get resolved compatibility settings for a model.
|
|
523
|
+
* Uses explicit model.compat if provided, otherwise auto-detects from URL.
|
|
524
|
+
*/
|
|
525
|
+
function getCompat(model) {
|
|
526
|
+
const detected = detectCompatFromUrl(model.baseUrl);
|
|
527
|
+
if (!model.compat)
|
|
528
|
+
return detected;
|
|
529
|
+
return {
|
|
530
|
+
supportsStore: model.compat.supportsStore ?? detected.supportsStore,
|
|
531
|
+
supportsDeveloperRole: model.compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,
|
|
532
|
+
supportsReasoningEffort: model.compat.supportsReasoningEffort ?? detected.supportsReasoningEffort,
|
|
533
|
+
maxTokensField: model.compat.maxTokensField ?? detected.maxTokensField,
|
|
534
|
+
requiresToolResultName: model.compat.requiresToolResultName ?? detected.requiresToolResultName,
|
|
535
|
+
requiresAssistantAfterToolResult: model.compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,
|
|
536
|
+
requiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
|
|
537
|
+
requiresMistralToolIds: model.compat.requiresMistralToolIds ?? detected.requiresMistralToolIds,
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
//# sourceMappingURL=openai-completions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-completions.js","sourceRoot":"","sources":["../../src/providers/openai-completions.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAU5B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAe7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;GAGG;AACH,SAAS,sBAAsB,CAAC,EAAU,EAAE,SAAkB,EAAU;IACvE,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,qCAAqC;IACrC,IAAI,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACjD,wCAAwC;IACxC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,4EAA4E;QAC5E,MAAM,OAAO,GAAG,WAAW,CAAC;QAC5B,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;SAAM,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,UAAU,CAA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AAa;QACnE,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,qBAAqB,IAAI,QAAQ,CAAC,qBAAqB;QAC3F,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAAC,uBAAuB,IAAI,QAAQ,CAAC,uBAAuB;QACjG,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,IAAI,QAAQ,CAAC,cAAc;QACtE,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAAC,sBAAsB,IAAI,QAAQ,CAAC,sBAAsB;QAC9F,gCAAgC,EAC/B,KAAK,CAAC,MAAM,CAAC,gCAAgC,IAAI,QAAQ,CAAC,gCAAgC;QAC3F,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAAC,sBAAsB,IAAI,QAAQ,CAAC,sBAAsB;QAC9F,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAAC,sBAAsB,IAAI,QAAQ,CAAC,sBAAsB;KAC9F,CAAC;AAAA,CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FetchFunction, StreamFunction, StreamOptions } from "../types.js";
|
|
2
|
+
export interface OpenAIResponsesOptions extends StreamOptions {
|
|
3
|
+
reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
4
|
+
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
5
|
+
/** Custom fetch for OAuth/proxy scenarios */
|
|
6
|
+
fetch?: FetchFunction;
|
|
7
|
+
/** Instructions for Codex API (replaces system prompt in body) */
|
|
8
|
+
instructions?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generate function for OpenAI Responses API
|
|
12
|
+
*/
|
|
13
|
+
export declare const streamOpenAIResponses: StreamFunction<"openai-responses">;
|
|
14
|
+
//# sourceMappingURL=openai-responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-responses.d.ts","sourceRoot":"","sources":["../../src/providers/openai-responses.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAIX,aAAa,EAGb,cAAc,EACd,aAAa,EAKb,MAAM,aAAa,CAAC;AAQrB,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC5D,eAAe,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAClE,gBAAgB,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1D,6CAA6C;IAC7C,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,kBAAkB,CA0UpE,CAAC"}
|