@ai-sdk/openai 2.0.136 → 2.0.138
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 +13 -0
- package/dist/index.js +22 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +21 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +21 -9
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 2.0.138
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1ff7951: fix(openai): report unfinished web searches as tool errors
|
|
8
|
+
- 1ff7951: Report failed and incomplete web searches as tool errors instead of successful tool results in OpenAI Responses API calls.
|
|
9
|
+
|
|
10
|
+
## 2.0.137
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6a87db5: Fix `gpt-transcribe` REST transcription. Requests with OpenAI provider options now use `response_format: 'json'` for `gpt-transcribe` and dated `gpt-4o-mini-transcribe` snapshots, which reject `verbose_json`. `durationInSeconds` is read from `usage.seconds` when a duration-billed response has no top-level `duration`.
|
|
15
|
+
|
|
3
16
|
## 2.0.136
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -4163,7 +4163,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4163
4163
|
type: "tool-result",
|
|
4164
4164
|
toolCallId: part.id,
|
|
4165
4165
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
4166
|
-
|
|
4166
|
+
...mapWebSearchResult(part),
|
|
4167
4167
|
providerExecuted: true
|
|
4168
4168
|
});
|
|
4169
4169
|
break;
|
|
@@ -4495,7 +4495,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4495
4495
|
type: "tool-result",
|
|
4496
4496
|
toolCallId: value.item.id,
|
|
4497
4497
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
4498
|
-
|
|
4498
|
+
...mapWebSearchResult(value.item),
|
|
4499
4499
|
providerExecuted: true
|
|
4500
4500
|
});
|
|
4501
4501
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4824,6 +4824,12 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
4824
4824
|
function isErrorChunk(chunk) {
|
|
4825
4825
|
return chunk.type === "error";
|
|
4826
4826
|
}
|
|
4827
|
+
function mapWebSearchResult({
|
|
4828
|
+
action,
|
|
4829
|
+
status
|
|
4830
|
+
}) {
|
|
4831
|
+
return status === "completed" ? { result: mapWebSearchOutput(action) } : { isError: true, result: { status } };
|
|
4832
|
+
}
|
|
4827
4833
|
function mapWebSearchOutput(action) {
|
|
4828
4834
|
var _a2;
|
|
4829
4835
|
if (action == null) {
|
|
@@ -5015,7 +5021,12 @@ var openaiTranscriptionResponseSchema = (0, import_provider_utils28.lazyValidato
|
|
|
5015
5021
|
compression_ratio: import_v420.z.number(),
|
|
5016
5022
|
no_speech_prob: import_v420.z.number()
|
|
5017
5023
|
})
|
|
5018
|
-
).nullish()
|
|
5024
|
+
).nullish(),
|
|
5025
|
+
// Lenient: an unexpected usage shape must not fail the transcription.
|
|
5026
|
+
usage: import_v420.z.object({
|
|
5027
|
+
type: import_v420.z.string().nullish(),
|
|
5028
|
+
seconds: import_v420.z.number().nullish()
|
|
5029
|
+
}).nullish().catch(void 0)
|
|
5019
5030
|
})
|
|
5020
5031
|
)
|
|
5021
5032
|
);
|
|
@@ -5148,10 +5159,10 @@ var OpenAITranscriptionModel = class {
|
|
|
5148
5159
|
prompt: openAIOptions.prompt,
|
|
5149
5160
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
5150
5161
|
// prefer verbose_json to get segments for models that support it
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5162
|
+
// gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
|
|
5163
|
+
response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
|
|
5164
|
+
this.modelId
|
|
5165
|
+
) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
|
|
5155
5166
|
temperature: openAIOptions.temperature,
|
|
5156
5167
|
timestamp_granularities: openAIOptions.timestampGranularities
|
|
5157
5168
|
};
|
|
@@ -5173,7 +5184,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5173
5184
|
};
|
|
5174
5185
|
}
|
|
5175
5186
|
async doGenerate(options) {
|
|
5176
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5187
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5177
5188
|
const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
5178
5189
|
const { formData, warnings } = await this.getArgs(options);
|
|
5179
5190
|
const {
|
|
@@ -5207,7 +5218,8 @@ var OpenAITranscriptionModel = class {
|
|
|
5207
5218
|
endSecond: word.end
|
|
5208
5219
|
}))) != null ? _g : [],
|
|
5209
5220
|
language,
|
|
5210
|
-
|
|
5221
|
+
// Duration-billed json responses report the duration only in `usage`:
|
|
5222
|
+
durationInSeconds: (_j = response.duration) != null ? _j : ((_h = response.usage) == null ? void 0 : _h.type) === "duration" ? (_i = response.usage.seconds) != null ? _i : void 0 : void 0,
|
|
5211
5223
|
warnings,
|
|
5212
5224
|
response: {
|
|
5213
5225
|
timestamp: currentDate,
|
|
@@ -5220,7 +5232,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5220
5232
|
};
|
|
5221
5233
|
|
|
5222
5234
|
// src/version.ts
|
|
5223
|
-
var VERSION = true ? "2.0.
|
|
5235
|
+
var VERSION = true ? "2.0.138" : "0.0.0-test";
|
|
5224
5236
|
|
|
5225
5237
|
// src/openai-provider.ts
|
|
5226
5238
|
function createOpenAI(options = {}) {
|