@ai-sdk/openai 3.0.83 → 3.0.84
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.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +307 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +307 -66
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +14 -1
- package/dist/internal/index.d.ts +14 -1
- package/dist/internal/index.js +306 -65
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +306 -65
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +81 -31
- package/package.json +1 -1
- package/src/chat/convert-openai-chat-usage.ts +5 -2
- package/src/chat/convert-to-openai-chat-messages.ts +111 -7
- package/src/chat/openai-chat-api.ts +2 -0
- package/src/chat/openai-chat-language-model.ts +1 -0
- package/src/chat/openai-chat-options.ts +16 -2
- 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 +117 -6
- package/src/responses/openai-responses-api.ts +77 -11
- package/src/responses/openai-responses-language-model.ts +37 -1
- package/src/responses/openai-responses-options.ts +32 -7
- package/src/responses/openai-responses-provider-metadata.ts +1 -0
package/dist/internal/index.js
CHANGED
|
@@ -227,7 +227,7 @@ function isHttpErrorStatusCode(value) {
|
|
|
227
227
|
|
|
228
228
|
// src/chat/convert-openai-chat-usage.ts
|
|
229
229
|
function convertOpenAIChatUsage(usage) {
|
|
230
|
-
var _a, _b, _c, _d, _e, _f;
|
|
230
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
231
231
|
if (usage == null) {
|
|
232
232
|
return {
|
|
233
233
|
inputTokens: {
|
|
@@ -247,13 +247,14 @@ function convertOpenAIChatUsage(usage) {
|
|
|
247
247
|
const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
|
|
248
248
|
const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
|
|
249
249
|
const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
|
|
250
|
-
const
|
|
250
|
+
const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
|
|
251
|
+
const reasoningTokens = (_h = (_g = usage.completion_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : 0;
|
|
251
252
|
return {
|
|
252
253
|
inputTokens: {
|
|
253
254
|
total: promptTokens,
|
|
254
|
-
noCache: promptTokens - cachedTokens,
|
|
255
|
+
noCache: promptTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
255
256
|
cacheRead: cachedTokens,
|
|
256
|
-
cacheWrite:
|
|
257
|
+
cacheWrite: cacheWriteTokens
|
|
257
258
|
},
|
|
258
259
|
outputTokens: {
|
|
259
260
|
total: completionTokens,
|
|
@@ -270,23 +271,47 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
|
270
271
|
function serializeToolCallArguments(input) {
|
|
271
272
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
272
273
|
}
|
|
274
|
+
function getPromptCacheBreakpoint(providerOptions) {
|
|
275
|
+
var _a;
|
|
276
|
+
return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
277
|
+
}
|
|
273
278
|
function convertToOpenAIChatMessages({
|
|
274
279
|
prompt,
|
|
275
280
|
systemMessageMode = "system"
|
|
276
281
|
}) {
|
|
277
|
-
var _a;
|
|
282
|
+
var _a, _b;
|
|
278
283
|
const messages = [];
|
|
279
284
|
const warnings = [];
|
|
280
|
-
for (const { role, content } of prompt) {
|
|
285
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
281
286
|
switch (role) {
|
|
282
287
|
case "system": {
|
|
283
288
|
switch (systemMessageMode) {
|
|
284
289
|
case "system": {
|
|
285
|
-
|
|
290
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
291
|
+
messages.push({
|
|
292
|
+
role: "system",
|
|
293
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
294
|
+
{
|
|
295
|
+
type: "text",
|
|
296
|
+
text: content,
|
|
297
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
});
|
|
286
301
|
break;
|
|
287
302
|
}
|
|
288
303
|
case "developer": {
|
|
289
|
-
|
|
304
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(providerOptions);
|
|
305
|
+
messages.push({
|
|
306
|
+
role: "developer",
|
|
307
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
308
|
+
{
|
|
309
|
+
type: "text",
|
|
310
|
+
text: content,
|
|
311
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
312
|
+
}
|
|
313
|
+
]
|
|
314
|
+
});
|
|
290
315
|
break;
|
|
291
316
|
}
|
|
292
317
|
case "remove": {
|
|
@@ -306,19 +331,31 @@ function convertToOpenAIChatMessages({
|
|
|
306
331
|
break;
|
|
307
332
|
}
|
|
308
333
|
case "user": {
|
|
309
|
-
if (content.length === 1 && content[0].type === "text") {
|
|
334
|
+
if (content.length === 1 && content[0].type === "text" && getPromptCacheBreakpoint(content[0].providerOptions) == null) {
|
|
310
335
|
messages.push({ role: "user", content: content[0].text });
|
|
311
336
|
break;
|
|
312
337
|
}
|
|
313
338
|
messages.push({
|
|
314
339
|
role: "user",
|
|
315
340
|
content: content.map((part, index) => {
|
|
316
|
-
var _a2,
|
|
341
|
+
var _a2, _b2, _c;
|
|
317
342
|
switch (part.type) {
|
|
318
343
|
case "text": {
|
|
319
|
-
|
|
344
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
345
|
+
part.providerOptions
|
|
346
|
+
);
|
|
347
|
+
return {
|
|
348
|
+
type: "text",
|
|
349
|
+
text: part.text,
|
|
350
|
+
...promptCacheBreakpoint != null && {
|
|
351
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
352
|
+
}
|
|
353
|
+
};
|
|
320
354
|
}
|
|
321
355
|
case "file": {
|
|
356
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
357
|
+
part.providerOptions
|
|
358
|
+
);
|
|
322
359
|
if (part.mediaType.startsWith("image/")) {
|
|
323
360
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
324
361
|
return {
|
|
@@ -326,7 +363,10 @@ function convertToOpenAIChatMessages({
|
|
|
326
363
|
image_url: {
|
|
327
364
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`,
|
|
328
365
|
// OpenAI specific extension: image detail
|
|
329
|
-
detail: (
|
|
366
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
367
|
+
},
|
|
368
|
+
...promptCacheBreakpoint != null && {
|
|
369
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
330
370
|
}
|
|
331
371
|
};
|
|
332
372
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
@@ -342,6 +382,9 @@ function convertToOpenAIChatMessages({
|
|
|
342
382
|
input_audio: {
|
|
343
383
|
data: (0, import_provider_utils2.convertToBase64)(part.data),
|
|
344
384
|
format: "wav"
|
|
385
|
+
},
|
|
386
|
+
...promptCacheBreakpoint != null && {
|
|
387
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
345
388
|
}
|
|
346
389
|
};
|
|
347
390
|
}
|
|
@@ -352,6 +395,9 @@ function convertToOpenAIChatMessages({
|
|
|
352
395
|
input_audio: {
|
|
353
396
|
data: (0, import_provider_utils2.convertToBase64)(part.data),
|
|
354
397
|
format: "mp3"
|
|
398
|
+
},
|
|
399
|
+
...promptCacheBreakpoint != null && {
|
|
400
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
355
401
|
}
|
|
356
402
|
};
|
|
357
403
|
}
|
|
@@ -372,6 +418,9 @@ function convertToOpenAIChatMessages({
|
|
|
372
418
|
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
373
419
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
374
420
|
file_data: `data:application/pdf;base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`
|
|
421
|
+
},
|
|
422
|
+
...promptCacheBreakpoint != null && {
|
|
423
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
375
424
|
}
|
|
376
425
|
};
|
|
377
426
|
} else {
|
|
@@ -387,11 +436,24 @@ function convertToOpenAIChatMessages({
|
|
|
387
436
|
}
|
|
388
437
|
case "assistant": {
|
|
389
438
|
let text = "";
|
|
439
|
+
const textParts = [];
|
|
440
|
+
let hasPromptCacheBreakpoint = false;
|
|
390
441
|
const toolCalls = [];
|
|
391
442
|
for (const part of content) {
|
|
392
443
|
switch (part.type) {
|
|
393
444
|
case "text": {
|
|
445
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint(
|
|
446
|
+
part.providerOptions
|
|
447
|
+
);
|
|
394
448
|
text += part.text;
|
|
449
|
+
textParts.push({
|
|
450
|
+
type: "text",
|
|
451
|
+
text: part.text,
|
|
452
|
+
...promptCacheBreakpoint != null && {
|
|
453
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
hasPromptCacheBreakpoint || (hasPromptCacheBreakpoint = promptCacheBreakpoint != null);
|
|
395
457
|
break;
|
|
396
458
|
}
|
|
397
459
|
case "tool-call": {
|
|
@@ -409,7 +471,7 @@ function convertToOpenAIChatMessages({
|
|
|
409
471
|
}
|
|
410
472
|
messages.push({
|
|
411
473
|
role: "assistant",
|
|
412
|
-
content: toolCalls.length > 0 ? text || null : text,
|
|
474
|
+
content: hasPromptCacheBreakpoint ? textParts : toolCalls.length > 0 ? text || null : text,
|
|
413
475
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
414
476
|
});
|
|
415
477
|
break;
|
|
@@ -420,6 +482,7 @@ function convertToOpenAIChatMessages({
|
|
|
420
482
|
continue;
|
|
421
483
|
}
|
|
422
484
|
const output = toolResponse.output;
|
|
485
|
+
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);
|
|
423
486
|
let contentValue;
|
|
424
487
|
switch (output.type) {
|
|
425
488
|
case "text":
|
|
@@ -427,7 +490,7 @@ function convertToOpenAIChatMessages({
|
|
|
427
490
|
contentValue = output.value;
|
|
428
491
|
break;
|
|
429
492
|
case "execution-denied":
|
|
430
|
-
contentValue = (
|
|
493
|
+
contentValue = (_b = output.reason) != null ? _b : "Tool call execution denied.";
|
|
431
494
|
break;
|
|
432
495
|
case "content":
|
|
433
496
|
case "json":
|
|
@@ -438,7 +501,13 @@ function convertToOpenAIChatMessages({
|
|
|
438
501
|
messages.push({
|
|
439
502
|
role: "tool",
|
|
440
503
|
tool_call_id: toolResponse.toolCallId,
|
|
441
|
-
content: contentValue
|
|
504
|
+
content: promptCacheBreakpoint == null ? contentValue : [
|
|
505
|
+
{
|
|
506
|
+
type: "text",
|
|
507
|
+
text: contentValue,
|
|
508
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
509
|
+
}
|
|
510
|
+
]
|
|
442
511
|
});
|
|
443
512
|
}
|
|
444
513
|
break;
|
|
@@ -541,7 +610,8 @@ var openaiChatResponseSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
541
610
|
completion_tokens: import_v42.z.number().nullish(),
|
|
542
611
|
total_tokens: import_v42.z.number().nullish(),
|
|
543
612
|
prompt_tokens_details: import_v42.z.object({
|
|
544
|
-
cached_tokens: import_v42.z.number().nullish()
|
|
613
|
+
cached_tokens: import_v42.z.number().nullish(),
|
|
614
|
+
cache_write_tokens: import_v42.z.number().nullish()
|
|
545
615
|
}).nullish(),
|
|
546
616
|
completion_tokens_details: import_v42.z.object({
|
|
547
617
|
reasoning_tokens: import_v42.z.number().nullish(),
|
|
@@ -610,7 +680,8 @@ var openaiChatChunkSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
610
680
|
completion_tokens: import_v42.z.number().nullish(),
|
|
611
681
|
total_tokens: import_v42.z.number().nullish(),
|
|
612
682
|
prompt_tokens_details: import_v42.z.object({
|
|
613
|
-
cached_tokens: import_v42.z.number().nullish()
|
|
683
|
+
cached_tokens: import_v42.z.number().nullish(),
|
|
684
|
+
cache_write_tokens: import_v42.z.number().nullish()
|
|
614
685
|
}).nullish(),
|
|
615
686
|
completion_tokens_details: import_v42.z.object({
|
|
616
687
|
reasoning_tokens: import_v42.z.number().nullish(),
|
|
@@ -659,7 +730,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
659
730
|
/**
|
|
660
731
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
661
732
|
*/
|
|
662
|
-
reasoningEffort: import_v43.z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
|
|
733
|
+
reasoningEffort: import_v43.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
663
734
|
/**
|
|
664
735
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
665
736
|
*/
|
|
@@ -703,11 +774,22 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
703
774
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
704
775
|
*/
|
|
705
776
|
promptCacheKey: import_v43.z.string().optional(),
|
|
777
|
+
/**
|
|
778
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
779
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
780
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
781
|
+
*/
|
|
782
|
+
promptCacheOptions: import_v43.z.object({
|
|
783
|
+
mode: import_v43.z.enum(["implicit", "explicit"]).optional(),
|
|
784
|
+
ttl: import_v43.z.literal("30m").optional()
|
|
785
|
+
}).optional(),
|
|
706
786
|
/**
|
|
707
787
|
* The retention policy for the prompt cache.
|
|
708
788
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
709
789
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
710
|
-
*
|
|
790
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
791
|
+
*
|
|
792
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
711
793
|
*
|
|
712
794
|
* @default 'in_memory'
|
|
713
795
|
*/
|
|
@@ -889,6 +971,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
889
971
|
reasoning_effort: openaiOptions.reasoningEffort,
|
|
890
972
|
service_tier: openaiOptions.serviceTier,
|
|
891
973
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
974
|
+
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
892
975
|
prompt_cache_retention: openaiOptions.promptCacheRetention,
|
|
893
976
|
safety_identifier: openaiOptions.safetyIdentifier,
|
|
894
977
|
// messages:
|
|
@@ -2581,7 +2664,7 @@ var import_provider_utils35 = require("@ai-sdk/provider-utils");
|
|
|
2581
2664
|
|
|
2582
2665
|
// src/responses/convert-openai-responses-usage.ts
|
|
2583
2666
|
function convertOpenAIResponsesUsage(usage) {
|
|
2584
|
-
var _a, _b, _c, _d;
|
|
2667
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2585
2668
|
if (usage == null) {
|
|
2586
2669
|
return {
|
|
2587
2670
|
inputTokens: {
|
|
@@ -2601,13 +2684,14 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2601
2684
|
const inputTokens = usage.input_tokens;
|
|
2602
2685
|
const outputTokens = usage.output_tokens;
|
|
2603
2686
|
const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
|
|
2604
|
-
const
|
|
2687
|
+
const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
|
|
2688
|
+
const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
|
|
2605
2689
|
return {
|
|
2606
2690
|
inputTokens: {
|
|
2607
2691
|
total: inputTokens,
|
|
2608
|
-
noCache: inputTokens - cachedTokens,
|
|
2692
|
+
noCache: inputTokens - cachedTokens - (cacheWriteTokens != null ? cacheWriteTokens : 0),
|
|
2609
2693
|
cacheRead: cachedTokens,
|
|
2610
|
-
cacheWrite:
|
|
2694
|
+
cacheWrite: cacheWriteTokens
|
|
2611
2695
|
},
|
|
2612
2696
|
outputTokens: {
|
|
2613
2697
|
total: outputTokens,
|
|
@@ -2825,6 +2909,10 @@ var toolSearchToolFactory = (0, import_provider_utils23.createProviderToolFactor
|
|
|
2825
2909
|
function serializeToolCallArguments2(input) {
|
|
2826
2910
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
2827
2911
|
}
|
|
2912
|
+
function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
|
|
2913
|
+
var _a;
|
|
2914
|
+
return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
2915
|
+
}
|
|
2828
2916
|
function isFileId(data, prefixes) {
|
|
2829
2917
|
if (!prefixes) return false;
|
|
2830
2918
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2848,16 +2936,42 @@ async function convertToOpenAIResponsesInput({
|
|
|
2848
2936
|
let input = [];
|
|
2849
2937
|
const warnings = [];
|
|
2850
2938
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2851
|
-
for (const { role, content } of prompt) {
|
|
2939
|
+
for (const { role, content, providerOptions } of prompt) {
|
|
2852
2940
|
switch (role) {
|
|
2853
2941
|
case "system": {
|
|
2854
2942
|
switch (systemMessageMode) {
|
|
2855
2943
|
case "system": {
|
|
2856
|
-
|
|
2944
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
2945
|
+
providerOptions,
|
|
2946
|
+
providerOptionsName
|
|
2947
|
+
);
|
|
2948
|
+
input.push({
|
|
2949
|
+
role: "system",
|
|
2950
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
2951
|
+
{
|
|
2952
|
+
type: "input_text",
|
|
2953
|
+
text: content,
|
|
2954
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
2955
|
+
}
|
|
2956
|
+
]
|
|
2957
|
+
});
|
|
2857
2958
|
break;
|
|
2858
2959
|
}
|
|
2859
2960
|
case "developer": {
|
|
2860
|
-
|
|
2961
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
2962
|
+
providerOptions,
|
|
2963
|
+
providerOptionsName
|
|
2964
|
+
);
|
|
2965
|
+
input.push({
|
|
2966
|
+
role: "developer",
|
|
2967
|
+
content: promptCacheBreakpoint == null ? content : [
|
|
2968
|
+
{
|
|
2969
|
+
type: "input_text",
|
|
2970
|
+
text: content,
|
|
2971
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
2972
|
+
}
|
|
2973
|
+
]
|
|
2974
|
+
});
|
|
2861
2975
|
break;
|
|
2862
2976
|
}
|
|
2863
2977
|
case "remove": {
|
|
@@ -2883,9 +2997,23 @@ async function convertToOpenAIResponsesInput({
|
|
|
2883
2997
|
var _a2, _b2, _c2;
|
|
2884
2998
|
switch (part.type) {
|
|
2885
2999
|
case "text": {
|
|
2886
|
-
|
|
3000
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3001
|
+
part.providerOptions,
|
|
3002
|
+
providerOptionsName
|
|
3003
|
+
);
|
|
3004
|
+
return {
|
|
3005
|
+
type: "input_text",
|
|
3006
|
+
text: part.text,
|
|
3007
|
+
...promptCacheBreakpoint != null && {
|
|
3008
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3009
|
+
}
|
|
3010
|
+
};
|
|
2887
3011
|
}
|
|
2888
3012
|
case "file": {
|
|
3013
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3014
|
+
part.providerOptions,
|
|
3015
|
+
providerOptionsName
|
|
3016
|
+
);
|
|
2889
3017
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2890
3018
|
if (mediaType.startsWith("image/")) {
|
|
2891
3019
|
return {
|
|
@@ -2893,13 +3021,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
2893
3021
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2894
3022
|
image_url: `data:${mediaType};base64,${(0, import_provider_utils24.convertToBase64)(part.data)}`
|
|
2895
3023
|
},
|
|
2896
|
-
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3024
|
+
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3025
|
+
...promptCacheBreakpoint != null && {
|
|
3026
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3027
|
+
}
|
|
2897
3028
|
};
|
|
2898
3029
|
}
|
|
2899
3030
|
if (part.data instanceof URL) {
|
|
2900
3031
|
return {
|
|
2901
3032
|
type: "input_file",
|
|
2902
|
-
file_url: part.data.toString()
|
|
3033
|
+
file_url: part.data.toString(),
|
|
3034
|
+
...promptCacheBreakpoint != null && {
|
|
3035
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3036
|
+
}
|
|
2903
3037
|
};
|
|
2904
3038
|
}
|
|
2905
3039
|
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
@@ -2912,6 +3046,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2912
3046
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2913
3047
|
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
2914
3048
|
file_data: `data:${mediaType};base64,${(0, import_provider_utils24.convertToBase64)(part.data)}`
|
|
3049
|
+
},
|
|
3050
|
+
...promptCacheBreakpoint != null && {
|
|
3051
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
2915
3052
|
}
|
|
2916
3053
|
};
|
|
2917
3054
|
}
|
|
@@ -3124,12 +3261,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
3124
3261
|
break;
|
|
3125
3262
|
}
|
|
3126
3263
|
case "reasoning": {
|
|
3127
|
-
const
|
|
3264
|
+
const providerOptions2 = await (0, import_provider_utils24.parseProviderOptions)({
|
|
3128
3265
|
provider: providerOptionsName,
|
|
3129
3266
|
providerOptions: part.providerOptions,
|
|
3130
3267
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
3131
3268
|
});
|
|
3132
|
-
const reasoningId =
|
|
3269
|
+
const reasoningId = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
3133
3270
|
if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
|
|
3134
3271
|
break;
|
|
3135
3272
|
}
|
|
@@ -3161,19 +3298,19 @@ async function convertToOpenAIResponsesInput({
|
|
|
3161
3298
|
reasoningMessages[reasoningId] = {
|
|
3162
3299
|
type: "reasoning",
|
|
3163
3300
|
id: reasoningId,
|
|
3164
|
-
encrypted_content:
|
|
3301
|
+
encrypted_content: providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent,
|
|
3165
3302
|
summary: summaryParts
|
|
3166
3303
|
};
|
|
3167
3304
|
input.push(reasoningMessages[reasoningId]);
|
|
3168
3305
|
} else {
|
|
3169
3306
|
reasoningMessage.summary.push(...summaryParts);
|
|
3170
|
-
if ((
|
|
3171
|
-
reasoningMessage.encrypted_content =
|
|
3307
|
+
if ((providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent) != null) {
|
|
3308
|
+
reasoningMessage.encrypted_content = providerOptions2.reasoningEncryptedContent;
|
|
3172
3309
|
}
|
|
3173
3310
|
}
|
|
3174
3311
|
}
|
|
3175
3312
|
} else {
|
|
3176
|
-
const encryptedContent =
|
|
3313
|
+
const encryptedContent = providerOptions2 == null ? void 0 : providerOptions2.reasoningEncryptedContent;
|
|
3177
3314
|
if (encryptedContent != null) {
|
|
3178
3315
|
const summaryParts = [];
|
|
3179
3316
|
if (part.text.length > 0) {
|
|
@@ -3306,31 +3443,53 @@ async function convertToOpenAIResponsesInput({
|
|
|
3306
3443
|
case "content":
|
|
3307
3444
|
outputValue = output.value.map((item) => {
|
|
3308
3445
|
var _a2, _b2, _c2, _d2, _e2;
|
|
3446
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3447
|
+
item.providerOptions,
|
|
3448
|
+
providerOptionsName
|
|
3449
|
+
);
|
|
3309
3450
|
switch (item.type) {
|
|
3310
3451
|
case "text":
|
|
3311
|
-
return {
|
|
3452
|
+
return {
|
|
3453
|
+
type: "input_text",
|
|
3454
|
+
text: item.text,
|
|
3455
|
+
...promptCacheBreakpoint != null && {
|
|
3456
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3457
|
+
}
|
|
3458
|
+
};
|
|
3312
3459
|
case "image-data":
|
|
3313
3460
|
return {
|
|
3314
3461
|
type: "input_image",
|
|
3315
3462
|
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3316
|
-
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3463
|
+
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3464
|
+
...promptCacheBreakpoint != null && {
|
|
3465
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3466
|
+
}
|
|
3317
3467
|
};
|
|
3318
3468
|
case "image-url":
|
|
3319
3469
|
return {
|
|
3320
3470
|
type: "input_image",
|
|
3321
3471
|
image_url: item.url,
|
|
3322
|
-
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3472
|
+
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3473
|
+
...promptCacheBreakpoint != null && {
|
|
3474
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3475
|
+
}
|
|
3323
3476
|
};
|
|
3324
3477
|
case "file-data":
|
|
3325
3478
|
return {
|
|
3326
3479
|
type: "input_file",
|
|
3327
3480
|
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3328
|
-
file_data: `data:${item.mediaType};base64,${item.data}
|
|
3481
|
+
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
3482
|
+
...promptCacheBreakpoint != null && {
|
|
3483
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3484
|
+
}
|
|
3329
3485
|
};
|
|
3330
3486
|
case "file-url":
|
|
3331
3487
|
return {
|
|
3332
3488
|
type: "input_file",
|
|
3333
|
-
file_url: item.url
|
|
3489
|
+
file_url: item.url,
|
|
3490
|
+
...promptCacheBreakpoint != null && {
|
|
3491
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3492
|
+
}
|
|
3334
3493
|
};
|
|
3335
3494
|
default:
|
|
3336
3495
|
warnings.push({
|
|
@@ -3367,35 +3526,57 @@ async function convertToOpenAIResponsesInput({
|
|
|
3367
3526
|
case "content":
|
|
3368
3527
|
contentValue = output.value.map((item) => {
|
|
3369
3528
|
var _a2, _b2, _c2, _d2, _e2;
|
|
3529
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3530
|
+
item.providerOptions,
|
|
3531
|
+
providerOptionsName
|
|
3532
|
+
);
|
|
3370
3533
|
switch (item.type) {
|
|
3371
3534
|
case "text": {
|
|
3372
|
-
return {
|
|
3535
|
+
return {
|
|
3536
|
+
type: "input_text",
|
|
3537
|
+
text: item.text,
|
|
3538
|
+
...promptCacheBreakpoint != null && {
|
|
3539
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3540
|
+
}
|
|
3541
|
+
};
|
|
3373
3542
|
}
|
|
3374
3543
|
case "image-data": {
|
|
3375
3544
|
return {
|
|
3376
3545
|
type: "input_image",
|
|
3377
3546
|
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3378
|
-
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3547
|
+
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3548
|
+
...promptCacheBreakpoint != null && {
|
|
3549
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3550
|
+
}
|
|
3379
3551
|
};
|
|
3380
3552
|
}
|
|
3381
3553
|
case "image-url": {
|
|
3382
3554
|
return {
|
|
3383
3555
|
type: "input_image",
|
|
3384
3556
|
image_url: item.url,
|
|
3385
|
-
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3557
|
+
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3558
|
+
...promptCacheBreakpoint != null && {
|
|
3559
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3560
|
+
}
|
|
3386
3561
|
};
|
|
3387
3562
|
}
|
|
3388
3563
|
case "file-data": {
|
|
3389
3564
|
return {
|
|
3390
3565
|
type: "input_file",
|
|
3391
3566
|
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3392
|
-
file_data: `data:${item.mediaType};base64,${item.data}
|
|
3567
|
+
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
3568
|
+
...promptCacheBreakpoint != null && {
|
|
3569
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3570
|
+
}
|
|
3393
3571
|
};
|
|
3394
3572
|
}
|
|
3395
3573
|
case "file-url": {
|
|
3396
3574
|
return {
|
|
3397
3575
|
type: "input_file",
|
|
3398
|
-
file_url: item.url
|
|
3576
|
+
file_url: item.url,
|
|
3577
|
+
...promptCacheBreakpoint != null && {
|
|
3578
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3579
|
+
}
|
|
3399
3580
|
};
|
|
3400
3581
|
}
|
|
3401
3582
|
default: {
|
|
@@ -3517,6 +3698,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
3517
3698
|
input_tokens: import_v418.z.number(),
|
|
3518
3699
|
input_tokens_details: import_v418.z.object({
|
|
3519
3700
|
cached_tokens: import_v418.z.number().nullish(),
|
|
3701
|
+
cache_write_tokens: import_v418.z.number().nullish(),
|
|
3520
3702
|
orchestration_input_tokens: import_v418.z.number().nullish(),
|
|
3521
3703
|
orchestration_input_cached_tokens: import_v418.z.number().nullish()
|
|
3522
3704
|
}).nullish(),
|
|
@@ -3526,6 +3708,9 @@ var openaiResponsesChunkSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
3526
3708
|
orchestration_output_tokens: import_v418.z.number().nullish()
|
|
3527
3709
|
}).nullish()
|
|
3528
3710
|
}),
|
|
3711
|
+
reasoning: import_v418.z.object({
|
|
3712
|
+
context: import_v418.z.string().nullish()
|
|
3713
|
+
}).nullish(),
|
|
3529
3714
|
service_tier: import_v418.z.string().nullish()
|
|
3530
3715
|
})
|
|
3531
3716
|
}),
|
|
@@ -3542,6 +3727,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
3542
3727
|
input_tokens: import_v418.z.number(),
|
|
3543
3728
|
input_tokens_details: import_v418.z.object({
|
|
3544
3729
|
cached_tokens: import_v418.z.number().nullish(),
|
|
3730
|
+
cache_write_tokens: import_v418.z.number().nullish(),
|
|
3545
3731
|
orchestration_input_tokens: import_v418.z.number().nullish(),
|
|
3546
3732
|
orchestration_input_cached_tokens: import_v418.z.number().nullish()
|
|
3547
3733
|
}).nullish(),
|
|
@@ -3551,6 +3737,9 @@ var openaiResponsesChunkSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
3551
3737
|
orchestration_output_tokens: import_v418.z.number().nullish()
|
|
3552
3738
|
}).nullish()
|
|
3553
3739
|
}).nullish(),
|
|
3740
|
+
reasoning: import_v418.z.object({
|
|
3741
|
+
context: import_v418.z.string().nullish()
|
|
3742
|
+
}).nullish(),
|
|
3554
3743
|
service_tier: import_v418.z.string().nullish()
|
|
3555
3744
|
})
|
|
3556
3745
|
}),
|
|
@@ -4322,11 +4511,15 @@ var openaiResponsesResponseSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
4322
4511
|
])
|
|
4323
4512
|
).optional(),
|
|
4324
4513
|
service_tier: import_v418.z.string().nullish(),
|
|
4514
|
+
reasoning: import_v418.z.object({
|
|
4515
|
+
context: import_v418.z.string().nullish()
|
|
4516
|
+
}).nullish(),
|
|
4325
4517
|
incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullish(),
|
|
4326
4518
|
usage: import_v418.z.object({
|
|
4327
4519
|
input_tokens: import_v418.z.number(),
|
|
4328
4520
|
input_tokens_details: import_v418.z.object({
|
|
4329
4521
|
cached_tokens: import_v418.z.number().nullish(),
|
|
4522
|
+
cache_write_tokens: import_v418.z.number().nullish(),
|
|
4330
4523
|
orchestration_input_tokens: import_v418.z.number().nullish(),
|
|
4331
4524
|
orchestration_input_cached_tokens: import_v418.z.number().nullish()
|
|
4332
4525
|
}).nullish(),
|
|
@@ -4481,11 +4674,22 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
|
|
|
4481
4674
|
* Sets a cache key to tie this prompt to cached prefixes for better caching performance.
|
|
4482
4675
|
*/
|
|
4483
4676
|
promptCacheKey: import_v419.z.string().nullish(),
|
|
4677
|
+
/**
|
|
4678
|
+
* Prompt cache behavior for GPT-5.6 and later models.
|
|
4679
|
+
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
4680
|
+
* `ttl` sets the minimum cache lifetime and currently only supports 30 minutes.
|
|
4681
|
+
*/
|
|
4682
|
+
promptCacheOptions: import_v419.z.object({
|
|
4683
|
+
mode: import_v419.z.enum(["implicit", "explicit"]).optional(),
|
|
4684
|
+
ttl: import_v419.z.literal("30m").optional()
|
|
4685
|
+
}).optional(),
|
|
4484
4686
|
/**
|
|
4485
4687
|
* The retention policy for the prompt cache.
|
|
4486
4688
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
4487
4689
|
* - '24h': Extended prompt caching that keeps cached prefixes active for up to 24 hours.
|
|
4488
|
-
*
|
|
4690
|
+
* Available for models before GPT-5.6 that support extended caching.
|
|
4691
|
+
*
|
|
4692
|
+
* @deprecated For GPT-5.6 and later models, use `promptCacheOptions.ttl`.
|
|
4489
4693
|
*
|
|
4490
4694
|
* @default 'in_memory'
|
|
4491
4695
|
*/
|
|
@@ -4493,14 +4697,21 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
|
|
|
4493
4697
|
/**
|
|
4494
4698
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
4495
4699
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
4496
|
-
*
|
|
4497
|
-
*
|
|
4498
|
-
* The 'none' type for `reasoningEffort` is only available for OpenAI's GPT-5.1
|
|
4499
|
-
* models. Also, the 'xhigh' type for `reasoningEffort` is only available for
|
|
4500
|
-
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
4501
|
-
* an error.
|
|
4700
|
+
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
4701
|
+
* Supported values vary by model.
|
|
4502
4702
|
*/
|
|
4503
4703
|
reasoningEffort: import_v419.z.string().nullish(),
|
|
4704
|
+
/**
|
|
4705
|
+
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
4706
|
+
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
4707
|
+
*/
|
|
4708
|
+
reasoningMode: import_v419.z.enum(["standard", "pro"]).optional(),
|
|
4709
|
+
/**
|
|
4710
|
+
* Controls which available reasoning items GPT-5.6 can use.
|
|
4711
|
+
* `auto` uses the model default, `current_turn` excludes reasoning from earlier
|
|
4712
|
+
* turns, and `all_turns` makes compatible earlier reasoning available.
|
|
4713
|
+
*/
|
|
4714
|
+
reasoningContext: import_v419.z.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
4504
4715
|
/**
|
|
4505
4716
|
* Controls reasoning summary output from the model.
|
|
4506
4717
|
* Set to "auto" to automatically receive the richest level available,
|
|
@@ -5423,18 +5634,25 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5423
5634
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
5424
5635
|
include,
|
|
5425
5636
|
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
5637
|
+
prompt_cache_options: openaiOptions == null ? void 0 : openaiOptions.promptCacheOptions,
|
|
5426
5638
|
prompt_cache_retention: openaiOptions == null ? void 0 : openaiOptions.promptCacheRetention,
|
|
5427
5639
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
5428
5640
|
top_logprobs: topLogprobs,
|
|
5429
5641
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5430
5642
|
// model-specific settings:
|
|
5431
|
-
...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
5643
|
+
...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5432
5644
|
reasoning: {
|
|
5433
5645
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
|
|
5434
5646
|
effort: openaiOptions.reasoningEffort
|
|
5435
5647
|
},
|
|
5436
5648
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
5437
5649
|
summary: openaiOptions.reasoningSummary
|
|
5650
|
+
},
|
|
5651
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null && {
|
|
5652
|
+
mode: openaiOptions.reasoningMode
|
|
5653
|
+
},
|
|
5654
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null && {
|
|
5655
|
+
context: openaiOptions.reasoningContext
|
|
5438
5656
|
}
|
|
5439
5657
|
}
|
|
5440
5658
|
}
|
|
@@ -5473,6 +5691,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5473
5691
|
details: "reasoningSummary is not supported for non-reasoning models"
|
|
5474
5692
|
});
|
|
5475
5693
|
}
|
|
5694
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null) {
|
|
5695
|
+
warnings.push({
|
|
5696
|
+
type: "unsupported",
|
|
5697
|
+
feature: "reasoningMode",
|
|
5698
|
+
details: "reasoningMode is not supported for non-reasoning models"
|
|
5699
|
+
});
|
|
5700
|
+
}
|
|
5701
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) {
|
|
5702
|
+
warnings.push({
|
|
5703
|
+
type: "unsupported",
|
|
5704
|
+
feature: "reasoningContext",
|
|
5705
|
+
details: "reasoningContext is not supported for non-reasoning models"
|
|
5706
|
+
});
|
|
5707
|
+
}
|
|
5476
5708
|
}
|
|
5477
5709
|
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelCapabilities.supportsFlexProcessing) {
|
|
5478
5710
|
warnings.push({
|
|
@@ -5509,7 +5741,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5509
5741
|
};
|
|
5510
5742
|
}
|
|
5511
5743
|
async doGenerate(options) {
|
|
5512
|
-
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;
|
|
5744
|
+
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;
|
|
5513
5745
|
const {
|
|
5514
5746
|
args: body,
|
|
5515
5747
|
warnings,
|
|
@@ -5958,7 +6190,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5958
6190
|
[providerOptionsName]: {
|
|
5959
6191
|
responseId: response.id,
|
|
5960
6192
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
5961
|
-
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {}
|
|
6193
|
+
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
|
|
6194
|
+
...((_z = response.reasoning) == null ? void 0 : _z.context) != null ? { reasoningContext: response.reasoning.context } : {}
|
|
5962
6195
|
}
|
|
5963
6196
|
};
|
|
5964
6197
|
const usage = response.usage;
|
|
@@ -5966,10 +6199,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5966
6199
|
content,
|
|
5967
6200
|
finishReason: {
|
|
5968
6201
|
unified: mapOpenAIResponseFinishReason({
|
|
5969
|
-
finishReason: (
|
|
6202
|
+
finishReason: (_A = response.incomplete_details) == null ? void 0 : _A.reason,
|
|
5970
6203
|
hasFunctionCall
|
|
5971
6204
|
}),
|
|
5972
|
-
raw: (
|
|
6205
|
+
raw: (_C = (_B = response.incomplete_details) == null ? void 0 : _B.reason) != null ? _C : void 0
|
|
5973
6206
|
},
|
|
5974
6207
|
usage: convertOpenAIResponsesUsage(usage),
|
|
5975
6208
|
request: { body },
|
|
@@ -6036,6 +6269,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6036
6269
|
let hasFunctionCall = false;
|
|
6037
6270
|
const activeReasoning = {};
|
|
6038
6271
|
let serviceTier;
|
|
6272
|
+
let reasoningContext;
|
|
6039
6273
|
const hostedToolSearchCallIds = [];
|
|
6040
6274
|
let encounteredStreamError = false;
|
|
6041
6275
|
const result = {
|
|
@@ -6045,7 +6279,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6045
6279
|
controller.enqueue({ type: "stream-start", warnings });
|
|
6046
6280
|
},
|
|
6047
6281
|
transform(chunk, controller) {
|
|
6048
|
-
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, _F, _G, _H, _I, _J, _K, _L;
|
|
6282
|
+
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, _F, _G, _H, _I, _J, _K, _L, _M, _N;
|
|
6049
6283
|
if (options.includeRawChunks) {
|
|
6050
6284
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
6051
6285
|
}
|
|
@@ -6787,8 +7021,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6787
7021
|
if (typeof value.response.service_tier === "string") {
|
|
6788
7022
|
serviceTier = value.response.service_tier;
|
|
6789
7023
|
}
|
|
7024
|
+
if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
|
|
7025
|
+
reasoningContext = value.response.reasoning.context;
|
|
7026
|
+
}
|
|
6790
7027
|
} else if (isResponseFailedChunk(value)) {
|
|
6791
|
-
const incompleteReason = (
|
|
7028
|
+
const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
|
|
6792
7029
|
finishReason = {
|
|
6793
7030
|
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
6794
7031
|
finishReason: incompleteReason,
|
|
@@ -6796,7 +7033,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6796
7033
|
}) : "error",
|
|
6797
7034
|
raw: incompleteReason != null ? incompleteReason : "error"
|
|
6798
7035
|
};
|
|
6799
|
-
usage = (
|
|
7036
|
+
usage = (_A = value.response.usage) != null ? _A : void 0;
|
|
7037
|
+
if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
|
|
7038
|
+
reasoningContext = value.response.reasoning.context;
|
|
7039
|
+
}
|
|
6800
7040
|
if (!encounteredStreamError && value.response.error != null) {
|
|
6801
7041
|
encounteredStreamError = true;
|
|
6802
7042
|
controller.enqueue({
|
|
@@ -6818,7 +7058,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6818
7058
|
controller.enqueue({
|
|
6819
7059
|
type: "source",
|
|
6820
7060
|
sourceType: "url",
|
|
6821
|
-
id: (
|
|
7061
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : (0, import_provider_utils35.generateId)(),
|
|
6822
7062
|
url: value.annotation.url,
|
|
6823
7063
|
title: value.annotation.title
|
|
6824
7064
|
});
|
|
@@ -6826,7 +7066,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6826
7066
|
controller.enqueue({
|
|
6827
7067
|
type: "source",
|
|
6828
7068
|
sourceType: "document",
|
|
6829
|
-
id: (
|
|
7069
|
+
id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : (0, import_provider_utils35.generateId)(),
|
|
6830
7070
|
mediaType: "text/plain",
|
|
6831
7071
|
title: value.annotation.filename,
|
|
6832
7072
|
filename: value.annotation.filename,
|
|
@@ -6842,7 +7082,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6842
7082
|
controller.enqueue({
|
|
6843
7083
|
type: "source",
|
|
6844
7084
|
sourceType: "document",
|
|
6845
|
-
id: (
|
|
7085
|
+
id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : (0, import_provider_utils35.generateId)(),
|
|
6846
7086
|
mediaType: "text/plain",
|
|
6847
7087
|
title: value.annotation.filename,
|
|
6848
7088
|
filename: value.annotation.filename,
|
|
@@ -6858,7 +7098,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6858
7098
|
controller.enqueue({
|
|
6859
7099
|
type: "source",
|
|
6860
7100
|
sourceType: "document",
|
|
6861
|
-
id: (
|
|
7101
|
+
id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : (0, import_provider_utils35.generateId)(),
|
|
6862
7102
|
mediaType: "application/octet-stream",
|
|
6863
7103
|
title: value.annotation.file_id,
|
|
6864
7104
|
filename: value.annotation.file_id,
|
|
@@ -6882,7 +7122,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6882
7122
|
[providerOptionsName]: {
|
|
6883
7123
|
responseId,
|
|
6884
7124
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
6885
|
-
...serviceTier !== void 0 ? { serviceTier } : {}
|
|
7125
|
+
...serviceTier !== void 0 ? { serviceTier } : {},
|
|
7126
|
+
...reasoningContext !== void 0 ? { reasoningContext } : {}
|
|
6886
7127
|
}
|
|
6887
7128
|
};
|
|
6888
7129
|
controller.enqueue({
|