ai 7.0.94 → 7.0.96

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.
@@ -1,15 +1,21 @@
1
1
  export {
2
+ cancelBatch as experimental_cancelBatch,
2
3
  startBatch as experimental_startBatch,
3
4
  getBatchResults as experimental_getBatchResults,
4
5
  getBatchStatus as experimental_getBatchStatus,
6
+ listBatches as experimental_listBatches,
5
7
  } from './batch';
6
8
  export type {
7
9
  BatchError as Experimental_BatchError,
8
10
  BatchProvider as Experimental_BatchProvider,
9
11
  BatchReference as Experimental_BatchReference,
10
12
  BatchStatus as Experimental_BatchStatus,
13
+ CancelBatchOptions as Experimental_CancelBatchOptions,
14
+ CancelBatchResult as Experimental_CancelBatchResult,
11
15
  GetBatchResultsOptions as Experimental_GetBatchResultsOptions,
12
16
  GetBatchStatusOptions as Experimental_GetBatchStatusOptions,
17
+ ListBatchesOptions as Experimental_ListBatchesOptions,
18
+ ListBatchesResult as Experimental_ListBatchesResult,
13
19
  StartBatchOptions as Experimental_StartBatchOptions,
14
20
  StartBatchResult as Experimental_StartBatchResult,
15
21
  Batch as Experimental_Batch,
@@ -3,6 +3,7 @@ import {
3
3
  withUserAgentSuffix,
4
4
  type ProviderOptions,
5
5
  } from '@ai-sdk/provider-utils';
6
+ import { InvalidResponseDataError } from '../error';
6
7
  import { logWarnings } from '../logger/log-warnings';
7
8
  import { resolveEmbeddingModel } from '../model/resolve-model';
8
9
  import { createTelemetryDispatcher } from '../telemetry/create-telemetry-dispatcher';
@@ -221,6 +222,13 @@ export async function embed({
221
222
  callbacks: [telemetryDispatcher.onEmbedEnd],
222
223
  });
223
224
 
225
+ if (embedding == null) {
226
+ throw new InvalidResponseDataError({
227
+ data: modelResponse.embeddings,
228
+ message: 'No embedding generated.',
229
+ });
230
+ }
231
+
224
232
  return {
225
233
  embedding,
226
234
  usage,
@@ -1,3 +1,8 @@
1
+ // atob needs to be invoked as a function call, not as a method call.
2
+ // Otherwise Cloudflare will throw a
3
+ // "TypeError: Illegal invocation: function called with incorrect this reference"
4
+ const { atob } = globalThis;
5
+
1
6
  /**
2
7
  * Converts a data URL of type text/* to a text string.
3
8
  */
@@ -10,7 +15,7 @@ export function getTextFromDataUrl(dataUrl: string): string {
10
15
  }
11
16
 
12
17
  try {
13
- return globalThis.atob(base64Content);
18
+ return atob(base64Content);
14
19
  } catch {
15
20
  throw new Error(`Error decoding data URL`);
16
21
  }