@ai-sdk/openai 4.0.87 → 4.0.88
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.js +14 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +13 -9
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat/convert-to-openai-chat-messages.ts +4 -2
- package/src/responses/convert-to-openai-responses-input.ts +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.88
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 32ff7ad: Preserve tool errors in OpenAI Chat Completions and Responses by wrapping their payloads in an `error` object. Send Google tool errors and denied executions under `functionResponse.response.error`.
|
|
8
|
+
|
|
3
9
|
## 4.0.87
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -617,15 +617,17 @@ function convertToOpenAIChatMessages({ prompt, systemMessageMode = "system" }) {
|
|
|
617
617
|
let contentValue;
|
|
618
618
|
switch (output.type) {
|
|
619
619
|
case "text":
|
|
620
|
-
case "error-text":
|
|
621
620
|
contentValue = output.value;
|
|
622
621
|
break;
|
|
622
|
+
case "error-text":
|
|
623
|
+
case "error-json":
|
|
624
|
+
contentValue = JSON.stringify({ error: output.value });
|
|
625
|
+
break;
|
|
623
626
|
case "execution-denied":
|
|
624
627
|
contentValue = output.reason ?? "Tool call execution denied.";
|
|
625
628
|
break;
|
|
626
629
|
case "content":
|
|
627
|
-
case "json":
|
|
628
|
-
case "error-json": contentValue = JSON.stringify(output.value);
|
|
630
|
+
case "json": contentValue = JSON.stringify(output.value);
|
|
629
631
|
}
|
|
630
632
|
messages.push({
|
|
631
633
|
role: "tool",
|
|
@@ -4557,14 +4559,14 @@ async function convertFunctionToolResultOutput({ output, toolName, outputSchemaT
|
|
|
4557
4559
|
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
4558
4560
|
}];
|
|
4559
4561
|
switch (output.type) {
|
|
4560
|
-
case "text":
|
|
4561
|
-
case "error-text":
|
|
4562
|
+
case "text": return convertScalarOutput(hasOutputSchema ? JSON.stringify(output.value) : output.value);
|
|
4563
|
+
case "error-text":
|
|
4564
|
+
case "error-json": return convertScalarOutput(JSON.stringify({ error: output.value }));
|
|
4562
4565
|
case "execution-denied": {
|
|
4563
4566
|
const reason = output.reason ?? "Tool call execution denied.";
|
|
4564
4567
|
return convertScalarOutput(hasOutputSchema ? JSON.stringify(reason) : reason);
|
|
4565
4568
|
}
|
|
4566
|
-
case "json":
|
|
4567
|
-
case "error-json": return convertScalarOutput(JSON.stringify(output.value));
|
|
4569
|
+
case "json": return convertScalarOutput(JSON.stringify(output.value));
|
|
4568
4570
|
case "content": return output.value.map((item) => {
|
|
4569
4571
|
const promptCacheBreakpoint = getPromptCacheBreakpoint(item.providerOptions, providerOptionsName);
|
|
4570
4572
|
switch (item.type) {
|
|
@@ -5383,14 +5385,16 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
5383
5385
|
let outputValue;
|
|
5384
5386
|
switch (output.type) {
|
|
5385
5387
|
case "text":
|
|
5386
|
-
case "error-text":
|
|
5387
5388
|
outputValue = convertScalarOutput(output.value);
|
|
5388
5389
|
break;
|
|
5390
|
+
case "error-text":
|
|
5391
|
+
case "error-json":
|
|
5392
|
+
outputValue = convertScalarOutput(JSON.stringify({ error: output.value }));
|
|
5393
|
+
break;
|
|
5389
5394
|
case "execution-denied":
|
|
5390
5395
|
outputValue = convertScalarOutput(output.reason ?? "Tool call execution denied.");
|
|
5391
5396
|
break;
|
|
5392
5397
|
case "json":
|
|
5393
|
-
case "error-json":
|
|
5394
5398
|
outputValue = convertScalarOutput(JSON.stringify(output.value));
|
|
5395
5399
|
break;
|
|
5396
5400
|
case "content":
|
|
@@ -10042,7 +10046,7 @@ var OpenAISkills = class {
|
|
|
10042
10046
|
};
|
|
10043
10047
|
//#endregion
|
|
10044
10048
|
//#region src/version.ts
|
|
10045
|
-
const VERSION = "4.0.
|
|
10049
|
+
const VERSION = "4.0.88";
|
|
10046
10050
|
//#endregion
|
|
10047
10051
|
//#region src/openai-provider.ts
|
|
10048
10052
|
/**
|