@ai-sdk/openai 3.0.126 → 3.0.127
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 +11 -0
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +7 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +7 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/responses/convert-to-openai-responses-input.ts +18 -2
- package/src/responses/openai-responses-language-model.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.127",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider": "
|
|
40
|
-
"@ai-sdk/provider
|
|
39
|
+
"@ai-sdk/provider-utils": "4.0.58",
|
|
40
|
+
"@ai-sdk/provider": "3.0.18"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
@@ -391,6 +391,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
391
391
|
fileIdPrefixes,
|
|
392
392
|
passThroughUnsupportedFiles = false,
|
|
393
393
|
store,
|
|
394
|
+
isReasoningModel = false,
|
|
394
395
|
hasConversation = false,
|
|
395
396
|
hasPreviousResponseId = false,
|
|
396
397
|
configurationUpdateUnsupportedReason,
|
|
@@ -408,6 +409,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
408
409
|
fileIdPrefixes?: readonly string[];
|
|
409
410
|
passThroughUnsupportedFiles?: boolean;
|
|
410
411
|
store: boolean;
|
|
412
|
+
isReasoningModel?: boolean; // when true, stored assistant messages are only referenced together with their reasoning
|
|
411
413
|
hasConversation?: boolean; // when true, skip assistant messages that already have item IDs
|
|
412
414
|
hasPreviousResponseId?: boolean; // when true, skip reasoning and function-call items that already exist in the previous response chain
|
|
413
415
|
configurationUpdateUnsupportedReason?: string;
|
|
@@ -625,6 +627,13 @@ export async function convertToOpenAIResponsesInput({
|
|
|
625
627
|
case 'assistant': {
|
|
626
628
|
const reasoningMessages: Record<string, OpenAIResponsesReasoning> = {};
|
|
627
629
|
|
|
630
|
+
// Stored messages of reasoning models are bound to the reasoning item
|
|
631
|
+
// that produced them. When the reasoning has been removed (e.g. with
|
|
632
|
+
// `pruneMessages`), referencing the message fails with "Item 'msg_...'
|
|
633
|
+
// of type 'message' was provided without its required 'reasoning'
|
|
634
|
+
// item", so it is sent with its content and without its id instead.
|
|
635
|
+
let hasPrecedingReasoning = false;
|
|
636
|
+
|
|
628
637
|
for (const part of content) {
|
|
629
638
|
switch (part.type) {
|
|
630
639
|
case 'text': {
|
|
@@ -641,8 +650,13 @@ export async function convertToOpenAIResponsesInput({
|
|
|
641
650
|
break;
|
|
642
651
|
}
|
|
643
652
|
|
|
653
|
+
// stored messages of reasoning models can only be referenced by id
|
|
654
|
+
// together with their reasoning (see above):
|
|
655
|
+
const canUseItemId =
|
|
656
|
+
id != null && (!isReasoningModel || hasPrecedingReasoning);
|
|
657
|
+
|
|
644
658
|
// item references reduce the payload size
|
|
645
|
-
if (store &&
|
|
659
|
+
if (store && canUseItemId) {
|
|
646
660
|
input.push({ type: 'item_reference', id });
|
|
647
661
|
break;
|
|
648
662
|
}
|
|
@@ -651,7 +665,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
651
665
|
...(explicitMessageItemType && { type: 'message' as const }),
|
|
652
666
|
role: 'assistant',
|
|
653
667
|
content: [{ type: 'output_text', text: part.text }],
|
|
654
|
-
id,
|
|
668
|
+
id: canUseItemId ? id : undefined,
|
|
655
669
|
...(phase != null && { phase }),
|
|
656
670
|
});
|
|
657
671
|
|
|
@@ -1038,6 +1052,8 @@ export async function convertToOpenAIResponsesInput({
|
|
|
1038
1052
|
}
|
|
1039
1053
|
|
|
1040
1054
|
case 'reasoning': {
|
|
1055
|
+
hasPrecedingReasoning = true;
|
|
1056
|
+
|
|
1041
1057
|
const providerOptions = await parseProviderOptions({
|
|
1042
1058
|
provider: providerOptionsName,
|
|
1043
1059
|
providerOptions: part.providerOptions,
|
|
@@ -295,6 +295,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|
|
295
295
|
passThroughUnsupportedFiles:
|
|
296
296
|
openaiOptions?.passThroughUnsupportedFiles ?? false,
|
|
297
297
|
store: openaiOptions?.store ?? true,
|
|
298
|
+
isReasoningModel,
|
|
298
299
|
hasConversation: openaiOptions?.conversation != null,
|
|
299
300
|
hasPreviousResponseId: openaiOptions?.previousResponseId != null,
|
|
300
301
|
hasLocalShellTool: hasOpenAITool('openai.local_shell'),
|