@ai-sdk/openai 4.0.10 → 4.0.11
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 +6 -0
- package/dist/index.d.ts +20 -1
- package/dist/index.js +324 -74
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +14 -1
- package/dist/internal/index.js +323 -73
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +75 -16
- package/package.json +3 -3
- package/src/chat/convert-openai-chat-usage.ts +5 -2
- package/src/chat/convert-to-openai-chat-messages.ts +114 -7
- package/src/chat/openai-chat-api.ts +2 -0
- package/src/chat/openai-chat-language-model-options.ts +16 -2
- package/src/chat/openai-chat-language-model.ts +1 -0
- package/src/chat/openai-chat-prompt.ts +8 -4
- package/src/responses/convert-openai-responses-usage.ts +5 -2
- package/src/responses/convert-to-openai-responses-input.ts +123 -6
- package/src/responses/openai-responses-api.ts +77 -11
- package/src/responses/openai-responses-language-model-options.ts +32 -7
- package/src/responses/openai-responses-language-model.ts +37 -1
- package/src/responses/openai-responses-provider-metadata.ts +1 -0
package/dist/internal/index.js
CHANGED
|
@@ -173,7 +173,7 @@ function isHttpErrorStatusCode(value) {
|
|
|
173
173
|
|
|
174
174
|
// src/chat/convert-openai-chat-usage.ts
|
|
175
175
|
function convertOpenAIChatUsage(usage) {
|
|
176
|
-
var _a, _b, _c, _d, _e, _f;
|
|
176
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
177
177
|
if (usage == null) {
|
|
178
178
|
return {
|
|
179
179
|
inputTokens: {
|
|
@@ -193,13 +193,14 @@ function convertOpenAIChatUsage(usage) {
|
|
|
193
193
|
const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
|
|
194
194
|
const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
|
|
195
195
|
const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
|
|
196
|
-
const
|
|
196
|
+
const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
|
|
197
|
+
const reasoningTokens = (_h = (_g = usage.completion_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : 0;
|
|
197
198
|
return {
|
|
198
199
|
inputTokens: {
|
|
199
200
|
total: promptTokens,
|
|
200
|
-
noCache: promptTokens - cachedTokens,
|
|
201
|
+
noCache: promptTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
201
202
|
cacheRead: cachedTokens,
|
|
202
|
-
cacheWrite:
|
|
203
|
+
cacheWrite: cacheWriteTokens
|
|
203
204
|
},
|
|
204
205
|
outputTokens: {
|
|
205
206
|
total: completionTokens,
|
|
@@ -223,23 +224,47 @@ import {
|
|
|
223
224
|
function serializeToolCallArguments(input) {
|
|
224
225
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
225
226
|
}
|
|
227
|
+
function getPromptCacheBreakpoint(providerOptions) {
|
|
228
|
+
var _a;
|
|
229
|
+
return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
230
|
+
}
|
|
226
231
|
function convertToOpenAIChatMessages({
|
|
227
232
|
prompt,
|
|
228
233
|
systemMessageMode = "system"
|
|
229
234
|
}) {
|
|
230
|
-
var _a;
|
|
235
|
+
var _a, _b;
|
|
231
236
|
const messages = [];
|
|
232
237
|
const warnings = [];
|
|
233
|
-
for (const { role, content } of prompt) {
|
|
238
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
234
239
|
switch (role) {
|
|
235
240
|
case "system": {
|
|
236
241
|
switch (systemMessageMode) {
|
|
237
242
|
case "system": {
|
|
238
|
-
|
|
243
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
244
|
+
messages.push({
|
|
245
|
+
role: "system",
|
|
246
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
247
|
+
{
|
|
248
|
+
type: "text",
|
|
249
|
+
text: content,
|
|
250
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
});
|
|
239
254
|
break;
|
|
240
255
|
}
|
|
241
256
|
case "developer": {
|
|
242
|
-
|
|
257
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
258
|
+
messages.push({
|
|
259
|
+
role: "developer",
|
|
260
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
261
|
+
{
|
|
262
|
+
type: "text",
|
|
263
|
+
text: content,
|
|
264
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
});
|
|
243
268
|
break;
|
|
244
269
|
}
|
|
245
270
|
case "remove": {
|
|
@@ -259,19 +284,31 @@ function convertToOpenAIChatMessages({
|
|
|
259
284
|
break;
|
|
260
285
|
}
|
|
261
286
|
case "user": {
|
|
262
|
-
if (content.length === 1 && content[0].type === "text") {
|
|
287
|
+
if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
|
|
263
288
|
messages.push({ role: "user", content: content[0].text });
|
|
264
289
|
break;
|
|
265
290
|
}
|
|
266
291
|
messages.push({
|
|
267
292
|
role: "user",
|
|
268
293
|
content: content.map((part, index) => {
|
|
269
|
-
var _a2,
|
|
294
|
+
var _a2, _b2, _c;
|
|
270
295
|
switch (part.type) {
|
|
271
296
|
case "text": {
|
|
272
|
-
|
|
297
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
298
|
+
part.providerOptions
|
|
299
|
+
);
|
|
300
|
+
return {
|
|
301
|
+
type: "text",
|
|
302
|
+
text: part.text,
|
|
303
|
+
...promptCacheBreakpoint != null && {
|
|
304
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
305
|
+
}
|
|
306
|
+
};
|
|
273
307
|
}
|
|
274
308
|
case "file": {
|
|
309
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
310
|
+
part.providerOptions
|
|
311
|
+
);
|
|
275
312
|
switch (part.data.type) {
|
|
276
313
|
case "reference": {
|
|
277
314
|
return {
|
|
@@ -281,6 +318,9 @@ function convertToOpenAIChatMessages({
|
|
|
281
318
|
reference: part.data.reference,
|
|
282
319
|
provider: "openai"
|
|
283
320
|
})
|
|
321
|
+
},
|
|
322
|
+
...promptCacheBreakpoint != null && {
|
|
323
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
284
324
|
}
|
|
285
325
|
};
|
|
286
326
|
}
|
|
@@ -297,7 +337,10 @@ function convertToOpenAIChatMessages({
|
|
|
297
337
|
type: "image_url",
|
|
298
338
|
image_url: {
|
|
299
339
|
url: part.data.type === "url" ? part.data.url.toString() : `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`,
|
|
300
|
-
detail: (
|
|
340
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
341
|
+
},
|
|
342
|
+
...promptCacheBreakpoint != null && {
|
|
343
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
301
344
|
}
|
|
302
345
|
};
|
|
303
346
|
} else if (topLevel === "audio") {
|
|
@@ -314,6 +357,9 @@ function convertToOpenAIChatMessages({
|
|
|
314
357
|
input_audio: {
|
|
315
358
|
data: convertToBase64(part.data.data),
|
|
316
359
|
format: "wav"
|
|
360
|
+
},
|
|
361
|
+
...promptCacheBreakpoint != null && {
|
|
362
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
317
363
|
}
|
|
318
364
|
};
|
|
319
365
|
}
|
|
@@ -324,6 +370,9 @@ function convertToOpenAIChatMessages({
|
|
|
324
370
|
input_audio: {
|
|
325
371
|
data: convertToBase64(part.data.data),
|
|
326
372
|
format: "mp3"
|
|
373
|
+
},
|
|
374
|
+
...promptCacheBreakpoint != null && {
|
|
375
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
327
376
|
}
|
|
328
377
|
};
|
|
329
378
|
}
|
|
@@ -351,6 +400,9 @@ function convertToOpenAIChatMessages({
|
|
|
351
400
|
file: {
|
|
352
401
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
353
402
|
file_data: `data:application/pdf;base64,${convertToBase64(part.data.data)}`
|
|
403
|
+
},
|
|
404
|
+
...promptCacheBreakpoint != null && {
|
|
405
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
354
406
|
}
|
|
355
407
|
};
|
|
356
408
|
}
|
|
@@ -364,11 +416,24 @@ function convertToOpenAIChatMessages({
|
|
|
364
416
|
}
|
|
365
417
|
case "assistant": {
|
|
366
418
|
let text = "";
|
|
419
|
+
const textParts = [];
|
|
420
|
+
let hasPromptCacheBreakpoint = false;
|
|
367
421
|
const toolCalls = [];
|
|
368
422
|
for (const part of content) {
|
|
369
423
|
switch (part.type) {
|
|
370
424
|
case "text": {
|
|
425
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
426
|
+
part.providerOptions
|
|
427
|
+
);
|
|
371
428
|
text += part.text;
|
|
429
|
+
textParts.push({
|
|
430
|
+
type: "text",
|
|
431
|
+
text: part.text,
|
|
432
|
+
...promptCacheBreakpoint != null && {
|
|
433
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
|
|
372
437
|
break;
|
|
373
438
|
}
|
|
374
439
|
case "tool-call": {
|
|
@@ -386,7 +451,7 @@ function convertToOpenAIChatMessages({
|
|
|
386
451
|
}
|
|
387
452
|
messages.push({
|
|
388
453
|
role: "assistant",
|
|
389
|
-
content: toolCalls.length > 0 ? text || null : text,
|
|
454
|
+
content: hasPromptCacheBreakpoint ? textParts : toolCalls.length > 0 ? text || null : text,
|
|
390
455
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
391
456
|
});
|
|
392
457
|
break;
|
|
@@ -397,6 +462,7 @@ function convertToOpenAIChatMessages({
|
|
|
397
462
|
continue;
|
|
398
463
|
}
|
|
399
464
|
const output = toolResponse.output;
|
|
465
|
+
const promptCacheBreakpoint = (_a = output.type === "content" ? output.value.map((part) => getPromptCacheBreakpoint(part.providerOptions)).find((breakpoint) => breakpoint != null) : getPromptCacheBreakpoint(output.providerOptions)) != null ? _a : getPromptCacheBreakpoint(toolResponse.providerOptions);
|
|
400
466
|
let contentValue;
|
|
401
467
|
switch (output.type) {
|
|
402
468
|
case "text":
|
|
@@ -404,7 +470,7 @@ function convertToOpenAIChatMessages({
|
|
|
404
470
|
contentValue = output.value;
|
|
405
471
|
break;
|
|
406
472
|
case "execution-denied":
|
|
407
|
-
contentValue = (
|
|
473
|
+
contentValue = (_b = output.reason) != null ? _b : "Tool call execution denied.";
|
|
408
474
|
break;
|
|
409
475
|
case "content":
|
|
410
476
|
case "json":
|
|
@@ -415,7 +481,13 @@ function convertToOpenAIChatMessages({
|
|
|
415
481
|
messages.push({
|
|
416
482
|
role: "tool",
|
|
417
483
|
tool_call_id: toolResponse.toolCallId,
|
|
418
|
-
content: contentValue
|
|
484
|
+
content: promptCacheBreakpoint == null ? contentValue : [
|
|
485
|
+
{
|
|
486
|
+
type: "text",
|
|
487
|
+
text: contentValue,
|
|
488
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
489
|
+
}
|
|
490
|
+
]
|
|
419
491
|
});
|
|
420
492
|
}
|
|
421
493
|
break;
|
|
@@ -521,7 +593,8 @@ var openaiChatResponseSchema = lazySchema(
|
|
|
521
593
|
completion_tokens: z2.number().nullish(),
|
|
522
594
|
total_tokens: z2.number().nullish(),
|
|
523
595
|
prompt_tokens_details: z2.object({
|
|
524
|
-
cached_tokens: z2.number().nullish()
|
|
596
|
+
cached_tokens: z2.number().nullish(),
|
|
597
|
+
cache_write_tokens: z2.number().nullish()
|
|
525
598
|
}).nullish(),
|
|
526
599
|
completion_tokens_details: z2.object({
|
|
527
600
|
reasoning_tokens: z2.number().nullish(),
|
|
@@ -590,7 +663,8 @@ var openaiChatChunkSchema = lazySchema(
|
|
|
590
663
|
completion_tokens: z2.number().nullish(),
|
|
591
664
|
total_tokens: z2.number().nullish(),
|
|
592
665
|
prompt_tokens_details: z2.object({
|
|
593
|
-
cached_tokens: z2.number().nullish()
|
|
666
|
+
cached_tokens: z2.number().nullish(),
|
|
667
|
+
cache_write_tokens: z2.number().nullish()
|
|
594
668
|
}).nullish(),
|
|
595
669
|
completion_tokens_details: z2.object({
|
|
596
670
|
reasoning_tokens: z2.number().nullish(),
|
|
@@ -642,7 +716,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
642
716
|
/**
|
|
643
717
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
644
718
|
*/
|
|
645
|
-
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
|
|
719
|
+
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
646
720
|
/**
|
|
647
721
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
648
722
|
*/
|
|
@@ -686,11 +760,22 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
686
760
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
687
761
|
*/
|
|
688
762
|
promptCacheKey: z3.string().optional(),
|
|
763
|
+
/**
|
|
764
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
765
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
766
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
767
|
+
*/
|
|
768
|
+
promptCacheOptions: z3.object({
|
|
769
|
+
mode: z3.enum(["implicit", "explicit"]).optional(),
|
|
770
|
+
ttl: z3.literal("30m").optional()
|
|
771
|
+
}).optional(),
|
|
689
772
|
/**
|
|
690
773
|
* The retention policy for the prompt cache.
|
|
691
774
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
692
775
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
693
|
-
*
|
|
776
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
777
|
+
*
|
|
778
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
694
779
|
*
|
|
695
780
|
* @default 'in_memory'
|
|
696
781
|
*/
|
|
@@ -885,6 +970,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
|
|
|
885
970
|
reasoning_effort: resolvedReasoningEffort,
|
|
886
971
|
service_tier: openaiOptions.serviceTier,
|
|
887
972
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
973
|
+
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
888
974
|
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
889
975
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
890
976
|
// messages:
|
|
@@ -2902,7 +2988,7 @@ import {
|
|
|
2902
2988
|
|
|
2903
2989
|
// src/responses/convert-openai-responses-usage.ts
|
|
2904
2990
|
function convertOpenAIResponsesUsage(usage) {
|
|
2905
|
-
var _a, _b, _c, _d;
|
|
2991
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2906
2992
|
if (usage == null) {
|
|
2907
2993
|
return {
|
|
2908
2994
|
inputTokens: {
|
|
@@ -2922,13 +3008,14 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2922
3008
|
const inputTokens = usage.input_tokens;
|
|
2923
3009
|
const outputTokens = usage.output_tokens;
|
|
2924
3010
|
const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
|
|
2925
|
-
const
|
|
3011
|
+
const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
|
|
3012
|
+
const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
|
|
2926
3013
|
return {
|
|
2927
3014
|
inputTokens: {
|
|
2928
3015
|
total: inputTokens,
|
|
2929
|
-
noCache: inputTokens - cachedTokens,
|
|
3016
|
+
noCache: inputTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
2930
3017
|
cacheRead: cachedTokens,
|
|
2931
|
-
cacheWrite:
|
|
3018
|
+
cacheWrite: cacheWriteTokens
|
|
2932
3019
|
},
|
|
2933
3020
|
outputTokens: {
|
|
2934
3021
|
total: outputTokens,
|
|
@@ -3173,6 +3260,10 @@ var toolSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
|
3173
3260
|
function serializeToolCallArguments2(input) {
|
|
3174
3261
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
3175
3262
|
}
|
|
3263
|
+
function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
|
|
3264
|
+
var _a;
|
|
3265
|
+
return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
3266
|
+
}
|
|
3176
3267
|
function isFileId(data, prefixes) {
|
|
3177
3268
|
if (!prefixes) return false;
|
|
3178
3269
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -3196,16 +3287,42 @@ async function convertToOpenAIResponsesInput({
|
|
|
3196
3287
|
let input = [];
|
|
3197
3288
|
const warnings = [];
|
|
3198
3289
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
3199
|
-
for (const { role, content } of prompt) {
|
|
3290
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
3200
3291
|
switch (role) {
|
|
3201
3292
|
case "system": {
|
|
3202
3293
|
switch (systemMessageMode) {
|
|
3203
3294
|
case "system": {
|
|
3204
|
-
|
|
3295
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3296
|
+
providerOptions,
|
|
3297
|
+
providerOptionsName
|
|
3298
|
+
);
|
|
3299
|
+
input.push({
|
|
3300
|
+
role: "system",
|
|
3301
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
3302
|
+
{
|
|
3303
|
+
type: "input_text",
|
|
3304
|
+
text: content,
|
|
3305
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3306
|
+
}
|
|
3307
|
+
]
|
|
3308
|
+
});
|
|
3205
3309
|
break;
|
|
3206
3310
|
}
|
|
3207
3311
|
case "developer": {
|
|
3208
|
-
|
|
3312
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3313
|
+
providerOptions,
|
|
3314
|
+
providerOptionsName
|
|
3315
|
+
);
|
|
3316
|
+
input.push({
|
|
3317
|
+
role: "developer",
|
|
3318
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
3319
|
+
{
|
|
3320
|
+
type: "input_text",
|
|
3321
|
+
text: content,
|
|
3322
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3323
|
+
}
|
|
3324
|
+
]
|
|
3325
|
+
});
|
|
3209
3326
|
break;
|
|
3210
3327
|
}
|
|
3211
3328
|
case "remove": {
|
|
@@ -3231,9 +3348,23 @@ async function convertToOpenAIResponsesInput({
|
|
|
3231
3348
|
var _a2, _b2, _c2, _d2, _e2;
|
|
3232
3349
|
switch (part.type) {
|
|
3233
3350
|
case "text": {
|
|
3234
|
-
|
|
3351
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3352
|
+
part.providerOptions,
|
|
3353
|
+
providerOptionsName
|
|
3354
|
+
);
|
|
3355
|
+
return {
|
|
3356
|
+
type: "input_text",
|
|
3357
|
+
text: part.text,
|
|
3358
|
+
...promptCacheBreakpoint != null && {
|
|
3359
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3360
|
+
}
|
|
3361
|
+
};
|
|
3235
3362
|
}
|
|
3236
3363
|
case "file": {
|
|
3364
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3365
|
+
part.providerOptions,
|
|
3366
|
+
providerOptionsName
|
|
3367
|
+
);
|
|
3237
3368
|
switch (part.data.type) {
|
|
3238
3369
|
case "reference": {
|
|
3239
3370
|
const fileId = resolveProviderReference2({
|
|
@@ -3244,12 +3375,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
3244
3375
|
return {
|
|
3245
3376
|
type: "input_image",
|
|
3246
3377
|
file_id: fileId,
|
|
3247
|
-
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3378
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3379
|
+
...promptCacheBreakpoint != null && {
|
|
3380
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3381
|
+
}
|
|
3248
3382
|
};
|
|
3249
3383
|
}
|
|
3250
3384
|
return {
|
|
3251
3385
|
type: "input_file",
|
|
3252
|
-
file_id: fileId
|
|
3386
|
+
file_id: fileId,
|
|
3387
|
+
...promptCacheBreakpoint != null && {
|
|
3388
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3389
|
+
}
|
|
3253
3390
|
};
|
|
3254
3391
|
}
|
|
3255
3392
|
case "text": {
|
|
@@ -3266,13 +3403,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3266
3403
|
...part.data.type === "url" ? { image_url: part.data.url.toString() } : typeof part.data.data === "string" && isFileId(part.data.data, fileIdPrefixes) ? { file_id: part.data.data } : {
|
|
3267
3404
|
image_url: `data:${resolveFullMediaType2({ part })};base64,${convertToBase643(part.data.data)}`
|
|
3268
3405
|
},
|
|
3269
|
-
detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3406
|
+
detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3407
|
+
...promptCacheBreakpoint != null && {
|
|
3408
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3409
|
+
}
|
|
3270
3410
|
};
|
|
3271
3411
|
} else {
|
|
3272
3412
|
if (part.data.type === "url") {
|
|
3273
3413
|
return {
|
|
3274
3414
|
type: "input_file",
|
|
3275
|
-
file_url: part.data.url.toString()
|
|
3415
|
+
file_url: part.data.url.toString(),
|
|
3416
|
+
...promptCacheBreakpoint != null && {
|
|
3417
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3418
|
+
}
|
|
3276
3419
|
};
|
|
3277
3420
|
}
|
|
3278
3421
|
const fullMediaType = resolveFullMediaType2({ part });
|
|
@@ -3286,6 +3429,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3286
3429
|
...typeof part.data.data === "string" && isFileId(part.data.data, fileIdPrefixes) ? { file_id: part.data.data } : {
|
|
3287
3430
|
filename: (_e2 = part.filename) != null ? _e2 : fullMediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
3288
3431
|
file_data: `data:${fullMediaType};base64,${convertToBase643(part.data.data)}`
|
|
3432
|
+
},
|
|
3433
|
+
...promptCacheBreakpoint != null && {
|
|
3434
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3289
3435
|
}
|
|
3290
3436
|
};
|
|
3291
3437
|
}
|
|
@@ -3302,9 +3448,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3302
3448
|
for (const part of content) {
|
|
3303
3449
|
switch (part.type) {
|
|
3304
3450
|
case "text": {
|
|
3305
|
-
const
|
|
3306
|
-
const id =
|
|
3307
|
-
const phase =
|
|
3451
|
+
const providerOptions2 = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
|
|
3452
|
+
const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3453
|
+
const phase = providerOptions2 == null ? void 0 : providerOptions2.phase;
|
|
3308
3454
|
if (hasConversation && id != null) {
|
|
3309
3455
|
break;
|
|
3310
3456
|
}
|
|
@@ -3501,12 +3647,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
3501
3647
|
break;
|
|
3502
3648
|
}
|
|
3503
3649
|
case "reasoning": {
|
|
3504
|
-
const
|
|
3650
|
+
const providerOptions2 = await parseProviderOptions7({
|
|
3505
3651
|
provider: providerOptionsName,
|
|
3506
3652
|
providerOptions: part.providerOptions,
|
|
3507
3653
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
3508
3654
|
});
|
|
3509
|
-
const reasoningId =
|
|
3655
|
+
const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3510
3656
|
if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
|
|
3511
3657
|
break;
|
|
3512
3658
|
}
|
|
@@ -3538,19 +3684,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3538
3684
|
reasoningMessages[reasoningId] = {
|
|
3539
3685
|
type: "reasoning",
|
|
3540
3686
|
id: reasoningId,
|
|
3541
|
-
encrypted_content:
|
|
3687
|
+
encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
|
|
3542
3688
|
summary: summaryParts
|
|
3543
3689
|
};
|
|
3544
3690
|
input.push(reasoningMessages[reasoningId]);
|
|
3545
3691
|
} else {
|
|
3546
3692
|
reasoningMessage.summary.push(...summaryParts);
|
|
3547
|
-
if ((
|
|
3548
|
-
reasoningMessage.encrypted_content =
|
|
3693
|
+
if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
|
|
3694
|
+
reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
|
|
3549
3695
|
}
|
|
3550
3696
|
}
|
|
3551
3697
|
}
|
|
3552
3698
|
} else {
|
|
3553
|
-
const encryptedContent =
|
|
3699
|
+
const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent;
|
|
3554
3700
|
if (encryptedContent != null) {
|
|
3555
3701
|
const summaryParts = [];
|
|
3556
3702
|
if (part.text.length > 0) {
|
|
@@ -3575,8 +3721,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
3575
3721
|
}
|
|
3576
3722
|
case "custom": {
|
|
3577
3723
|
if (part.kind === "openai.compaction") {
|
|
3578
|
-
const
|
|
3579
|
-
const id =
|
|
3724
|
+
const providerOptions2 = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName];
|
|
3725
|
+
const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3580
3726
|
if (hasConversation && id != null) {
|
|
3581
3727
|
break;
|
|
3582
3728
|
}
|
|
@@ -3584,7 +3730,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3584
3730
|
input.push({ type: "item_reference", id });
|
|
3585
3731
|
break;
|
|
3586
3732
|
}
|
|
3587
|
-
const encryptedContent =
|
|
3733
|
+
const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.encryptedContent;
|
|
3588
3734
|
if (id != null) {
|
|
3589
3735
|
input.push({
|
|
3590
3736
|
type: "compaction",
|
|
@@ -3705,9 +3851,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3705
3851
|
case "content":
|
|
3706
3852
|
outputValue = output.value.map((item) => {
|
|
3707
3853
|
var _a2, _b2, _c2;
|
|
3854
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3855
|
+
item.providerOptions,
|
|
3856
|
+
providerOptionsName
|
|
3857
|
+
);
|
|
3708
3858
|
switch (item.type) {
|
|
3709
3859
|
case "text":
|
|
3710
|
-
return {
|
|
3860
|
+
return {
|
|
3861
|
+
type: "input_text",
|
|
3862
|
+
text: item.text,
|
|
3863
|
+
...promptCacheBreakpoint != null && {
|
|
3864
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3711
3867
|
case "file": {
|
|
3712
3868
|
const topLevel = getTopLevelMediaType2(item.mediaType);
|
|
3713
3869
|
const imageDetail = (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail;
|
|
@@ -3719,13 +3875,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3719
3875
|
return {
|
|
3720
3876
|
type: "input_image",
|
|
3721
3877
|
image_url: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
|
|
3722
|
-
detail: imageDetail
|
|
3878
|
+
detail: imageDetail,
|
|
3879
|
+
...promptCacheBreakpoint != null && {
|
|
3880
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3881
|
+
}
|
|
3723
3882
|
};
|
|
3724
3883
|
}
|
|
3725
3884
|
return {
|
|
3726
3885
|
type: "input_file",
|
|
3727
3886
|
filename: (_c2 = item.filename) != null ? _c2 : "data",
|
|
3728
|
-
file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}
|
|
3887
|
+
file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
|
|
3888
|
+
...promptCacheBreakpoint != null && {
|
|
3889
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3890
|
+
}
|
|
3729
3891
|
};
|
|
3730
3892
|
}
|
|
3731
3893
|
if (item.data.type === "url") {
|
|
@@ -3733,12 +3895,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
3733
3895
|
return {
|
|
3734
3896
|
type: "input_image",
|
|
3735
3897
|
image_url: item.data.url.toString(),
|
|
3736
|
-
detail: imageDetail
|
|
3898
|
+
detail: imageDetail,
|
|
3899
|
+
...promptCacheBreakpoint != null && {
|
|
3900
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3901
|
+
}
|
|
3737
3902
|
};
|
|
3738
3903
|
}
|
|
3739
3904
|
return {
|
|
3740
3905
|
type: "input_file",
|
|
3741
|
-
file_url: item.data.url.toString()
|
|
3906
|
+
file_url: item.data.url.toString(),
|
|
3907
|
+
...promptCacheBreakpoint != null && {
|
|
3908
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3909
|
+
}
|
|
3742
3910
|
};
|
|
3743
3911
|
}
|
|
3744
3912
|
warnings.push({
|
|
@@ -3782,9 +3950,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3782
3950
|
case "content":
|
|
3783
3951
|
contentValue = output.value.map((item) => {
|
|
3784
3952
|
var _a2, _b2, _c2;
|
|
3953
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3954
|
+
item.providerOptions,
|
|
3955
|
+
providerOptionsName
|
|
3956
|
+
);
|
|
3785
3957
|
switch (item.type) {
|
|
3786
3958
|
case "text": {
|
|
3787
|
-
return {
|
|
3959
|
+
return {
|
|
3960
|
+
type: "input_text",
|
|
3961
|
+
text: item.text,
|
|
3962
|
+
...promptCacheBreakpoint != null && {
|
|
3963
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3788
3966
|
}
|
|
3789
3967
|
case "file": {
|
|
3790
3968
|
const topLevel = getTopLevelMediaType2(item.mediaType);
|
|
@@ -3797,13 +3975,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3797
3975
|
return {
|
|
3798
3976
|
type: "input_image",
|
|
3799
3977
|
image_url: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
|
|
3800
|
-
detail: imageDetail
|
|
3978
|
+
detail: imageDetail,
|
|
3979
|
+
...promptCacheBreakpoint != null && {
|
|
3980
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3981
|
+
}
|
|
3801
3982
|
};
|
|
3802
3983
|
}
|
|
3803
3984
|
return {
|
|
3804
3985
|
type: "input_file",
|
|
3805
3986
|
filename: (_c2 = item.filename) != null ? _c2 : "data",
|
|
3806
|
-
file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}
|
|
3987
|
+
file_data: `data:${fullMediaType};base64,${convertToBase643(item.data.data)}`,
|
|
3988
|
+
...promptCacheBreakpoint != null && {
|
|
3989
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3990
|
+
}
|
|
3807
3991
|
};
|
|
3808
3992
|
}
|
|
3809
3993
|
if (item.data.type === "url") {
|
|
@@ -3811,12 +3995,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
3811
3995
|
return {
|
|
3812
3996
|
type: "input_image",
|
|
3813
3997
|
image_url: item.data.url.toString(),
|
|
3814
|
-
detail: imageDetail
|
|
3998
|
+
detail: imageDetail,
|
|
3999
|
+
...promptCacheBreakpoint != null && {
|
|
4000
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4001
|
+
}
|
|
3815
4002
|
};
|
|
3816
4003
|
}
|
|
3817
4004
|
return {
|
|
3818
4005
|
type: "input_file",
|
|
3819
|
-
file_url: item.data.url.toString()
|
|
4006
|
+
file_url: item.data.url.toString(),
|
|
4007
|
+
...promptCacheBreakpoint != null && {
|
|
4008
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4009
|
+
}
|
|
3820
4010
|
};
|
|
3821
4011
|
}
|
|
3822
4012
|
warnings.push({
|
|
@@ -3947,6 +4137,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
3947
4137
|
input_tokens: z18.number(),
|
|
3948
4138
|
input_tokens_details: z18.object({
|
|
3949
4139
|
cached_tokens: z18.number().nullish(),
|
|
4140
|
+
cache_write_tokens: z18.number().nullish(),
|
|
3950
4141
|
orchestration_input_tokens: z18.number().nullish(),
|
|
3951
4142
|
orchestration_input_cached_tokens: z18.number().nullish()
|
|
3952
4143
|
}).nullish(),
|
|
@@ -3956,6 +4147,9 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
3956
4147
|
orchestration_output_tokens: z18.number().nullish()
|
|
3957
4148
|
}).nullish()
|
|
3958
4149
|
}),
|
|
4150
|
+
reasoning: z18.object({
|
|
4151
|
+
context: z18.string().nullish()
|
|
4152
|
+
}).nullish(),
|
|
3959
4153
|
service_tier: z18.string().nullish()
|
|
3960
4154
|
})
|
|
3961
4155
|
}),
|
|
@@ -3972,6 +4166,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
3972
4166
|
input_tokens: z18.number(),
|
|
3973
4167
|
input_tokens_details: z18.object({
|
|
3974
4168
|
cached_tokens: z18.number().nullish(),
|
|
4169
|
+
cache_write_tokens: z18.number().nullish(),
|
|
3975
4170
|
orchestration_input_tokens: z18.number().nullish(),
|
|
3976
4171
|
orchestration_input_cached_tokens: z18.number().nullish()
|
|
3977
4172
|
}).nullish(),
|
|
@@ -3981,6 +4176,9 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
3981
4176
|
orchestration_output_tokens: z18.number().nullish()
|
|
3982
4177
|
}).nullish()
|
|
3983
4178
|
}).nullish(),
|
|
4179
|
+
reasoning: z18.object({
|
|
4180
|
+
context: z18.string().nullish()
|
|
4181
|
+
}).nullish(),
|
|
3984
4182
|
service_tier: z18.string().nullish()
|
|
3985
4183
|
})
|
|
3986
4184
|
}),
|
|
@@ -4767,11 +4965,15 @@ var openaiResponsesResponseSchema = lazySchema16(
|
|
|
4767
4965
|
])
|
|
4768
4966
|
).optional(),
|
|
4769
4967
|
service_tier: z18.string().nullish(),
|
|
4968
|
+
reasoning: z18.object({
|
|
4969
|
+
context: z18.string().nullish()
|
|
4970
|
+
}).nullish(),
|
|
4770
4971
|
incomplete_details: z18.object({ reason: z18.string() }).nullish(),
|
|
4771
4972
|
usage: z18.object({
|
|
4772
4973
|
input_tokens: z18.number(),
|
|
4773
4974
|
input_tokens_details: z18.object({
|
|
4774
4975
|
cached_tokens: z18.number().nullish(),
|
|
4976
|
+
cache_write_tokens: z18.number().nullish(),
|
|
4775
4977
|
orchestration_input_tokens: z18.number().nullish(),
|
|
4776
4978
|
orchestration_input_cached_tokens: z18.number().nullish()
|
|
4777
4979
|
}).nullish(),
|
|
@@ -4929,11 +5131,22 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
|
|
|
4929
5131
|
* Sets a cache key to tie this prompt to cached prefixes for better caching performance.
|
|
4930
5132
|
*/
|
|
4931
5133
|
promptCacheKey: z19.string().nullish(),
|
|
5134
|
+
/**
|
|
5135
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
5136
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
5137
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
5138
|
+
*/
|
|
5139
|
+
promptCacheOptions: z19.object({
|
|
5140
|
+
mode: z19.enum(["implicit", "explicit"]).optional(),
|
|
5141
|
+
ttl: z19.literal("30m").optional()
|
|
5142
|
+
}).optional(),
|
|
4932
5143
|
/**
|
|
4933
5144
|
* The retention policy for the prompt cache.
|
|
4934
5145
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
4935
5146
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
4936
|
-
*
|
|
5147
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
5148
|
+
*
|
|
5149
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
4937
5150
|
*
|
|
4938
5151
|
* @default 'in_memory'
|
|
4939
5152
|
*/
|
|
@@ -4941,14 +5154,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
|
|
|
4941
5154
|
/**
|
|
4942
5155
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
4943
5156
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
4944
|
-
*
|
|
4945
|
-
*
|
|
4946
|
-
* The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
|
|
4947
|
-
* models. Also, the 'xhigh' type for `reasoningEffort` is only available for
|
|
4948
|
-
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
4949
|
-
* an error.
|
|
5157
|
+
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5158
|
+
* Supported values vary by model.
|
|
4950
5159
|
*/
|
|
4951
5160
|
reasoningEffort: z19.string().nullish(),
|
|
5161
|
+
/**
|
|
5162
|
+
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5163
|
+
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
5164
|
+
*/
|
|
5165
|
+
reasoningMode: z19.enum(["standard", "pro"]).optional(),
|
|
5166
|
+
/**
|
|
5167
|
+
* Controls which available reasoning items GPT-5.6 can use.
|
|
5168
|
+
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
5169
|
+
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
5170
|
+
*/
|
|
5171
|
+
reasoningContext: z19.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
4952
5172
|
/**
|
|
4953
5173
|
* Controls reasoning summary output from the model.
|
|
4954
5174
|
* Set to "auto" to automatically receive the richest level available,
|
|
@@ -5929,6 +6149,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5929
6149
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
5930
6150
|
include,
|
|
5931
6151
|
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
6152
|
+
prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
|
|
5932
6153
|
prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
|
|
5933
6154
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
5934
6155
|
top_logprobs: topLogprobs,
|
|
@@ -5941,13 +6162,19 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5941
6162
|
}))
|
|
5942
6163
|
},
|
|
5943
6164
|
// model-specific settings:
|
|
5944
|
-
...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null) && {
|
|
6165
|
+
...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5945
6166
|
reasoning: {
|
|
5946
6167
|
...resolvedReasoningEffort != null && {
|
|
5947
6168
|
effort: resolvedReasoningEffort
|
|
5948
6169
|
},
|
|
5949
6170
|
...resolvedReasoningSummary != null && {
|
|
5950
6171
|
summary: resolvedReasoningSummary
|
|
6172
|
+
},
|
|
6173
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
|
|
6174
|
+
mode: openaiOptions.reasoningMode
|
|
6175
|
+
},
|
|
6176
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
|
|
6177
|
+
context: openaiOptions.reasoningContext
|
|
5951
6178
|
}
|
|
5952
6179
|
}
|
|
5953
6180
|
}
|
|
@@ -5986,6 +6213,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5986
6213
|
details: "reasoningSummary is not supported for non-reasoning models"
|
|
5987
6214
|
});
|
|
5988
6215
|
}
|
|
6216
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
|
|
6217
|
+
warnings.push({
|
|
6218
|
+
type: "unsupported",
|
|
6219
|
+
feature: "reasoningMode",
|
|
6220
|
+
details: "reasoningMode is not supported for non-reasoning models"
|
|
6221
|
+
});
|
|
6222
|
+
}
|
|
6223
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
|
|
6224
|
+
warnings.push({
|
|
6225
|
+
type: "unsupported",
|
|
6226
|
+
feature: "reasoningContext",
|
|
6227
|
+
details: "reasoningContext is not supported for non-reasoning models"
|
|
6228
|
+
});
|
|
6229
|
+
}
|
|
5989
6230
|
}
|
|
5990
6231
|
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
|
|
5991
6232
|
warnings.push({
|
|
@@ -6022,7 +6263,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6022
6263
|
};
|
|
6023
6264
|
}
|
|
6024
6265
|
async doGenerate(options) {
|
|
6025
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
6266
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
6026
6267
|
const {
|
|
6027
6268
|
args: body,
|
|
6028
6269
|
warnings,
|
|
@@ -6485,7 +6726,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6485
6726
|
[providerOptionsName]: {
|
|
6486
6727
|
responseId: response.id,
|
|
6487
6728
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
6488
|
-
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {}
|
|
6729
|
+
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
|
|
6730
|
+
...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
|
|
6489
6731
|
}
|
|
6490
6732
|
};
|
|
6491
6733
|
const usage = response.usage;
|
|
@@ -6493,10 +6735,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6493
6735
|
content,
|
|
6494
6736
|
finishReason: {
|
|
6495
6737
|
unified: mapOpenAIResponseFinishReason({
|
|
6496
|
-
finishReason: (
|
|
6738
|
+
finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
|
|
6497
6739
|
hasFunctionCall
|
|
6498
6740
|
}),
|
|
6499
|
-
raw: (
|
|
6741
|
+
raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
|
|
6500
6742
|
},
|
|
6501
6743
|
usage: convertOpenAIResponsesUsage(usage),
|
|
6502
6744
|
request: { body },
|
|
@@ -6564,6 +6806,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6564
6806
|
let hasFunctionCall = false;
|
|
6565
6807
|
const activeReasoning = {};
|
|
6566
6808
|
let serviceTier;
|
|
6809
|
+
let reasoningContext;
|
|
6567
6810
|
const hostedToolSearchCallIds = [];
|
|
6568
6811
|
let encounteredStreamError = false;
|
|
6569
6812
|
const result = {
|
|
@@ -6573,7 +6816,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6573
6816
|
controller.enqueue({ type: "stream-start", warnings });
|
|
6574
6817
|
},
|
|
6575
6818
|
transform(chunk, controller) {
|
|
6576
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
|
|
6819
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
|
|
6577
6820
|
if (options.includeRawChunks) {
|
|
6578
6821
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
6579
6822
|
}
|
|
@@ -7327,8 +7570,11 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7327
7570
|
if (typeof value.response.service_tier === "string") {
|
|
7328
7571
|
serviceTier = value.response.service_tier;
|
|
7329
7572
|
}
|
|
7573
|
+
if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
|
|
7574
|
+
reasoningContext = value.response.reasoning.context;
|
|
7575
|
+
}
|
|
7330
7576
|
} else if (isResponseFailedChunk(value)) {
|
|
7331
|
-
const incompleteReason = (
|
|
7577
|
+
const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
|
|
7332
7578
|
finishReason = {
|
|
7333
7579
|
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
7334
7580
|
finishReason: incompleteReason,
|
|
@@ -7336,7 +7582,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7336
7582
|
}) : "error",
|
|
7337
7583
|
raw: incompleteReason != null ? incompleteReason : "error"
|
|
7338
7584
|
};
|
|
7339
|
-
usage = (
|
|
7585
|
+
usage = (_A = value.response.usage) != null ? _A : void 0;
|
|
7586
|
+
if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
|
|
7587
|
+
reasoningContext = value.response.reasoning.context;
|
|
7588
|
+
}
|
|
7340
7589
|
if (!encounteredStreamError && value.response.error != null) {
|
|
7341
7590
|
encounteredStreamError = true;
|
|
7342
7591
|
controller.enqueue({
|
|
@@ -7358,7 +7607,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7358
7607
|
controller.enqueue({
|
|
7359
7608
|
type: "source",
|
|
7360
7609
|
sourceType: "url",
|
|
7361
|
-
id: (
|
|
7610
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
|
|
7362
7611
|
url: value.annotation.url,
|
|
7363
7612
|
title: value.annotation.title
|
|
7364
7613
|
});
|
|
@@ -7366,7 +7615,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7366
7615
|
controller.enqueue({
|
|
7367
7616
|
type: "source",
|
|
7368
7617
|
sourceType: "document",
|
|
7369
|
-
id: (
|
|
7618
|
+
id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
|
|
7370
7619
|
mediaType: "text/plain",
|
|
7371
7620
|
title: value.annotation.filename,
|
|
7372
7621
|
filename: value.annotation.filename,
|
|
@@ -7382,7 +7631,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7382
7631
|
controller.enqueue({
|
|
7383
7632
|
type: "source",
|
|
7384
7633
|
sourceType: "document",
|
|
7385
|
-
id: (
|
|
7634
|
+
id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
|
|
7386
7635
|
mediaType: "text/plain",
|
|
7387
7636
|
title: value.annotation.filename,
|
|
7388
7637
|
filename: value.annotation.filename,
|
|
@@ -7398,7 +7647,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7398
7647
|
controller.enqueue({
|
|
7399
7648
|
type: "source",
|
|
7400
7649
|
sourceType: "document",
|
|
7401
|
-
id: (
|
|
7650
|
+
id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
|
|
7402
7651
|
mediaType: "application/octet-stream",
|
|
7403
7652
|
title: value.annotation.file_id,
|
|
7404
7653
|
filename: value.annotation.file_id,
|
|
@@ -7422,7 +7671,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7422
7671
|
[providerOptionsName]: {
|
|
7423
7672
|
responseId,
|
|
7424
7673
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
7425
|
-
...serviceTier !== void 0 ? { serviceTier } : {}
|
|
7674
|
+
...serviceTier !== void 0 ? { serviceTier } : {},
|
|
7675
|
+
...reasoningContext !== void 0 ? { reasoningContext } : {}
|
|
7426
7676
|
}
|
|
7427
7677
|
};
|
|
7428
7678
|
controller.enqueue({
|