@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/dist/internal/index.js
CHANGED
|
@@ -409,15 +409,17 @@ function convertToOpenAIChatMessages({ prompt, systemMessageMode = "system" }) {
|
|
|
409
409
|
let contentValue;
|
|
410
410
|
switch (output.type) {
|
|
411
411
|
case "text":
|
|
412
|
-
case "error-text":
|
|
413
412
|
contentValue = output.value;
|
|
414
413
|
break;
|
|
414
|
+
case "error-text":
|
|
415
|
+
case "error-json":
|
|
416
|
+
contentValue = JSON.stringify({ error: output.value });
|
|
417
|
+
break;
|
|
415
418
|
case "execution-denied":
|
|
416
419
|
contentValue = output.reason ?? "Tool call execution denied.";
|
|
417
420
|
break;
|
|
418
421
|
case "content":
|
|
419
|
-
case "json":
|
|
420
|
-
case "error-json": contentValue = JSON.stringify(output.value);
|
|
422
|
+
case "json": contentValue = JSON.stringify(output.value);
|
|
421
423
|
}
|
|
422
424
|
messages.push({
|
|
423
425
|
role: "tool",
|
|
@@ -3311,14 +3313,14 @@ async function convertFunctionToolResultOutput({ output, toolName, outputSchemaT
|
|
|
3311
3313
|
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3312
3314
|
}];
|
|
3313
3315
|
switch (output.type) {
|
|
3314
|
-
case "text":
|
|
3315
|
-
case "error-text":
|
|
3316
|
+
case "text": return convertScalarOutput(hasOutputSchema ? JSON.stringify(output.value) : output.value);
|
|
3317
|
+
case "error-text":
|
|
3318
|
+
case "error-json": return convertScalarOutput(JSON.stringify({ error: output.value }));
|
|
3316
3319
|
case "execution-denied": {
|
|
3317
3320
|
const reason = output.reason ?? "Tool call execution denied.";
|
|
3318
3321
|
return convertScalarOutput(hasOutputSchema ? JSON.stringify(reason) : reason);
|
|
3319
3322
|
}
|
|
3320
|
-
case "json":
|
|
3321
|
-
case "error-json": return convertScalarOutput(JSON.stringify(output.value));
|
|
3323
|
+
case "json": return convertScalarOutput(JSON.stringify(output.value));
|
|
3322
3324
|
case "content": return output.value.map((item) => {
|
|
3323
3325
|
const promptCacheBreakpoint = getPromptCacheBreakpoint(item.providerOptions, providerOptionsName);
|
|
3324
3326
|
switch (item.type) {
|
|
@@ -4137,14 +4139,16 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
4137
4139
|
let outputValue;
|
|
4138
4140
|
switch (output.type) {
|
|
4139
4141
|
case "text":
|
|
4140
|
-
case "error-text":
|
|
4141
4142
|
outputValue = convertScalarOutput(output.value);
|
|
4142
4143
|
break;
|
|
4144
|
+
case "error-text":
|
|
4145
|
+
case "error-json":
|
|
4146
|
+
outputValue = convertScalarOutput(JSON.stringify({ error: output.value }));
|
|
4147
|
+
break;
|
|
4143
4148
|
case "execution-denied":
|
|
4144
4149
|
outputValue = convertScalarOutput(output.reason ?? "Tool call execution denied.");
|
|
4145
4150
|
break;
|
|
4146
4151
|
case "json":
|
|
4147
|
-
case "error-json":
|
|
4148
4152
|
outputValue = convertScalarOutput(JSON.stringify(output.value));
|
|
4149
4153
|
break;
|
|
4150
4154
|
case "content":
|