@ai-sdk/openai 2.0.136 → 2.0.137
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 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +13 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +13 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2005,7 +2005,12 @@ var openaiTranscriptionResponseSchema = lazyValidator9(
|
|
|
2005
2005
|
compression_ratio: z10.number(),
|
|
2006
2006
|
no_speech_prob: z10.number()
|
|
2007
2007
|
})
|
|
2008
|
-
).nullish()
|
|
2008
|
+
).nullish(),
|
|
2009
|
+
// Lenient: an unexpected usage shape must not fail the transcription.
|
|
2010
|
+
usage: z10.object({
|
|
2011
|
+
type: z10.string().nullish(),
|
|
2012
|
+
seconds: z10.number().nullish()
|
|
2013
|
+
}).nullish().catch(void 0)
|
|
2009
2014
|
})
|
|
2010
2015
|
)
|
|
2011
2016
|
);
|
|
@@ -2141,10 +2146,10 @@ var OpenAITranscriptionModel = class {
|
|
|
2141
2146
|
prompt: openAIOptions.prompt,
|
|
2142
2147
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
2143
2148
|
// prefer verbose_json to get segments for models that support it
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2149
|
+
// gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
|
|
2150
|
+
response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
|
|
2151
|
+
this.modelId
|
|
2152
|
+
) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
|
|
2148
2153
|
temperature: openAIOptions.temperature,
|
|
2149
2154
|
timestamp_granularities: openAIOptions.timestampGranularities
|
|
2150
2155
|
};
|
|
@@ -2166,7 +2171,7 @@ var OpenAITranscriptionModel = class {
|
|
|
2166
2171
|
};
|
|
2167
2172
|
}
|
|
2168
2173
|
async doGenerate(options) {
|
|
2169
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2174
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2170
2175
|
const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
|
|
2171
2176
|
const { formData, warnings } = await this.getArgs(options);
|
|
2172
2177
|
const {
|
|
@@ -2200,7 +2205,8 @@ var OpenAITranscriptionModel = class {
|
|
|
2200
2205
|
endSecond: word.end
|
|
2201
2206
|
}))) != null ? _g : [],
|
|
2202
2207
|
language,
|
|
2203
|
-
|
|
2208
|
+
// Duration-billed json responses report the duration only in `usage`:
|
|
2209
|
+
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,
|
|
2204
2210
|
warnings,
|
|
2205
2211
|
response: {
|
|
2206
2212
|
timestamp: currentDate,
|