@ai-sdk/openai 4.0.15 → 4.0.16
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 +30 -18
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +29 -17
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +4 -4
- package/package.json +2 -2
- package/src/responses/openai-responses-language-model.ts +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 75f86f4: fix(provider/openai, provider/open-responses): throw a descriptive error when the Responses API returns a 200 with no `output`
|
|
8
|
+
|
|
9
|
+
A successful (200) Responses body missing the `output` array previously threw an opaque `output is not iterable` TypeError from `doGenerate`. Both providers now surface a clear `APICallError` ("Responses API returned no output …"), including the incomplete-details reason (and status, for open-responses) when present. When the body includes a `response.error`, its message is surfaced first so upstream error details aren't masked by the generic fallback. This makes malformed/incomplete upstream responses actionable instead of a cryptic crash.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [cd06458]
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.11
|
|
13
|
+
|
|
3
14
|
## 4.0.15
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -6533,7 +6533,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6533
6533
|
};
|
|
6534
6534
|
}
|
|
6535
6535
|
async doGenerate(options) {
|
|
6536
|
-
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;
|
|
6536
|
+
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;
|
|
6537
6537
|
const {
|
|
6538
6538
|
args: body,
|
|
6539
6539
|
warnings,
|
|
@@ -6573,6 +6573,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6573
6573
|
isRetryable: false
|
|
6574
6574
|
});
|
|
6575
6575
|
}
|
|
6576
|
+
if (response.output == null) {
|
|
6577
|
+
const detail = (_c = response.incomplete_details) == null ? void 0 : _c.reason;
|
|
6578
|
+
throw new APICallError2({
|
|
6579
|
+
message: detail ? `Responses API returned no output (${detail})` : "Responses API returned no output",
|
|
6580
|
+
url,
|
|
6581
|
+
requestBodyValues: body,
|
|
6582
|
+
statusCode: 500,
|
|
6583
|
+
responseHeaders,
|
|
6584
|
+
responseBody: rawResponse,
|
|
6585
|
+
isRetryable: false
|
|
6586
|
+
});
|
|
6587
|
+
}
|
|
6576
6588
|
const content = [];
|
|
6577
6589
|
const logprobs = [];
|
|
6578
6590
|
let hasFunctionCall = false;
|
|
@@ -6590,7 +6602,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6590
6602
|
providerMetadata: {
|
|
6591
6603
|
[providerOptionsName]: {
|
|
6592
6604
|
itemId: part.id,
|
|
6593
|
-
reasoningEncryptedContent: (
|
|
6605
|
+
reasoningEncryptedContent: (_d = part.encrypted_content) != null ? _d : null
|
|
6594
6606
|
}
|
|
6595
6607
|
}
|
|
6596
6608
|
});
|
|
@@ -6616,7 +6628,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6616
6628
|
break;
|
|
6617
6629
|
}
|
|
6618
6630
|
case "tool_search_call": {
|
|
6619
|
-
const toolCallId = (
|
|
6631
|
+
const toolCallId = (_e = part.call_id) != null ? _e : part.id;
|
|
6620
6632
|
const isHosted = part.execution === "server";
|
|
6621
6633
|
if (isHosted) {
|
|
6622
6634
|
hostedToolSearchCallIds.push(toolCallId);
|
|
@@ -6639,7 +6651,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6639
6651
|
break;
|
|
6640
6652
|
}
|
|
6641
6653
|
case "tool_search_output": {
|
|
6642
|
-
const toolCallId = (
|
|
6654
|
+
const toolCallId = (_g = (_f = part.call_id) != null ? _f : hostedToolSearchCallIds.shift()) != null ? _g : part.id;
|
|
6643
6655
|
content.push({
|
|
6644
6656
|
type: "tool-result",
|
|
6645
6657
|
toolCallId,
|
|
@@ -6710,7 +6722,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6710
6722
|
}
|
|
6711
6723
|
case "message": {
|
|
6712
6724
|
for (const contentPart of part.content) {
|
|
6713
|
-
if (((
|
|
6725
|
+
if (((_i = (_h = options.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.logprobs) && contentPart.logprobs) {
|
|
6714
6726
|
logprobs.push(contentPart.logprobs);
|
|
6715
6727
|
}
|
|
6716
6728
|
const providerMetadata2 = {
|
|
@@ -6732,7 +6744,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6732
6744
|
content.push({
|
|
6733
6745
|
type: "source",
|
|
6734
6746
|
sourceType: "url",
|
|
6735
|
-
id: (
|
|
6747
|
+
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
|
|
6736
6748
|
url: annotation.url,
|
|
6737
6749
|
title: annotation.title
|
|
6738
6750
|
});
|
|
@@ -6740,7 +6752,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6740
6752
|
content.push({
|
|
6741
6753
|
type: "source",
|
|
6742
6754
|
sourceType: "document",
|
|
6743
|
-
id: (
|
|
6755
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
|
|
6744
6756
|
mediaType: "text/plain",
|
|
6745
6757
|
title: annotation.filename,
|
|
6746
6758
|
filename: annotation.filename,
|
|
@@ -6756,7 +6768,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6756
6768
|
content.push({
|
|
6757
6769
|
type: "source",
|
|
6758
6770
|
sourceType: "document",
|
|
6759
|
-
id: (
|
|
6771
|
+
id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
|
|
6760
6772
|
mediaType: "text/plain",
|
|
6761
6773
|
title: annotation.filename,
|
|
6762
6774
|
filename: annotation.filename,
|
|
@@ -6772,7 +6784,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6772
6784
|
content.push({
|
|
6773
6785
|
type: "source",
|
|
6774
6786
|
sourceType: "document",
|
|
6775
|
-
id: (
|
|
6787
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
|
|
6776
6788
|
mediaType: "application/octet-stream",
|
|
6777
6789
|
title: annotation.file_id,
|
|
6778
6790
|
filename: annotation.file_id,
|
|
@@ -6842,7 +6854,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6842
6854
|
break;
|
|
6843
6855
|
}
|
|
6844
6856
|
case "mcp_call": {
|
|
6845
|
-
const toolCallId = part.approval_request_id != null ? (
|
|
6857
|
+
const toolCallId = part.approval_request_id != null ? (_v = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _v : part.id : part.id;
|
|
6846
6858
|
const toolName = `mcp.${part.name}`;
|
|
6847
6859
|
content.push({
|
|
6848
6860
|
type: "tool-call",
|
|
@@ -6876,8 +6888,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6876
6888
|
break;
|
|
6877
6889
|
}
|
|
6878
6890
|
case "mcp_approval_request": {
|
|
6879
|
-
const approvalRequestId = (
|
|
6880
|
-
const dummyToolCallId = (
|
|
6891
|
+
const approvalRequestId = (_w = part.approval_request_id) != null ? _w : part.id;
|
|
6892
|
+
const dummyToolCallId = (_z = (_y = (_x = this.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId2();
|
|
6881
6893
|
const toolName = `mcp.${part.name}`;
|
|
6882
6894
|
content.push({
|
|
6883
6895
|
type: "tool-call",
|
|
@@ -6943,13 +6955,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6943
6955
|
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
6944
6956
|
result: {
|
|
6945
6957
|
queries: part.queries,
|
|
6946
|
-
results: (
|
|
6958
|
+
results: (_B = (_A = part.results) == null ? void 0 : _A.map((result) => ({
|
|
6947
6959
|
attributes: result.attributes,
|
|
6948
6960
|
fileId: result.file_id,
|
|
6949
6961
|
filename: result.filename,
|
|
6950
6962
|
score: result.score,
|
|
6951
6963
|
text: result.text
|
|
6952
|
-
}))) != null ?
|
|
6964
|
+
}))) != null ? _B : null
|
|
6953
6965
|
}
|
|
6954
6966
|
});
|
|
6955
6967
|
break;
|
|
@@ -7013,7 +7025,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7013
7025
|
responseId: response.id,
|
|
7014
7026
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
7015
7027
|
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
|
|
7016
|
-
...((
|
|
7028
|
+
...((_C = response.reasoning) == null ? void 0 : _C.context) != null ? { reasoningContext: response.reasoning.context } : {}
|
|
7017
7029
|
}
|
|
7018
7030
|
};
|
|
7019
7031
|
const usage = response.usage;
|
|
@@ -7021,10 +7033,10 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7021
7033
|
content,
|
|
7022
7034
|
finishReason: {
|
|
7023
7035
|
unified: mapOpenAIResponseFinishReason({
|
|
7024
|
-
finishReason: (
|
|
7036
|
+
finishReason: (_D = response.incomplete_details) == null ? void 0 : _D.reason,
|
|
7025
7037
|
hasFunctionCall
|
|
7026
7038
|
}),
|
|
7027
|
-
raw: (
|
|
7039
|
+
raw: (_F = (_E = response.incomplete_details) == null ? void 0 : _E.reason) != null ? _F : void 0
|
|
7028
7040
|
},
|
|
7029
7041
|
usage: convertOpenAIResponsesUsage(usage),
|
|
7030
7042
|
request: { body },
|
|
@@ -8861,7 +8873,7 @@ var OpenAISkills = class {
|
|
|
8861
8873
|
};
|
|
8862
8874
|
|
|
8863
8875
|
// src/version.ts
|
|
8864
|
-
var VERSION = true ? "4.0.
|
|
8876
|
+
var VERSION = true ? "4.0.16" : "0.0.0-test";
|
|
8865
8877
|
|
|
8866
8878
|
// src/openai-provider.ts
|
|
8867
8879
|
function createOpenAI(options = {}) {
|