@ai-sdk/openai 2.0.0-beta.1 → 2.0.0-beta.10
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/CHANGELOG.md +67 -0
- package/dist/index.d.mts +12 -27
- package/dist/index.d.ts +12 -27
- package/dist/index.js +592 -397
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +426 -229
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +35 -205
- package/dist/internal/index.d.ts +35 -205
- package/dist/internal/index.js +584 -389
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +421 -224
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/internal/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
parseProviderOptions,
|
|
12
12
|
postJsonToApi
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
14
|
-
import { z as z5 } from "zod";
|
|
14
|
+
import { z as z5 } from "zod/v4";
|
|
15
15
|
|
|
16
16
|
// src/convert-to-openai-chat-messages.ts
|
|
17
17
|
import {
|
|
@@ -224,7 +224,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// src/openai-chat-options.ts
|
|
227
|
-
import { z } from "zod";
|
|
227
|
+
import { z } from "zod/v4";
|
|
228
228
|
var openaiProviderOptions = z.object({
|
|
229
229
|
/**
|
|
230
230
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
@@ -267,11 +267,11 @@ var openaiProviderOptions = z.object({
|
|
|
267
267
|
/**
|
|
268
268
|
* Metadata to associate with the request.
|
|
269
269
|
*/
|
|
270
|
-
metadata: z.record(z.string()).optional(),
|
|
270
|
+
metadata: z.record(z.string().max(64), z.string().max(512)).optional(),
|
|
271
271
|
/**
|
|
272
272
|
* Parameters for prediction mode.
|
|
273
273
|
*/
|
|
274
|
-
prediction: z.record(z.any()).optional(),
|
|
274
|
+
prediction: z.record(z.string(), z.any()).optional(),
|
|
275
275
|
/**
|
|
276
276
|
* Whether to use structured outputs.
|
|
277
277
|
*
|
|
@@ -284,11 +284,17 @@ var openaiProviderOptions = z.object({
|
|
|
284
284
|
*
|
|
285
285
|
* @default 'auto'
|
|
286
286
|
*/
|
|
287
|
-
serviceTier: z.enum(["auto", "flex"]).optional()
|
|
287
|
+
serviceTier: z.enum(["auto", "flex"]).optional(),
|
|
288
|
+
/**
|
|
289
|
+
* Whether to use strict JSON schema validation.
|
|
290
|
+
*
|
|
291
|
+
* @default false
|
|
292
|
+
*/
|
|
293
|
+
strictJsonSchema: z.boolean().optional()
|
|
288
294
|
});
|
|
289
295
|
|
|
290
296
|
// src/openai-error.ts
|
|
291
|
-
import { z as z2 } from "zod";
|
|
297
|
+
import { z as z2 } from "zod/v4";
|
|
292
298
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
293
299
|
var openaiErrorDataSchema = z2.object({
|
|
294
300
|
error: z2.object({
|
|
@@ -313,7 +319,7 @@ import {
|
|
|
313
319
|
|
|
314
320
|
// src/tool/file-search.ts
|
|
315
321
|
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
316
|
-
import { z as z3 } from "zod";
|
|
322
|
+
import { z as z3 } from "zod/v4";
|
|
317
323
|
var fileSearchArgsSchema = z3.object({
|
|
318
324
|
/**
|
|
319
325
|
* List of vector store IDs to search through. If not provided, searches all available vector stores.
|
|
@@ -338,7 +344,7 @@ var fileSearch = createProviderDefinedToolFactory({
|
|
|
338
344
|
|
|
339
345
|
// src/tool/web-search-preview.ts
|
|
340
346
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
341
|
-
import { z as z4 } from "zod";
|
|
347
|
+
import { z as z4 } from "zod/v4";
|
|
342
348
|
var webSearchPreviewArgsSchema = z4.object({
|
|
343
349
|
/**
|
|
344
350
|
* Search context size to use for the web search.
|
|
@@ -383,7 +389,8 @@ var webSearchPreview = createProviderDefinedToolFactory2({
|
|
|
383
389
|
function prepareTools({
|
|
384
390
|
tools,
|
|
385
391
|
toolChoice,
|
|
386
|
-
structuredOutputs
|
|
392
|
+
structuredOutputs,
|
|
393
|
+
strictJsonSchema
|
|
387
394
|
}) {
|
|
388
395
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
389
396
|
const toolWarnings = [];
|
|
@@ -400,7 +407,7 @@ function prepareTools({
|
|
|
400
407
|
name: tool.name,
|
|
401
408
|
description: tool.description,
|
|
402
409
|
parameters: tool.inputSchema,
|
|
403
|
-
strict: structuredOutputs ?
|
|
410
|
+
strict: structuredOutputs ? strictJsonSchema : void 0
|
|
404
411
|
}
|
|
405
412
|
});
|
|
406
413
|
break;
|
|
@@ -492,7 +499,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
492
499
|
toolChoice,
|
|
493
500
|
providerOptions
|
|
494
501
|
}) {
|
|
495
|
-
var _a, _b, _c;
|
|
502
|
+
var _a, _b, _c, _d;
|
|
496
503
|
const warnings = [];
|
|
497
504
|
const openaiOptions = (_a = await parseProviderOptions({
|
|
498
505
|
provider: "openai",
|
|
@@ -520,6 +527,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
520
527
|
}
|
|
521
528
|
);
|
|
522
529
|
warnings.push(...messageWarnings);
|
|
530
|
+
const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
|
|
523
531
|
const baseArgs = {
|
|
524
532
|
// model id:
|
|
525
533
|
model: this.modelId,
|
|
@@ -535,18 +543,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
535
543
|
top_p: topP,
|
|
536
544
|
frequency_penalty: frequencyPenalty,
|
|
537
545
|
presence_penalty: presencePenalty,
|
|
538
|
-
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ?
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
} : { type: "json_object" }
|
|
549
|
-
) : void 0,
|
|
546
|
+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
|
|
547
|
+
type: "json_schema",
|
|
548
|
+
json_schema: {
|
|
549
|
+
schema: responseFormat.schema,
|
|
550
|
+
strict: strictJsonSchema,
|
|
551
|
+
name: (_d = responseFormat.name) != null ? _d : "response",
|
|
552
|
+
description: responseFormat.description
|
|
553
|
+
}
|
|
554
|
+
} : { type: "json_object" } : void 0,
|
|
550
555
|
stop: stopSequences,
|
|
551
556
|
seed,
|
|
552
557
|
// openai specific settings:
|
|
@@ -645,7 +650,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
645
650
|
} = prepareTools({
|
|
646
651
|
tools,
|
|
647
652
|
toolChoice,
|
|
648
|
-
structuredOutputs
|
|
653
|
+
structuredOutputs,
|
|
654
|
+
strictJsonSchema
|
|
649
655
|
});
|
|
650
656
|
return {
|
|
651
657
|
args: {
|
|
@@ -1078,7 +1084,7 @@ import {
|
|
|
1078
1084
|
parseProviderOptions as parseProviderOptions2,
|
|
1079
1085
|
postJsonToApi as postJsonToApi2
|
|
1080
1086
|
} from "@ai-sdk/provider-utils";
|
|
1081
|
-
import { z as z7 } from "zod";
|
|
1087
|
+
import { z as z7 } from "zod/v4";
|
|
1082
1088
|
|
|
1083
1089
|
// src/convert-to-openai-completion-prompt.ts
|
|
1084
1090
|
import {
|
|
@@ -1159,7 +1165,7 @@ ${user}:`]
|
|
|
1159
1165
|
}
|
|
1160
1166
|
|
|
1161
1167
|
// src/openai-completion-options.ts
|
|
1162
|
-
import { z as z6 } from "zod";
|
|
1168
|
+
import { z as z6 } from "zod/v4";
|
|
1163
1169
|
var openaiCompletionProviderOptions = z6.object({
|
|
1164
1170
|
/**
|
|
1165
1171
|
Echo back the prompt in addition to the completion.
|
|
@@ -1484,10 +1490,10 @@ import {
|
|
|
1484
1490
|
parseProviderOptions as parseProviderOptions3,
|
|
1485
1491
|
postJsonToApi as postJsonToApi3
|
|
1486
1492
|
} from "@ai-sdk/provider-utils";
|
|
1487
|
-
import { z as z9 } from "zod";
|
|
1493
|
+
import { z as z9 } from "zod/v4";
|
|
1488
1494
|
|
|
1489
1495
|
// src/openai-embedding-options.ts
|
|
1490
|
-
import { z as z8 } from "zod";
|
|
1496
|
+
import { z as z8 } from "zod/v4";
|
|
1491
1497
|
var openaiEmbeddingProviderOptions = z8.object({
|
|
1492
1498
|
/**
|
|
1493
1499
|
The number of dimensions the resulting output embeddings should have.
|
|
@@ -1575,7 +1581,7 @@ import {
|
|
|
1575
1581
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1576
1582
|
postJsonToApi as postJsonToApi4
|
|
1577
1583
|
} from "@ai-sdk/provider-utils";
|
|
1578
|
-
import { z as z10 } from "zod";
|
|
1584
|
+
import { z as z10 } from "zod/v4";
|
|
1579
1585
|
|
|
1580
1586
|
// src/openai-image-settings.ts
|
|
1581
1587
|
var modelMaxImagesPerCall = {
|
|
@@ -1677,10 +1683,10 @@ import {
|
|
|
1677
1683
|
parseProviderOptions as parseProviderOptions4,
|
|
1678
1684
|
postFormDataToApi
|
|
1679
1685
|
} from "@ai-sdk/provider-utils";
|
|
1680
|
-
import { z as z12 } from "zod";
|
|
1686
|
+
import { z as z12 } from "zod/v4";
|
|
1681
1687
|
|
|
1682
1688
|
// src/openai-transcription-options.ts
|
|
1683
|
-
import { z as z11 } from "zod";
|
|
1689
|
+
import { z as z11 } from "zod/v4";
|
|
1684
1690
|
var openAITranscriptionProviderOptions = z11.object({
|
|
1685
1691
|
/**
|
|
1686
1692
|
* Additional information to include in the transcription response.
|
|
@@ -1871,7 +1877,7 @@ import {
|
|
|
1871
1877
|
parseProviderOptions as parseProviderOptions5,
|
|
1872
1878
|
postJsonToApi as postJsonToApi5
|
|
1873
1879
|
} from "@ai-sdk/provider-utils";
|
|
1874
|
-
import { z as z13 } from "zod";
|
|
1880
|
+
import { z as z13 } from "zod/v4";
|
|
1875
1881
|
var OpenAIProviderOptionsSchema = z13.object({
|
|
1876
1882
|
instructions: z13.string().nullish(),
|
|
1877
1883
|
speed: z13.number().min(0.25).max(4).default(1).nullish()
|
|
@@ -1977,24 +1983,30 @@ var OpenAISpeechModel = class {
|
|
|
1977
1983
|
};
|
|
1978
1984
|
|
|
1979
1985
|
// src/responses/openai-responses-language-model.ts
|
|
1986
|
+
import {
|
|
1987
|
+
APICallError
|
|
1988
|
+
} from "@ai-sdk/provider";
|
|
1980
1989
|
import {
|
|
1981
1990
|
combineHeaders as combineHeaders7,
|
|
1982
1991
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
1983
1992
|
createJsonResponseHandler as createJsonResponseHandler6,
|
|
1984
1993
|
generateId as generateId2,
|
|
1985
|
-
parseProviderOptions as
|
|
1994
|
+
parseProviderOptions as parseProviderOptions7,
|
|
1986
1995
|
postJsonToApi as postJsonToApi6
|
|
1987
1996
|
} from "@ai-sdk/provider-utils";
|
|
1988
|
-
import { z as
|
|
1997
|
+
import { z as z15 } from "zod/v4";
|
|
1989
1998
|
|
|
1990
1999
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1991
2000
|
import {
|
|
1992
2001
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
1993
2002
|
} from "@ai-sdk/provider";
|
|
1994
|
-
|
|
2003
|
+
import { parseProviderOptions as parseProviderOptions6 } from "@ai-sdk/provider-utils";
|
|
2004
|
+
import { z as z14 } from "zod/v4";
|
|
2005
|
+
async function convertToOpenAIResponsesMessages({
|
|
1995
2006
|
prompt,
|
|
1996
2007
|
systemMessageMode
|
|
1997
2008
|
}) {
|
|
2009
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1998
2010
|
const messages = [];
|
|
1999
2011
|
const warnings = [];
|
|
2000
2012
|
for (const { role, content } of prompt) {
|
|
@@ -2029,7 +2041,7 @@ function convertToOpenAIResponsesMessages({
|
|
|
2029
2041
|
messages.push({
|
|
2030
2042
|
role: "user",
|
|
2031
2043
|
content: content.map((part, index) => {
|
|
2032
|
-
var
|
|
2044
|
+
var _a2, _b2, _c2;
|
|
2033
2045
|
switch (part.type) {
|
|
2034
2046
|
case "text": {
|
|
2035
2047
|
return { type: "input_text", text: part.text };
|
|
@@ -2041,7 +2053,7 @@ function convertToOpenAIResponsesMessages({
|
|
|
2041
2053
|
type: "input_image",
|
|
2042
2054
|
image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
|
|
2043
2055
|
// OpenAI specific extension: image detail
|
|
2044
|
-
detail: (
|
|
2056
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
2045
2057
|
};
|
|
2046
2058
|
} else if (part.mediaType === "application/pdf") {
|
|
2047
2059
|
if (part.data instanceof URL) {
|
|
@@ -2051,7 +2063,7 @@ function convertToOpenAIResponsesMessages({
|
|
|
2051
2063
|
}
|
|
2052
2064
|
return {
|
|
2053
2065
|
type: "input_file",
|
|
2054
|
-
filename: (
|
|
2066
|
+
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2055
2067
|
file_data: `data:application/pdf;base64,${part.data}`
|
|
2056
2068
|
};
|
|
2057
2069
|
} else {
|
|
@@ -2066,12 +2078,14 @@ function convertToOpenAIResponsesMessages({
|
|
|
2066
2078
|
break;
|
|
2067
2079
|
}
|
|
2068
2080
|
case "assistant": {
|
|
2081
|
+
const reasoningMessages = {};
|
|
2069
2082
|
for (const part of content) {
|
|
2070
2083
|
switch (part.type) {
|
|
2071
2084
|
case "text": {
|
|
2072
2085
|
messages.push({
|
|
2073
2086
|
role: "assistant",
|
|
2074
|
-
content: [{ type: "output_text", text: part.text }]
|
|
2087
|
+
content: [{ type: "output_text", text: part.text }],
|
|
2088
|
+
id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
|
|
2075
2089
|
});
|
|
2076
2090
|
break;
|
|
2077
2091
|
}
|
|
@@ -2083,7 +2097,8 @@ function convertToOpenAIResponsesMessages({
|
|
|
2083
2097
|
type: "function_call",
|
|
2084
2098
|
call_id: part.toolCallId,
|
|
2085
2099
|
name: part.toolName,
|
|
2086
|
-
arguments: JSON.stringify(part.input)
|
|
2100
|
+
arguments: JSON.stringify(part.input),
|
|
2101
|
+
id: (_f = (_e = (_d = part.providerOptions) == null ? void 0 : _d.openai) == null ? void 0 : _e.itemId) != null ? _f : void 0
|
|
2087
2102
|
});
|
|
2088
2103
|
break;
|
|
2089
2104
|
}
|
|
@@ -2094,6 +2109,43 @@ function convertToOpenAIResponsesMessages({
|
|
|
2094
2109
|
});
|
|
2095
2110
|
break;
|
|
2096
2111
|
}
|
|
2112
|
+
case "reasoning": {
|
|
2113
|
+
const providerOptions = await parseProviderOptions6({
|
|
2114
|
+
provider: "openai",
|
|
2115
|
+
providerOptions: part.providerOptions,
|
|
2116
|
+
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
2117
|
+
});
|
|
2118
|
+
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2119
|
+
if (reasoningId != null) {
|
|
2120
|
+
const existingReasoningMessage = reasoningMessages[reasoningId];
|
|
2121
|
+
const summaryParts = [];
|
|
2122
|
+
if (part.text.length > 0) {
|
|
2123
|
+
summaryParts.push({ type: "summary_text", text: part.text });
|
|
2124
|
+
} else if (existingReasoningMessage !== void 0) {
|
|
2125
|
+
warnings.push({
|
|
2126
|
+
type: "other",
|
|
2127
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
if (existingReasoningMessage === void 0) {
|
|
2131
|
+
reasoningMessages[reasoningId] = {
|
|
2132
|
+
type: "reasoning",
|
|
2133
|
+
id: reasoningId,
|
|
2134
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2135
|
+
summary: summaryParts
|
|
2136
|
+
};
|
|
2137
|
+
messages.push(reasoningMessages[reasoningId]);
|
|
2138
|
+
} else {
|
|
2139
|
+
existingReasoningMessage.summary.push(...summaryParts);
|
|
2140
|
+
}
|
|
2141
|
+
} else {
|
|
2142
|
+
warnings.push({
|
|
2143
|
+
type: "other",
|
|
2144
|
+
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
break;
|
|
2148
|
+
}
|
|
2097
2149
|
}
|
|
2098
2150
|
}
|
|
2099
2151
|
break;
|
|
@@ -2129,6 +2181,10 @@ function convertToOpenAIResponsesMessages({
|
|
|
2129
2181
|
}
|
|
2130
2182
|
return { messages, warnings };
|
|
2131
2183
|
}
|
|
2184
|
+
var openaiResponsesReasoningProviderOptionsSchema = z14.object({
|
|
2185
|
+
itemId: z14.string().nullish(),
|
|
2186
|
+
reasoningEncryptedContent: z14.string().nullish()
|
|
2187
|
+
});
|
|
2132
2188
|
|
|
2133
2189
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
2134
2190
|
function mapOpenAIResponseFinishReason({
|
|
@@ -2155,7 +2211,7 @@ import {
|
|
|
2155
2211
|
function prepareResponsesTools({
|
|
2156
2212
|
tools,
|
|
2157
2213
|
toolChoice,
|
|
2158
|
-
|
|
2214
|
+
strictJsonSchema
|
|
2159
2215
|
}) {
|
|
2160
2216
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
2161
2217
|
const toolWarnings = [];
|
|
@@ -2171,11 +2227,21 @@ function prepareResponsesTools({
|
|
|
2171
2227
|
name: tool.name,
|
|
2172
2228
|
description: tool.description,
|
|
2173
2229
|
parameters: tool.inputSchema,
|
|
2174
|
-
strict:
|
|
2230
|
+
strict: strictJsonSchema
|
|
2175
2231
|
});
|
|
2176
2232
|
break;
|
|
2177
2233
|
case "provider-defined":
|
|
2178
2234
|
switch (tool.id) {
|
|
2235
|
+
case "openai.file_search": {
|
|
2236
|
+
const args = fileSearchArgsSchema.parse(tool.args);
|
|
2237
|
+
openaiTools.push({
|
|
2238
|
+
type: "file_search",
|
|
2239
|
+
vector_store_ids: args.vectorStoreIds,
|
|
2240
|
+
max_results: args.maxResults,
|
|
2241
|
+
search_type: args.searchType
|
|
2242
|
+
});
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2179
2245
|
case "openai.web_search_preview":
|
|
2180
2246
|
openaiTools.push({
|
|
2181
2247
|
type: "web_search_preview",
|
|
@@ -2205,7 +2271,7 @@ function prepareResponsesTools({
|
|
|
2205
2271
|
case "tool":
|
|
2206
2272
|
return {
|
|
2207
2273
|
tools: openaiTools,
|
|
2208
|
-
toolChoice: toolChoice.toolName === "web_search_preview" ? { type: "web_search_preview" } : { type: "function", name: toolChoice.toolName },
|
|
2274
|
+
toolChoice: toolChoice.toolName === "file_search" ? { type: "file_search" } : toolChoice.toolName === "web_search_preview" ? { type: "web_search_preview" } : { type: "function", name: toolChoice.toolName },
|
|
2209
2275
|
toolWarnings
|
|
2210
2276
|
};
|
|
2211
2277
|
default: {
|
|
@@ -2269,17 +2335,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2269
2335
|
if (stopSequences != null) {
|
|
2270
2336
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
2271
2337
|
}
|
|
2272
|
-
const { messages, warnings: messageWarnings } = convertToOpenAIResponsesMessages({
|
|
2338
|
+
const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
|
|
2273
2339
|
prompt,
|
|
2274
2340
|
systemMessageMode: modelConfig.systemMessageMode
|
|
2275
2341
|
});
|
|
2276
2342
|
warnings.push(...messageWarnings);
|
|
2277
|
-
const openaiOptions = await
|
|
2343
|
+
const openaiOptions = await parseProviderOptions7({
|
|
2278
2344
|
provider: "openai",
|
|
2279
2345
|
providerOptions,
|
|
2280
2346
|
schema: openaiResponsesProviderOptionsSchema
|
|
2281
2347
|
});
|
|
2282
|
-
const
|
|
2348
|
+
const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
|
|
2283
2349
|
const baseArgs = {
|
|
2284
2350
|
model: this.modelId,
|
|
2285
2351
|
input: messages,
|
|
@@ -2290,7 +2356,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2290
2356
|
text: {
|
|
2291
2357
|
format: responseFormat.schema != null ? {
|
|
2292
2358
|
type: "json_schema",
|
|
2293
|
-
strict:
|
|
2359
|
+
strict: strictJsonSchema,
|
|
2294
2360
|
name: (_b = responseFormat.name) != null ? _b : "response",
|
|
2295
2361
|
description: responseFormat.description,
|
|
2296
2362
|
schema: responseFormat.schema
|
|
@@ -2305,6 +2371,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2305
2371
|
user: openaiOptions == null ? void 0 : openaiOptions.user,
|
|
2306
2372
|
instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
|
|
2307
2373
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
2374
|
+
include: openaiOptions == null ? void 0 : openaiOptions.include,
|
|
2308
2375
|
// model-specific settings:
|
|
2309
2376
|
...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
2310
2377
|
reasoning: {
|
|
@@ -2337,6 +2404,21 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2337
2404
|
details: "topP is not supported for reasoning models"
|
|
2338
2405
|
});
|
|
2339
2406
|
}
|
|
2407
|
+
} else {
|
|
2408
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
2409
|
+
warnings.push({
|
|
2410
|
+
type: "unsupported-setting",
|
|
2411
|
+
setting: "reasoningEffort",
|
|
2412
|
+
details: "reasoningEffort is not supported for non-reasoning models"
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) {
|
|
2416
|
+
warnings.push({
|
|
2417
|
+
type: "unsupported-setting",
|
|
2418
|
+
setting: "reasoningSummary",
|
|
2419
|
+
details: "reasoningSummary is not supported for non-reasoning models"
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2340
2422
|
}
|
|
2341
2423
|
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !supportsFlexProcessing2(this.modelId)) {
|
|
2342
2424
|
warnings.push({
|
|
@@ -2353,7 +2435,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2353
2435
|
} = prepareResponsesTools({
|
|
2354
2436
|
tools,
|
|
2355
2437
|
toolChoice,
|
|
2356
|
-
|
|
2438
|
+
strictJsonSchema
|
|
2357
2439
|
});
|
|
2358
2440
|
return {
|
|
2359
2441
|
args: {
|
|
@@ -2365,101 +2447,137 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2365
2447
|
};
|
|
2366
2448
|
}
|
|
2367
2449
|
async doGenerate(options) {
|
|
2368
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2369
2451
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2452
|
+
const url = this.config.url({
|
|
2453
|
+
path: "/responses",
|
|
2454
|
+
modelId: this.modelId
|
|
2455
|
+
});
|
|
2370
2456
|
const {
|
|
2371
2457
|
responseHeaders,
|
|
2372
2458
|
value: response,
|
|
2373
2459
|
rawValue: rawResponse
|
|
2374
2460
|
} = await postJsonToApi6({
|
|
2375
|
-
url
|
|
2376
|
-
path: "/responses",
|
|
2377
|
-
modelId: this.modelId
|
|
2378
|
-
}),
|
|
2461
|
+
url,
|
|
2379
2462
|
headers: combineHeaders7(this.config.headers(), options.headers),
|
|
2380
2463
|
body,
|
|
2381
2464
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2382
2465
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
2383
|
-
|
|
2384
|
-
id:
|
|
2385
|
-
created_at:
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2466
|
+
z15.object({
|
|
2467
|
+
id: z15.string(),
|
|
2468
|
+
created_at: z15.number(),
|
|
2469
|
+
error: z15.object({
|
|
2470
|
+
code: z15.string(),
|
|
2471
|
+
message: z15.string()
|
|
2472
|
+
}).nullish(),
|
|
2473
|
+
model: z15.string(),
|
|
2474
|
+
output: z15.array(
|
|
2475
|
+
z15.discriminatedUnion("type", [
|
|
2476
|
+
z15.object({
|
|
2477
|
+
type: z15.literal("message"),
|
|
2478
|
+
role: z15.literal("assistant"),
|
|
2479
|
+
id: z15.string(),
|
|
2480
|
+
content: z15.array(
|
|
2481
|
+
z15.object({
|
|
2482
|
+
type: z15.literal("output_text"),
|
|
2483
|
+
text: z15.string(),
|
|
2484
|
+
annotations: z15.array(
|
|
2485
|
+
z15.object({
|
|
2486
|
+
type: z15.literal("url_citation"),
|
|
2487
|
+
start_index: z15.number(),
|
|
2488
|
+
end_index: z15.number(),
|
|
2489
|
+
url: z15.string(),
|
|
2490
|
+
title: z15.string()
|
|
2403
2491
|
})
|
|
2404
2492
|
)
|
|
2405
2493
|
})
|
|
2406
2494
|
)
|
|
2407
2495
|
}),
|
|
2408
|
-
|
|
2409
|
-
type:
|
|
2410
|
-
call_id:
|
|
2411
|
-
name:
|
|
2412
|
-
arguments:
|
|
2496
|
+
z15.object({
|
|
2497
|
+
type: z15.literal("function_call"),
|
|
2498
|
+
call_id: z15.string(),
|
|
2499
|
+
name: z15.string(),
|
|
2500
|
+
arguments: z15.string(),
|
|
2501
|
+
id: z15.string()
|
|
2413
2502
|
}),
|
|
2414
|
-
|
|
2415
|
-
type:
|
|
2416
|
-
id:
|
|
2417
|
-
status:
|
|
2503
|
+
z15.object({
|
|
2504
|
+
type: z15.literal("web_search_call"),
|
|
2505
|
+
id: z15.string(),
|
|
2506
|
+
status: z15.string().optional()
|
|
2418
2507
|
}),
|
|
2419
|
-
|
|
2420
|
-
type:
|
|
2421
|
-
id:
|
|
2422
|
-
status:
|
|
2508
|
+
z15.object({
|
|
2509
|
+
type: z15.literal("computer_call"),
|
|
2510
|
+
id: z15.string(),
|
|
2511
|
+
status: z15.string().optional()
|
|
2423
2512
|
}),
|
|
2424
|
-
|
|
2425
|
-
type:
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2513
|
+
z15.object({
|
|
2514
|
+
type: z15.literal("reasoning"),
|
|
2515
|
+
id: z15.string(),
|
|
2516
|
+
encrypted_content: z15.string().nullish(),
|
|
2517
|
+
summary: z15.array(
|
|
2518
|
+
z15.object({
|
|
2519
|
+
type: z15.literal("summary_text"),
|
|
2520
|
+
text: z15.string()
|
|
2430
2521
|
})
|
|
2431
2522
|
)
|
|
2432
2523
|
})
|
|
2433
2524
|
])
|
|
2434
2525
|
),
|
|
2435
|
-
incomplete_details:
|
|
2526
|
+
incomplete_details: z15.object({ reason: z15.string() }).nullable(),
|
|
2436
2527
|
usage: usageSchema2
|
|
2437
2528
|
})
|
|
2438
2529
|
),
|
|
2439
2530
|
abortSignal: options.abortSignal,
|
|
2440
2531
|
fetch: this.config.fetch
|
|
2441
2532
|
});
|
|
2533
|
+
if (response.error) {
|
|
2534
|
+
throw new APICallError({
|
|
2535
|
+
message: response.error.message,
|
|
2536
|
+
url,
|
|
2537
|
+
requestBodyValues: body,
|
|
2538
|
+
statusCode: 400,
|
|
2539
|
+
responseHeaders,
|
|
2540
|
+
responseBody: rawResponse,
|
|
2541
|
+
isRetryable: false
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2442
2544
|
const content = [];
|
|
2443
2545
|
for (const part of response.output) {
|
|
2444
2546
|
switch (part.type) {
|
|
2445
2547
|
case "reasoning": {
|
|
2446
|
-
|
|
2447
|
-
type: "
|
|
2448
|
-
|
|
2449
|
-
|
|
2548
|
+
if (part.summary.length === 0) {
|
|
2549
|
+
part.summary.push({ type: "summary_text", text: "" });
|
|
2550
|
+
}
|
|
2551
|
+
for (const summary of part.summary) {
|
|
2552
|
+
content.push({
|
|
2553
|
+
type: "reasoning",
|
|
2554
|
+
text: summary.text,
|
|
2555
|
+
providerMetadata: {
|
|
2556
|
+
openai: {
|
|
2557
|
+
itemId: part.id,
|
|
2558
|
+
reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2450
2563
|
break;
|
|
2451
2564
|
}
|
|
2452
2565
|
case "message": {
|
|
2453
2566
|
for (const contentPart of part.content) {
|
|
2454
2567
|
content.push({
|
|
2455
2568
|
type: "text",
|
|
2456
|
-
text: contentPart.text
|
|
2569
|
+
text: contentPart.text,
|
|
2570
|
+
providerMetadata: {
|
|
2571
|
+
openai: {
|
|
2572
|
+
itemId: part.id
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2457
2575
|
});
|
|
2458
2576
|
for (const annotation of contentPart.annotations) {
|
|
2459
2577
|
content.push({
|
|
2460
2578
|
type: "source",
|
|
2461
2579
|
sourceType: "url",
|
|
2462
|
-
id: (
|
|
2580
|
+
id: (_d = (_c = (_b = this.config).generateId) == null ? void 0 : _c.call(_b)) != null ? _d : generateId2(),
|
|
2463
2581
|
url: annotation.url,
|
|
2464
2582
|
title: annotation.title
|
|
2465
2583
|
});
|
|
@@ -2472,7 +2590,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2472
2590
|
type: "tool-call",
|
|
2473
2591
|
toolCallId: part.call_id,
|
|
2474
2592
|
toolName: part.name,
|
|
2475
|
-
input: part.arguments
|
|
2593
|
+
input: part.arguments,
|
|
2594
|
+
providerMetadata: {
|
|
2595
|
+
openai: {
|
|
2596
|
+
itemId: part.id
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2476
2599
|
});
|
|
2477
2600
|
break;
|
|
2478
2601
|
}
|
|
@@ -2518,15 +2641,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2518
2641
|
return {
|
|
2519
2642
|
content,
|
|
2520
2643
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2521
|
-
finishReason: (
|
|
2644
|
+
finishReason: (_e = response.incomplete_details) == null ? void 0 : _e.reason,
|
|
2522
2645
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2523
2646
|
}),
|
|
2524
2647
|
usage: {
|
|
2525
2648
|
inputTokens: response.usage.input_tokens,
|
|
2526
2649
|
outputTokens: response.usage.output_tokens,
|
|
2527
2650
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2528
|
-
reasoningTokens: (
|
|
2529
|
-
cachedInputTokens: (
|
|
2651
|
+
reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : void 0,
|
|
2652
|
+
cachedInputTokens: (_i = (_h = response.usage.input_tokens_details) == null ? void 0 : _h.cached_tokens) != null ? _i : void 0
|
|
2530
2653
|
},
|
|
2531
2654
|
request: { body },
|
|
2532
2655
|
response: {
|
|
@@ -2573,6 +2696,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2573
2696
|
let responseId = null;
|
|
2574
2697
|
const ongoingToolCalls = {};
|
|
2575
2698
|
let hasToolCalls = false;
|
|
2699
|
+
const activeReasoning = {};
|
|
2576
2700
|
return {
|
|
2577
2701
|
stream: response.pipeThrough(
|
|
2578
2702
|
new TransformStream({
|
|
@@ -2580,7 +2704,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2580
2704
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2581
2705
|
},
|
|
2582
2706
|
transform(chunk, controller) {
|
|
2583
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2707
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2584
2708
|
if (options.includeRawChunks) {
|
|
2585
2709
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2586
2710
|
}
|
|
@@ -2624,12 +2748,27 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2624
2748
|
} else if (value.item.type === "message") {
|
|
2625
2749
|
controller.enqueue({
|
|
2626
2750
|
type: "text-start",
|
|
2627
|
-
id: value.item.id
|
|
2751
|
+
id: value.item.id,
|
|
2752
|
+
providerMetadata: {
|
|
2753
|
+
openai: {
|
|
2754
|
+
itemId: value.item.id
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2628
2757
|
});
|
|
2629
|
-
} else if (value
|
|
2758
|
+
} else if (isResponseOutputItemAddedReasoningChunk(value)) {
|
|
2759
|
+
activeReasoning[value.item.id] = {
|
|
2760
|
+
encryptedContent: value.item.encrypted_content,
|
|
2761
|
+
summaryParts: [0]
|
|
2762
|
+
};
|
|
2630
2763
|
controller.enqueue({
|
|
2631
2764
|
type: "reasoning-start",
|
|
2632
|
-
id: value.item.id
|
|
2765
|
+
id: `${value.item.id}:0`,
|
|
2766
|
+
providerMetadata: {
|
|
2767
|
+
openai: {
|
|
2768
|
+
itemId: value.item.id,
|
|
2769
|
+
reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2633
2772
|
});
|
|
2634
2773
|
}
|
|
2635
2774
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
@@ -2644,7 +2783,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2644
2783
|
type: "tool-call",
|
|
2645
2784
|
toolCallId: value.item.call_id,
|
|
2646
2785
|
toolName: value.item.name,
|
|
2647
|
-
input: value.item.arguments
|
|
2786
|
+
input: value.item.arguments,
|
|
2787
|
+
providerMetadata: {
|
|
2788
|
+
openai: {
|
|
2789
|
+
itemId: value.item.id
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2648
2792
|
});
|
|
2649
2793
|
} else if (value.item.type === "web_search_call") {
|
|
2650
2794
|
ongoingToolCalls[value.output_index] = void 0;
|
|
@@ -2699,11 +2843,21 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2699
2843
|
type: "text-end",
|
|
2700
2844
|
id: value.item.id
|
|
2701
2845
|
});
|
|
2702
|
-
} else if (value
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2846
|
+
} else if (isResponseOutputItemDoneReasoningChunk(value)) {
|
|
2847
|
+
const activeReasoningPart = activeReasoning[value.item.id];
|
|
2848
|
+
for (const summaryIndex of activeReasoningPart.summaryParts) {
|
|
2849
|
+
controller.enqueue({
|
|
2850
|
+
type: "reasoning-end",
|
|
2851
|
+
id: `${value.item.id}:${summaryIndex}`,
|
|
2852
|
+
providerMetadata: {
|
|
2853
|
+
openai: {
|
|
2854
|
+
itemId: value.item.id,
|
|
2855
|
+
reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
delete activeReasoning[value.item.id];
|
|
2707
2861
|
}
|
|
2708
2862
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
2709
2863
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
@@ -2728,30 +2882,53 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2728
2882
|
id: value.item_id,
|
|
2729
2883
|
delta: value.delta
|
|
2730
2884
|
});
|
|
2885
|
+
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
2886
|
+
if (value.summary_index > 0) {
|
|
2887
|
+
(_c = activeReasoning[value.item_id]) == null ? void 0 : _c.summaryParts.push(
|
|
2888
|
+
value.summary_index
|
|
2889
|
+
);
|
|
2890
|
+
controller.enqueue({
|
|
2891
|
+
type: "reasoning-start",
|
|
2892
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
2893
|
+
providerMetadata: {
|
|
2894
|
+
openai: {
|
|
2895
|
+
itemId: value.item_id,
|
|
2896
|
+
reasoningEncryptedContent: (_e = (_d = activeReasoning[value.item_id]) == null ? void 0 : _d.encryptedContent) != null ? _e : null
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2731
2901
|
} else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
|
|
2732
2902
|
controller.enqueue({
|
|
2733
2903
|
type: "reasoning-delta",
|
|
2904
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
2734
2905
|
delta: value.delta,
|
|
2735
|
-
|
|
2906
|
+
providerMetadata: {
|
|
2907
|
+
openai: {
|
|
2908
|
+
itemId: value.item_id
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2736
2911
|
});
|
|
2737
2912
|
} else if (isResponseFinishedChunk(value)) {
|
|
2738
2913
|
finishReason = mapOpenAIResponseFinishReason({
|
|
2739
|
-
finishReason: (
|
|
2914
|
+
finishReason: (_f = value.response.incomplete_details) == null ? void 0 : _f.reason,
|
|
2740
2915
|
hasToolCalls
|
|
2741
2916
|
});
|
|
2742
2917
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
2743
2918
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
2744
2919
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
2745
|
-
usage.reasoningTokens = (
|
|
2746
|
-
usage.cachedInputTokens = (
|
|
2920
|
+
usage.reasoningTokens = (_h = (_g = value.response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : void 0;
|
|
2921
|
+
usage.cachedInputTokens = (_j = (_i = value.response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens) != null ? _j : void 0;
|
|
2747
2922
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
2748
2923
|
controller.enqueue({
|
|
2749
2924
|
type: "source",
|
|
2750
2925
|
sourceType: "url",
|
|
2751
|
-
id: (
|
|
2926
|
+
id: (_m = (_l = (_k = self.config).generateId) == null ? void 0 : _l.call(_k)) != null ? _m : generateId2(),
|
|
2752
2927
|
url: value.annotation.url,
|
|
2753
2928
|
title: value.annotation.title
|
|
2754
2929
|
});
|
|
2930
|
+
} else if (isErrorChunk(value)) {
|
|
2931
|
+
controller.enqueue({ type: "error", error: value });
|
|
2755
2932
|
}
|
|
2756
2933
|
},
|
|
2757
2934
|
flush(controller) {
|
|
@@ -2773,124 +2950,130 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2773
2950
|
};
|
|
2774
2951
|
}
|
|
2775
2952
|
};
|
|
2776
|
-
var usageSchema2 =
|
|
2777
|
-
input_tokens:
|
|
2778
|
-
input_tokens_details:
|
|
2779
|
-
output_tokens:
|
|
2780
|
-
output_tokens_details:
|
|
2953
|
+
var usageSchema2 = z15.object({
|
|
2954
|
+
input_tokens: z15.number(),
|
|
2955
|
+
input_tokens_details: z15.object({ cached_tokens: z15.number().nullish() }).nullish(),
|
|
2956
|
+
output_tokens: z15.number(),
|
|
2957
|
+
output_tokens_details: z15.object({ reasoning_tokens: z15.number().nullish() }).nullish()
|
|
2781
2958
|
});
|
|
2782
|
-
var textDeltaChunkSchema =
|
|
2783
|
-
type:
|
|
2784
|
-
item_id:
|
|
2785
|
-
delta:
|
|
2959
|
+
var textDeltaChunkSchema = z15.object({
|
|
2960
|
+
type: z15.literal("response.output_text.delta"),
|
|
2961
|
+
item_id: z15.string(),
|
|
2962
|
+
delta: z15.string()
|
|
2786
2963
|
});
|
|
2787
|
-
var
|
|
2788
|
-
type:
|
|
2789
|
-
|
|
2790
|
-
|
|
2964
|
+
var errorChunkSchema = z15.object({
|
|
2965
|
+
type: z15.literal("error"),
|
|
2966
|
+
code: z15.string(),
|
|
2967
|
+
message: z15.string(),
|
|
2968
|
+
param: z15.string().nullish(),
|
|
2969
|
+
sequence_number: z15.number()
|
|
2970
|
+
});
|
|
2971
|
+
var responseFinishedChunkSchema = z15.object({
|
|
2972
|
+
type: z15.enum(["response.completed", "response.incomplete"]),
|
|
2973
|
+
response: z15.object({
|
|
2974
|
+
incomplete_details: z15.object({ reason: z15.string() }).nullish(),
|
|
2791
2975
|
usage: usageSchema2
|
|
2792
2976
|
})
|
|
2793
2977
|
});
|
|
2794
|
-
var responseCreatedChunkSchema =
|
|
2795
|
-
type:
|
|
2796
|
-
response:
|
|
2797
|
-
id:
|
|
2798
|
-
created_at:
|
|
2799
|
-
model:
|
|
2978
|
+
var responseCreatedChunkSchema = z15.object({
|
|
2979
|
+
type: z15.literal("response.created"),
|
|
2980
|
+
response: z15.object({
|
|
2981
|
+
id: z15.string(),
|
|
2982
|
+
created_at: z15.number(),
|
|
2983
|
+
model: z15.string()
|
|
2800
2984
|
})
|
|
2801
2985
|
});
|
|
2802
|
-
var responseOutputItemAddedSchema =
|
|
2803
|
-
type:
|
|
2804
|
-
output_index:
|
|
2805
|
-
item:
|
|
2806
|
-
|
|
2807
|
-
type:
|
|
2808
|
-
id:
|
|
2986
|
+
var responseOutputItemAddedSchema = z15.object({
|
|
2987
|
+
type: z15.literal("response.output_item.added"),
|
|
2988
|
+
output_index: z15.number(),
|
|
2989
|
+
item: z15.discriminatedUnion("type", [
|
|
2990
|
+
z15.object({
|
|
2991
|
+
type: z15.literal("message"),
|
|
2992
|
+
id: z15.string()
|
|
2809
2993
|
}),
|
|
2810
|
-
|
|
2811
|
-
type:
|
|
2812
|
-
id:
|
|
2994
|
+
z15.object({
|
|
2995
|
+
type: z15.literal("reasoning"),
|
|
2996
|
+
id: z15.string(),
|
|
2997
|
+
encrypted_content: z15.string().nullish()
|
|
2813
2998
|
}),
|
|
2814
|
-
|
|
2815
|
-
type:
|
|
2816
|
-
id:
|
|
2817
|
-
call_id:
|
|
2818
|
-
name:
|
|
2819
|
-
arguments:
|
|
2999
|
+
z15.object({
|
|
3000
|
+
type: z15.literal("function_call"),
|
|
3001
|
+
id: z15.string(),
|
|
3002
|
+
call_id: z15.string(),
|
|
3003
|
+
name: z15.string(),
|
|
3004
|
+
arguments: z15.string()
|
|
2820
3005
|
}),
|
|
2821
|
-
|
|
2822
|
-
type:
|
|
2823
|
-
id:
|
|
2824
|
-
status:
|
|
3006
|
+
z15.object({
|
|
3007
|
+
type: z15.literal("web_search_call"),
|
|
3008
|
+
id: z15.string(),
|
|
3009
|
+
status: z15.string()
|
|
2825
3010
|
}),
|
|
2826
|
-
|
|
2827
|
-
type:
|
|
2828
|
-
id:
|
|
2829
|
-
status:
|
|
3011
|
+
z15.object({
|
|
3012
|
+
type: z15.literal("computer_call"),
|
|
3013
|
+
id: z15.string(),
|
|
3014
|
+
status: z15.string()
|
|
2830
3015
|
})
|
|
2831
3016
|
])
|
|
2832
3017
|
});
|
|
2833
|
-
var responseOutputItemDoneSchema =
|
|
2834
|
-
type:
|
|
2835
|
-
output_index:
|
|
2836
|
-
item:
|
|
2837
|
-
|
|
2838
|
-
type:
|
|
2839
|
-
id:
|
|
3018
|
+
var responseOutputItemDoneSchema = z15.object({
|
|
3019
|
+
type: z15.literal("response.output_item.done"),
|
|
3020
|
+
output_index: z15.number(),
|
|
3021
|
+
item: z15.discriminatedUnion("type", [
|
|
3022
|
+
z15.object({
|
|
3023
|
+
type: z15.literal("message"),
|
|
3024
|
+
id: z15.string()
|
|
2840
3025
|
}),
|
|
2841
|
-
|
|
2842
|
-
type:
|
|
2843
|
-
id:
|
|
3026
|
+
z15.object({
|
|
3027
|
+
type: z15.literal("reasoning"),
|
|
3028
|
+
id: z15.string(),
|
|
3029
|
+
encrypted_content: z15.string().nullish()
|
|
2844
3030
|
}),
|
|
2845
|
-
|
|
2846
|
-
type:
|
|
2847
|
-
id:
|
|
2848
|
-
call_id:
|
|
2849
|
-
name:
|
|
2850
|
-
arguments:
|
|
2851
|
-
status:
|
|
3031
|
+
z15.object({
|
|
3032
|
+
type: z15.literal("function_call"),
|
|
3033
|
+
id: z15.string(),
|
|
3034
|
+
call_id: z15.string(),
|
|
3035
|
+
name: z15.string(),
|
|
3036
|
+
arguments: z15.string(),
|
|
3037
|
+
status: z15.literal("completed")
|
|
2852
3038
|
}),
|
|
2853
|
-
|
|
2854
|
-
type:
|
|
2855
|
-
id:
|
|
2856
|
-
status:
|
|
3039
|
+
z15.object({
|
|
3040
|
+
type: z15.literal("web_search_call"),
|
|
3041
|
+
id: z15.string(),
|
|
3042
|
+
status: z15.literal("completed")
|
|
2857
3043
|
}),
|
|
2858
|
-
|
|
2859
|
-
type:
|
|
2860
|
-
id:
|
|
2861
|
-
status:
|
|
3044
|
+
z15.object({
|
|
3045
|
+
type: z15.literal("computer_call"),
|
|
3046
|
+
id: z15.string(),
|
|
3047
|
+
status: z15.literal("completed")
|
|
2862
3048
|
})
|
|
2863
3049
|
])
|
|
2864
3050
|
});
|
|
2865
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2866
|
-
type:
|
|
2867
|
-
item_id:
|
|
2868
|
-
output_index:
|
|
2869
|
-
delta:
|
|
3051
|
+
var responseFunctionCallArgumentsDeltaSchema = z15.object({
|
|
3052
|
+
type: z15.literal("response.function_call_arguments.delta"),
|
|
3053
|
+
item_id: z15.string(),
|
|
3054
|
+
output_index: z15.number(),
|
|
3055
|
+
delta: z15.string()
|
|
2870
3056
|
});
|
|
2871
|
-
var responseAnnotationAddedSchema =
|
|
2872
|
-
type:
|
|
2873
|
-
annotation:
|
|
2874
|
-
type:
|
|
2875
|
-
url:
|
|
2876
|
-
title:
|
|
3057
|
+
var responseAnnotationAddedSchema = z15.object({
|
|
3058
|
+
type: z15.literal("response.output_text.annotation.added"),
|
|
3059
|
+
annotation: z15.object({
|
|
3060
|
+
type: z15.literal("url_citation"),
|
|
3061
|
+
url: z15.string(),
|
|
3062
|
+
title: z15.string()
|
|
2877
3063
|
})
|
|
2878
3064
|
});
|
|
2879
|
-
var
|
|
2880
|
-
type:
|
|
2881
|
-
item_id:
|
|
2882
|
-
|
|
2883
|
-
summary_index: z14.number(),
|
|
2884
|
-
delta: z14.string()
|
|
3065
|
+
var responseReasoningSummaryPartAddedSchema = z15.object({
|
|
3066
|
+
type: z15.literal("response.reasoning_summary_part.added"),
|
|
3067
|
+
item_id: z15.string(),
|
|
3068
|
+
summary_index: z15.number()
|
|
2885
3069
|
});
|
|
2886
|
-
var
|
|
2887
|
-
type:
|
|
2888
|
-
item_id:
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
part: z14.unknown().nullish()
|
|
3070
|
+
var responseReasoningSummaryTextDeltaSchema = z15.object({
|
|
3071
|
+
type: z15.literal("response.reasoning_summary_text.delta"),
|
|
3072
|
+
item_id: z15.string(),
|
|
3073
|
+
summary_index: z15.number(),
|
|
3074
|
+
delta: z15.string()
|
|
2892
3075
|
});
|
|
2893
|
-
var openaiResponsesChunkSchema =
|
|
3076
|
+
var openaiResponsesChunkSchema = z15.union([
|
|
2894
3077
|
textDeltaChunkSchema,
|
|
2895
3078
|
responseFinishedChunkSchema,
|
|
2896
3079
|
responseCreatedChunkSchema,
|
|
@@ -2898,9 +3081,10 @@ var openaiResponsesChunkSchema = z14.union([
|
|
|
2898
3081
|
responseOutputItemDoneSchema,
|
|
2899
3082
|
responseFunctionCallArgumentsDeltaSchema,
|
|
2900
3083
|
responseAnnotationAddedSchema,
|
|
3084
|
+
responseReasoningSummaryPartAddedSchema,
|
|
2901
3085
|
responseReasoningSummaryTextDeltaSchema,
|
|
2902
|
-
|
|
2903
|
-
|
|
3086
|
+
errorChunkSchema,
|
|
3087
|
+
z15.object({ type: z15.string() }).loose()
|
|
2904
3088
|
// fallback for unknown chunks
|
|
2905
3089
|
]);
|
|
2906
3090
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2909,6 +3093,9 @@ function isTextDeltaChunk(chunk) {
|
|
|
2909
3093
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
2910
3094
|
return chunk.type === "response.output_item.done";
|
|
2911
3095
|
}
|
|
3096
|
+
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
3097
|
+
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
3098
|
+
}
|
|
2912
3099
|
function isResponseFinishedChunk(chunk) {
|
|
2913
3100
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
2914
3101
|
}
|
|
@@ -2921,14 +3108,23 @@ function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
|
2921
3108
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
2922
3109
|
return chunk.type === "response.output_item.added";
|
|
2923
3110
|
}
|
|
3111
|
+
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
3112
|
+
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
3113
|
+
}
|
|
2924
3114
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
2925
3115
|
return chunk.type === "response.output_text.annotation.added";
|
|
2926
3116
|
}
|
|
3117
|
+
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
3118
|
+
return chunk.type === "response.reasoning_summary_part.added";
|
|
3119
|
+
}
|
|
2927
3120
|
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
2928
3121
|
return chunk.type === "response.reasoning_summary_text.delta";
|
|
2929
3122
|
}
|
|
3123
|
+
function isErrorChunk(chunk) {
|
|
3124
|
+
return chunk.type === "error";
|
|
3125
|
+
}
|
|
2930
3126
|
function getResponsesModelConfig(modelId) {
|
|
2931
|
-
if (modelId.startsWith("o")) {
|
|
3127
|
+
if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
2932
3128
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
2933
3129
|
return {
|
|
2934
3130
|
isReasoningModel: true,
|
|
@@ -2951,17 +3147,18 @@ function getResponsesModelConfig(modelId) {
|
|
|
2951
3147
|
function supportsFlexProcessing2(modelId) {
|
|
2952
3148
|
return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
2953
3149
|
}
|
|
2954
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2955
|
-
metadata:
|
|
2956
|
-
parallelToolCalls:
|
|
2957
|
-
previousResponseId:
|
|
2958
|
-
store:
|
|
2959
|
-
user:
|
|
2960
|
-
reasoningEffort:
|
|
2961
|
-
|
|
2962
|
-
instructions:
|
|
2963
|
-
reasoningSummary:
|
|
2964
|
-
serviceTier:
|
|
3150
|
+
var openaiResponsesProviderOptionsSchema = z15.object({
|
|
3151
|
+
metadata: z15.any().nullish(),
|
|
3152
|
+
parallelToolCalls: z15.boolean().nullish(),
|
|
3153
|
+
previousResponseId: z15.string().nullish(),
|
|
3154
|
+
store: z15.boolean().nullish(),
|
|
3155
|
+
user: z15.string().nullish(),
|
|
3156
|
+
reasoningEffort: z15.string().nullish(),
|
|
3157
|
+
strictJsonSchema: z15.boolean().nullish(),
|
|
3158
|
+
instructions: z15.string().nullish(),
|
|
3159
|
+
reasoningSummary: z15.string().nullish(),
|
|
3160
|
+
serviceTier: z15.enum(["auto", "flex"]).nullish(),
|
|
3161
|
+
include: z15.array(z15.enum(["reasoning.encrypted_content"])).nullish()
|
|
2965
3162
|
});
|
|
2966
3163
|
export {
|
|
2967
3164
|
OpenAIChatLanguageModel,
|