@ai-sdk/openai 4.0.92 → 4.0.94
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 +15 -0
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +5 -2
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +16 -1
- 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": "4.0.
|
|
3
|
+
"version": "4.0.94",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ai-sdk/provider": "4.0.27",
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.60"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.4",
|
|
@@ -435,6 +435,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
435
435
|
fileIdPrefixes,
|
|
436
436
|
passThroughUnsupportedFiles = false,
|
|
437
437
|
store,
|
|
438
|
+
isReasoningModel = false,
|
|
438
439
|
hasConversation = false,
|
|
439
440
|
hasPreviousResponseId = false,
|
|
440
441
|
hasLocalShellTool = false,
|
|
@@ -455,6 +456,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
455
456
|
fileIdPrefixes?: readonly string[];
|
|
456
457
|
passThroughUnsupportedFiles?: boolean;
|
|
457
458
|
store: boolean;
|
|
459
|
+
isReasoningModel?: boolean; // when true, stored assistant messages are only referenced together with their reasoning
|
|
458
460
|
hasConversation?: boolean; // when true, skip assistant messages that already have item IDs
|
|
459
461
|
hasPreviousResponseId?: boolean; // when true, skip reasoning and function-call items that already exist in the previous response chain
|
|
460
462
|
hasLocalShellTool?: boolean;
|
|
@@ -714,6 +716,13 @@ export async function convertToOpenAIResponsesInput({
|
|
|
714
716
|
const reasoningMessages: Record<string, OpenAIResponsesReasoning> = {};
|
|
715
717
|
const emittedTextItemIds = new Set<string>();
|
|
716
718
|
|
|
719
|
+
// Stored messages of reasoning models are bound to the reasoning item
|
|
720
|
+
// that produced them. When the reasoning has been removed (e.g. with
|
|
721
|
+
// `pruneMessages`), referencing the message fails with "Item 'msg_...'
|
|
722
|
+
// of type 'message' was provided without its required 'reasoning'
|
|
723
|
+
// item", so it is sent with its content instead.
|
|
724
|
+
let hasPrecedingReasoning = false;
|
|
725
|
+
|
|
717
726
|
for (const part of content) {
|
|
718
727
|
switch (part.type) {
|
|
719
728
|
case 'text': {
|
|
@@ -732,7 +741,11 @@ export async function convertToOpenAIResponsesInput({
|
|
|
732
741
|
}
|
|
733
742
|
|
|
734
743
|
// item references reduce the payload size
|
|
735
|
-
if (
|
|
744
|
+
if (
|
|
745
|
+
store &&
|
|
746
|
+
id != null &&
|
|
747
|
+
(!isReasoningModel || hasPrecedingReasoning)
|
|
748
|
+
) {
|
|
736
749
|
if (!emittedTextItemIds.has(id)) {
|
|
737
750
|
emittedTextItemIds.add(id);
|
|
738
751
|
input.push({ type: 'item_reference', id });
|
|
@@ -1243,6 +1256,8 @@ export async function convertToOpenAIResponsesInput({
|
|
|
1243
1256
|
}
|
|
1244
1257
|
|
|
1245
1258
|
case 'reasoning': {
|
|
1259
|
+
hasPrecedingReasoning = true;
|
|
1260
|
+
|
|
1246
1261
|
const providerOptions = await parseProviderOptions({
|
|
1247
1262
|
provider: providerOptionsName,
|
|
1248
1263
|
providerOptions: part.providerOptions,
|
|
@@ -437,6 +437,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
437
437
|
passThroughUnsupportedFiles:
|
|
438
438
|
openaiOptions?.passThroughUnsupportedFiles ?? false,
|
|
439
439
|
store: openaiOptions?.store ?? true,
|
|
440
|
+
isReasoningModel,
|
|
440
441
|
hasConversation: openaiOptions?.conversation != null,
|
|
441
442
|
hasPreviousResponseId: openaiOptions?.previousResponseId != null,
|
|
442
443
|
hasLocalShellTool: hasOpenAITool('openai.local_shell'),
|