ai 7.0.185 → 7.0.187

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{default-stop-condition-2oQvBMQu.js → default-stop-condition-CeJWqvOg.js} +19 -13
  3. package/dist/default-stop-condition-CeJWqvOg.js.map +1 -0
  4. package/dist/{index-D1zb0Eh5.d.ts → index-Dg74caoY.d.ts} +39 -11
  5. package/dist/index-Dg74caoY.d.ts.map +1 -0
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +66 -14
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/index.d.ts +1 -1
  10. package/dist/internal/index.js +1 -1
  11. package/docs/03-agents/07-workflow-agent.mdx +22 -5
  12. package/docs/03-ai-sdk-core/18-tools.mdx +20 -18
  13. package/docs/03-ai-sdk-core/32-decisions.mdx +4 -0
  14. package/docs/03-ai-sdk-core/36-transcription.mdx +12 -13
  15. package/docs/03-ai-sdk-core/36-translation.mdx +18 -23
  16. package/docs/03-ai-sdk-core/50-error-handling.mdx +6 -0
  17. package/docs/03-ai-sdk-core/60-telemetry.mdx +14 -12
  18. package/docs/04-ai-sdk-ui/21-error-handling.mdx +11 -9
  19. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +1 -1
  20. package/docs/07-reference/01-ai-sdk-core/{11-stream-translate.mdx → 11-stream-speech-translation.mdx} +9 -16
  21. package/docs/07-reference/01-ai-sdk-core/{11-stream-transcribe.mdx → 11-stream-transcription.mdx} +7 -14
  22. package/docs/07-reference/01-ai-sdk-core/index.mdx +4 -4
  23. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +14 -0
  24. package/docs/07-reference/05-ai-sdk-errors/ai-no-transcript-generated-error.mdx +1 -0
  25. package/docs/07-reference/05-ai-sdk-errors/ai-no-translation-generated-error.mdx +1 -0
  26. package/package.json +17 -13
  27. package/src/error/no-transcript-generated-error.ts +11 -2
  28. package/src/error/no-translation-generated-error.ts +13 -2
  29. package/src/generate-text/stream-text.ts +27 -0
  30. package/src/logger/deprecations.ts +2 -0
  31. package/src/model/resolve-model.ts +3 -3
  32. package/src/transcribe/index.ts +19 -1
  33. package/src/transcribe/stream-transcribe.ts +21 -11
  34. package/src/translate/index.ts +41 -3
  35. package/src/translate/stream-translate-result.ts +4 -4
  36. package/src/translate/stream-translate.ts +23 -13
  37. package/src/util/retry-with-exponential-backoff.ts +14 -9
  38. package/dist/default-stop-condition-2oQvBMQu.js.map +0 -1
  39. package/dist/index-D1zb0Eh5.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.187
4
+
5
+ ### Patch Changes
6
+
7
+ - db4d3bd: fix(ai): call speech translation, video, and reranking model factories with the default provider as their receiver when resolving model IDs, so class-based providers that read instance state no longer fail
8
+ - 8246e9a: Promote `streamSpeechTranslation` (formerly `experimental_streamTranslate`), `StreamSpeechTranslationResult`, `SpeechTranslationStreamPart`, the OpenAI and Google speech translation model exports, and the `speechTranslation()` provider shortcut to stable. The experimental names and `translation()` remain as deprecated aliases.
9
+ - f958ef0: Promote `streamTranscription` (formerly `experimental_streamTranscribe`) and the `TranscriptionModelV4Stream*` provider types to stable, with deprecated experimental aliases for backwards compatibility.
10
+ - 317a048: fix(ai): attach the provider error as the `cause` of `NoTranscriptGeneratedError` and `NoTranslationGeneratedError` when a streaming transcription or translation ends without a result after an error part, so result promise consumers can tell a provider failure from audio that produced no output
11
+ - a13a1da: fix(ai): Apply exponential backoff and respect retry headers for stream retries, including callback-directed retries. Abort retry waits when the request or stream is cancelled.
12
+ - Updated dependencies [7b2769c]
13
+ - Updated dependencies [f958ef0]
14
+ - @ai-sdk/gateway@4.0.160
15
+ - @ai-sdk/provider@4.0.40
16
+ - @ai-sdk/provider-utils@5.0.87
17
+
18
+ ## 7.0.186
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [a94c76e]
23
+ - @ai-sdk/gateway@4.0.159
24
+
3
25
  ## 7.0.185
4
26
 
5
27
  ### Patch Changes
@@ -265,6 +265,8 @@ const deprecationCodes = /* @__PURE__ */ new Map([
265
265
  ["streamObject", "AISDK_DEP_STREAM_OBJECT"],
266
266
  ["experimental_generateSpeech", "AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH"],
267
267
  ["experimental_transcribe", "AISDK_DEP_EXPERIMENTAL_TRANSCRIBE"],
268
+ ["experimental_streamTranscribe", "AISDK_DEP_EXPERIMENTAL_STREAM_TRANSCRIBE"],
269
+ ["experimental_streamTranslate", "AISDK_DEP_EXPERIMENTAL_STREAM_TRANSLATE"],
268
270
  ["\"image\" content part", "AISDK_DEP_IMAGE_CONTENT_PART"],
269
271
  ["\"tool-result\" content of type \"file-data\"", "AISDK_DEP_TOOL_RESULT_FILE_DATA"],
270
272
  ["\"tool-result\" content of type \"file-url\"", "AISDK_DEP_TOOL_RESULT_FILE_URL"],
@@ -781,9 +783,10 @@ function resolveTranscriptionModel(model) {
781
783
  }
782
784
  function resolveSpeechTranslationModel(model) {
783
785
  if (typeof model === "string") {
784
- const speechTranslationModel = (globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway).speechTranslationModel;
786
+ const provider = globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway;
787
+ const speechTranslationModel = provider.speechTranslationModel;
785
788
  if (!speechTranslationModel) throw new Error("The default provider does not support speech translation models. Please pass a provider model instance that implements the experimental speech translation model specification.");
786
- return speechTranslationModel(model);
789
+ return speechTranslationModel.call(provider, model);
787
790
  }
788
791
  if (model.specificationVersion !== "v4") {
789
792
  const unsupportedModel = model;
@@ -829,9 +832,10 @@ function resolveImageModel(model) {
829
832
  }
830
833
  function resolveVideoModel(model) {
831
834
  if (typeof model === "string") {
832
- const videoModel = (globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway).videoModel;
835
+ const provider = globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway;
836
+ const videoModel = provider.videoModel;
833
837
  if (!videoModel) throw new Error("The default provider does not support video models. Please use a Experimental_VideoModelV4 object from a provider (e.g., vertex.video(\"model-id\")).");
834
- return videoModel(model);
838
+ return videoModel.call(provider, model);
835
839
  }
836
840
  if (!["v4", "v3"].includes(model.specificationVersion)) {
837
841
  const unsupportedModel = model;
@@ -845,9 +849,10 @@ function resolveVideoModel(model) {
845
849
  }
846
850
  function resolveRerankingModel(model) {
847
851
  if (typeof model === "string") {
848
- const rerankingModel = getGlobalProvider().rerankingModel;
852
+ const provider = getGlobalProvider();
853
+ const rerankingModel = provider.rerankingModel;
849
854
  if (!rerankingModel) throw new Error("The default provider does not support reranking models. Please use a RerankingModel object from a provider (e.g., gateway.rerankingModel(\"model-id\")).");
850
- return rerankingModel(model);
855
+ return rerankingModel.call(provider, model);
851
856
  }
852
857
  if (model.specificationVersion !== "v4" && model.specificationVersion !== "v3") {
853
858
  const unsupportedModel = model;
@@ -930,7 +935,7 @@ function asEvaluationModel(model) {
930
935
  }
931
936
  //#endregion
932
937
  //#region src/version.ts
933
- const VERSION = "7.0.185";
938
+ const VERSION = "7.0.187";
934
939
  //#endregion
935
940
  //#region src/util/download/download.ts
936
941
  /**
@@ -1993,16 +1998,17 @@ function mergeAbortSignals(...signals) {
1993
1998
  }
1994
1999
  //#endregion
1995
2000
  //#region src/util/retry-with-exponential-backoff.ts
1996
- function getRetryDelayInMs({ error, exponentialBackoffDelay }) {
1997
- const headers = APICallError.isInstance(error) ? error.responseHeaders : APICallError.isInstance(error.cause) ? error.cause.responseHeaders : void 0;
2001
+ function getRetryDelayInMs({ error, responseHeaders, exponentialBackoffDelay }) {
2002
+ const headers = APICallError.isInstance(error) ? error.responseHeaders ?? responseHeaders : GatewayError.isInstance(error) && APICallError.isInstance(error.cause) ? error.cause.responseHeaders ?? responseHeaders : responseHeaders;
1998
2003
  if (!headers) return exponentialBackoffDelay;
2004
+ const normalizedHeaders = Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
1999
2005
  let ms;
2000
- const retryAfterMs = headers["retry-after-ms"];
2006
+ const retryAfterMs = normalizedHeaders["retry-after-ms"];
2001
2007
  if (retryAfterMs) {
2002
2008
  const timeoutMs = parseFloat(retryAfterMs);
2003
2009
  if (!Number.isNaN(timeoutMs)) ms = timeoutMs;
2004
2010
  }
2005
- const retryAfter = headers["retry-after"];
2011
+ const retryAfter = normalizedHeaders["retry-after"];
2006
2012
  if (retryAfter && ms === void 0) {
2007
2013
  const timeoutSeconds = parseFloat(retryAfter);
2008
2014
  if (!Number.isNaN(timeoutSeconds)) ms = timeoutSeconds * 1e3;
@@ -4233,6 +4239,6 @@ function createDefaultStopCondition(stepCount, onWarning) {
4233
4239
  };
4234
4240
  }
4235
4241
  //#endregion
4236
- export { convertToLanguageModelPrompt as $, toolSearch as A, InvalidMessageRoleError as At, setAbortTimeout as B, InvalidToolApprovalError as Bt, resolveToolApproval as C, asLanguageModelV4 as Ct, convertToReasoningOutputs as D, logWarnings as Dt, DefaultGenerateTextResult as E, createLogWarnings as Et, resolveGeneratedFileData as F, NoOutputGeneratedError as Ft, addLanguageModelUsage as G, mergeAbortSignals as H, DefaultGeneratedFile as I, MissingToolResultsError as It, standardizePrompt as J, asLanguageModelUsage as K, DefaultGeneratedFileWithType as L, ToolCallNotFoundForApprovalError as Lt, prepareToolsForToolCallers as M, UnsupportedModelVersionError as Mt, resolveToolCallerConfiguration as N, ToolCallRepairError as Nt, validateToolContext as O, notify as Ot, convertLanguageModelContent as P, NoSuchToolError as Pt, createToolModelOutput as Q, collectToolApprovals as R, InvalidToolInputError as Rt, filterIncludedContext as S, asVideoModelV4 as St, getToolCallInputSchemaInput as T, asEmbeddingModelV4 as Tt, getOwn as U, prepareRetries as V, InvalidArgumentError as Vt, addImageModelUsage as W, prepareToolChoice as X, prepareTools as Y, prepareLanguageModelCallOptions as Z, createTelemetryDispatcher as _, resolveSpeechModel as _t, createAsyncIterableStream as a, convertDataContentToUint8Array as at, AI_SDK_TELEMETRY_TRACING_CHANNEL as b, resolveVideoModel as bt, validateApprovedToolApprovals as c, download as ct, verifyToolApprovalSignature as d, resolveDecisionModel as dt, downloadAssets as et, hashCanonical as f, resolveEmbeddingModel as ft, DefaultStepResult as g, resolveRerankingModel as gt, createRestrictedTelemetryDispatcher as h, resolveLanguageModel as ht, asAsyncIterableStream as i, convertDataContentToBase64String as it, appendToolCallerMessages as j, InvalidDataContentError as jt, createToolSearchState as k, RetryError as kt, maybeSignApproval as l, VERSION as lt, isDeepEqualData as m, resolveImageModel as mt, logDefaultStopConditionWarning as n, convertToLanguageModelV4FilePart as nt, mapWithConcurrency as o, mergeObjects as ot, toResponseMessages as p, resolveExtractionModel as pt, createNullLanguageModelUsage as q, isOutputChunk as r, splitDataUrl as rt, prepareToolCallConcurrency as s, createDefaultDownloadFunction as st, createDefaultStopCondition as t, mapToolResultOutput as tt, signToolApproval as u, asEvaluationModel as ut, getGlobalTelemetryIntegrations as v, resolveSpeechTranslationModel as vt, parseToolCall as w, asImageModelV4 as wt, mergeCallbacks as x, asProviderV4 as xt, registerTelemetry as y, resolveTranscriptionModel as yt, calculateTokensPerSecond as z, InvalidToolApprovalSignatureError as zt };
4242
+ export { createToolModelOutput as $, toolSearch as A, RetryError as At, setAbortTimeout as B, InvalidToolApprovalSignatureError as Bt, resolveToolApproval as C, asVideoModelV4 as Ct, convertToReasoningOutputs as D, createLogWarnings as Dt, DefaultGenerateTextResult as E, asEmbeddingModelV4 as Et, resolveGeneratedFileData as F, NoSuchToolError as Ft, addImageModelUsage as G, getRetryDelayInMs as H, InvalidArgumentError as Ht, DefaultGeneratedFile as I, NoOutputGeneratedError as It, createNullLanguageModelUsage as J, addLanguageModelUsage as K, DefaultGeneratedFileWithType as L, MissingToolResultsError as Lt, prepareToolsForToolCallers as M, InvalidDataContentError as Mt, resolveToolCallerConfiguration as N, UnsupportedModelVersionError as Nt, validateToolContext as O, logWarnings as Ot, convertLanguageModelContent as P, ToolCallRepairError as Pt, prepareLanguageModelCallOptions as Q, collectToolApprovals as R, ToolCallNotFoundForApprovalError as Rt, filterIncludedContext as S, asProviderV4 as St, getToolCallInputSchemaInput as T, asImageModelV4 as Tt, mergeAbortSignals as U, prepareRetries as V, InvalidToolApprovalError as Vt, getOwn as W, prepareTools as X, standardizePrompt as Y, prepareToolChoice as Z, createTelemetryDispatcher as _, resolveRerankingModel as _t, createAsyncIterableStream as a, convertDataContentToBase64String as at, AI_SDK_TELEMETRY_TRACING_CHANNEL as b, resolveTranscriptionModel as bt, validateApprovedToolApprovals as c, createDefaultDownloadFunction as ct, verifyToolApprovalSignature as d, asEvaluationModel as dt, convertToLanguageModelPrompt as et, hashCanonical as f, resolveDecisionModel as ft, DefaultStepResult as g, resolveLanguageModel as gt, createRestrictedTelemetryDispatcher as h, resolveImageModel as ht, asAsyncIterableStream as i, splitDataUrl as it, appendToolCallerMessages as j, InvalidMessageRoleError as jt, createToolSearchState as k, notify as kt, maybeSignApproval as l, download as lt, isDeepEqualData as m, resolveExtractionModel as mt, logDefaultStopConditionWarning as n, mapToolResultOutput as nt, mapWithConcurrency as o, convertDataContentToUint8Array as ot, toResponseMessages as p, resolveEmbeddingModel as pt, asLanguageModelUsage as q, isOutputChunk as r, convertToLanguageModelV4FilePart as rt, prepareToolCallConcurrency as s, mergeObjects as st, createDefaultStopCondition as t, downloadAssets as tt, signToolApproval as u, VERSION as ut, getGlobalTelemetryIntegrations as v, resolveSpeechModel as vt, parseToolCall as w, asLanguageModelV4 as wt, mergeCallbacks as x, resolveVideoModel as xt, registerTelemetry as y, resolveSpeechTranslationModel as yt, calculateTokensPerSecond as z, InvalidToolInputError as zt };
4237
4243
 
4238
- //# sourceMappingURL=default-stop-condition-2oQvBMQu.js.map
4244
+ //# sourceMappingURL=default-stop-condition-CeJWqvOg.js.map