@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/dist/internal/index.js
CHANGED
|
@@ -2000,7 +2000,12 @@ var openaiTranscriptionResponseSchema = (0, import_provider_utils15.lazyValidato
|
|
|
2000
2000
|
compression_ratio: import_v410.z.number(),
|
|
2001
2001
|
no_speech_prob: import_v410.z.number()
|
|
2002
2002
|
})
|
|
2003
|
-
).nullish()
|
|
2003
|
+
).nullish(),
|
|
2004
|
+
// Lenient: an unexpected usage shape must not fail the transcription.
|
|
2005
|
+
usage: import_v410.z.object({
|
|
2006
|
+
type: import_v410.z.string().nullish(),
|
|
2007
|
+
seconds: import_v410.z.number().nullish()
|
|
2008
|
+
}).nullish().catch(void 0)
|
|
2004
2009
|
})
|
|
2005
2010
|
)
|
|
2006
2011
|
);
|
|
@@ -2133,10 +2138,10 @@ var OpenAITranscriptionModel = class {
|
|
|
2133
2138
|
prompt: openAIOptions.prompt,
|
|
2134
2139
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
2135
2140
|
// prefer verbose_json to get segments for models that support it
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2141
|
+
// gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
|
|
2142
|
+
response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
|
|
2143
|
+
this.modelId
|
|
2144
|
+
) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
|
|
2140
2145
|
temperature: openAIOptions.temperature,
|
|
2141
2146
|
timestamp_granularities: openAIOptions.timestampGranularities
|
|
2142
2147
|
};
|
|
@@ -2158,7 +2163,7 @@ var OpenAITranscriptionModel = class {
|
|
|
2158
2163
|
};
|
|
2159
2164
|
}
|
|
2160
2165
|
async doGenerate(options) {
|
|
2161
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2166
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2162
2167
|
const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
2163
2168
|
const { formData, warnings } = await this.getArgs(options);
|
|
2164
2169
|
const {
|
|
@@ -2192,7 +2197,8 @@ var OpenAITranscriptionModel = class {
|
|
|
2192
2197
|
endSecond: word.end
|
|
2193
2198
|
}))) != null ? _g : [],
|
|
2194
2199
|
language,
|
|
2195
|
-
|
|
2200
|
+
// Duration-billed json responses report the duration only in `usage`:
|
|
2201
|
+
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,
|
|
2196
2202
|
warnings,
|
|
2197
2203
|
response: {
|
|
2198
2204
|
timestamp: currentDate,
|
|
@@ -4473,7 +4479,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4473
4479
|
type: "tool-result",
|
|
4474
4480
|
toolCallId: part.id,
|
|
4475
4481
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
4476
|
-
|
|
4482
|
+
...mapWebSearchResult(part),
|
|
4477
4483
|
providerExecuted: true
|
|
4478
4484
|
});
|
|
4479
4485
|
break;
|
|
@@ -4805,7 +4811,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4805
4811
|
type: "tool-result",
|
|
4806
4812
|
toolCallId: value.item.id,
|
|
4807
4813
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
4808
|
-
|
|
4814
|
+
...mapWebSearchResult(value.item),
|
|
4809
4815
|
providerExecuted: true
|
|
4810
4816
|
});
|
|
4811
4817
|
} else if (value.item.type === "computer_call") {
|
|
@@ -5134,6 +5140,12 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
5134
5140
|
function isErrorChunk(chunk) {
|
|
5135
5141
|
return chunk.type === "error";
|
|
5136
5142
|
}
|
|
5143
|
+
function mapWebSearchResult({
|
|
5144
|
+
action,
|
|
5145
|
+
status
|
|
5146
|
+
}) {
|
|
5147
|
+
return status === "completed" ? { result: mapWebSearchOutput(action) } : { isError: true, result: { status } };
|
|
5148
|
+
}
|
|
5137
5149
|
function mapWebSearchOutput(action) {
|
|
5138
5150
|
var _a2;
|
|
5139
5151
|
if (action == null) {
|