@arcote.tech/arc-ai-openai 0.5.0 → 0.5.2
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/package.json +2 -2
- package/src/index.ts +24 -14
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-ai-openai",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "OpenAI adapter for Arc AI framework",
|
|
7
7
|
"main": "./src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@arcote.tech/arc-ai": "^0.5.
|
|
13
|
+
"@arcote.tech/arc-ai": "^0.5.2",
|
|
14
14
|
"typescript": "^5.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ export function openai(config: OpenAIConfig): LLMProvider {
|
|
|
31
31
|
name: t.name,
|
|
32
32
|
description: t.description,
|
|
33
33
|
parameters: t.parameters,
|
|
34
|
+
strict: false,
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -146,6 +147,9 @@ export function openai(config: OpenAIConfig): LLMProvider {
|
|
|
146
147
|
if (request.webSearch) {
|
|
147
148
|
body.tools = [...(tools ?? []), { type: "web_search_preview" }];
|
|
148
149
|
}
|
|
150
|
+
if (request.toolChoice) {
|
|
151
|
+
body.tool_choice = request.toolChoice;
|
|
152
|
+
}
|
|
149
153
|
|
|
150
154
|
const response = await fetch(`${baseUrl}/responses`, {
|
|
151
155
|
method: "POST",
|
|
@@ -202,6 +206,9 @@ export function openai(config: OpenAIConfig): LLMProvider {
|
|
|
202
206
|
if (request.webSearch) {
|
|
203
207
|
body.tools = [...(tools ?? []), { type: "web_search_preview" }];
|
|
204
208
|
}
|
|
209
|
+
if (request.toolChoice) {
|
|
210
|
+
body.tool_choice = request.toolChoice;
|
|
211
|
+
}
|
|
205
212
|
|
|
206
213
|
const response = await fetch(`${baseUrl}/responses`, {
|
|
207
214
|
method: "POST",
|
|
@@ -281,10 +288,10 @@ export function openai(config: OpenAIConfig): LLMProvider {
|
|
|
281
288
|
|
|
282
289
|
case "response.output_item.done":
|
|
283
290
|
if (event.item?.type === "function_call") {
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
"{}";
|
|
291
|
+
const buffered = toolCallArgBuffers.get(event.item.call_id);
|
|
292
|
+
const argsStr = (buffered && buffered.length > 0)
|
|
293
|
+
? buffered
|
|
294
|
+
: (event.item.arguments ?? "{}");
|
|
288
295
|
let args: Record<string, unknown> = {};
|
|
289
296
|
try {
|
|
290
297
|
args = JSON.parse(argsStr);
|
|
@@ -325,19 +332,22 @@ export function openai(config: OpenAIConfig): LLMProvider {
|
|
|
325
332
|
};
|
|
326
333
|
}
|
|
327
334
|
|
|
335
|
+
const pricing: Record<string, { inputPer1M: number; outputPer1M: number; cachedInputPer1M?: number; reasoningPer1M?: number }> = {
|
|
336
|
+
"gpt-4o": { inputPer1M: 2.50, outputPer1M: 10.00, cachedInputPer1M: 1.25 },
|
|
337
|
+
"gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.60, cachedInputPer1M: 0.075 },
|
|
338
|
+
"o3": { inputPer1M: 10.00, outputPer1M: 40.00, reasoningPer1M: 40.00 },
|
|
339
|
+
"o3-mini": { inputPer1M: 1.10, outputPer1M: 4.40, reasoningPer1M: 4.40 },
|
|
340
|
+
"gpt-4.1": { inputPer1M: 2.00, outputPer1M: 8.00, cachedInputPer1M: 0.50 },
|
|
341
|
+
"gpt-4.1-mini": { inputPer1M: 0.40, outputPer1M: 1.60, cachedInputPer1M: 0.10 },
|
|
342
|
+
"gpt-4.1-nano": { inputPer1M: 0.10, outputPer1M: 0.40, cachedInputPer1M: 0.025 },
|
|
343
|
+
"gpt-5.4-nano": { inputPer1M: 0.10, outputPer1M: 0.40, cachedInputPer1M: 0.025 },
|
|
344
|
+
};
|
|
345
|
+
|
|
328
346
|
return {
|
|
329
347
|
name: "openai",
|
|
330
|
-
models:
|
|
331
|
-
"gpt-4o",
|
|
332
|
-
"gpt-4o-mini",
|
|
333
|
-
"o3",
|
|
334
|
-
"o3-mini",
|
|
335
|
-
"gpt-4.1",
|
|
336
|
-
"gpt-4.1-mini",
|
|
337
|
-
"gpt-4.1-nano",
|
|
338
|
-
"gpt-5.4-nano",
|
|
339
|
-
],
|
|
348
|
+
models: Object.keys(pricing),
|
|
340
349
|
complete,
|
|
341
350
|
streamComplete,
|
|
351
|
+
getPricing: (model: string) => pricing[model],
|
|
342
352
|
};
|
|
343
353
|
}
|