ai 7.0.90 → 7.0.92

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.
@@ -76,7 +76,7 @@ export async function callCompletionApi({
76
76
 
77
77
  if (!response.ok) {
78
78
  throw new Error(
79
- (await response.text()) ?? 'Failed to fetch the chat response.',
79
+ (await response.text()) || 'Failed to fetch the chat response.',
80
80
  );
81
81
  }
82
82
 
@@ -201,7 +201,7 @@ export abstract class HttpChatTransport<
201
201
 
202
202
  if (!response.ok) {
203
203
  throw new Error(
204
- (await response.text()) ?? 'Failed to fetch the chat response.',
204
+ (await response.text()) || 'Failed to fetch the chat response.',
205
205
  );
206
206
  }
207
207
 
@@ -257,7 +257,7 @@ export abstract class HttpChatTransport<
257
257
 
258
258
  if (!response.ok) {
259
259
  throw new Error(
260
- (await response.text()) ?? 'Failed to fetch the chat response.',
260
+ (await response.text()) || 'Failed to fetch the chat response.',
261
261
  );
262
262
  }
263
263
 
@@ -43,7 +43,7 @@ export function asAsyncIterableStream<T>(
43
43
  * Implements the async iterator protocol for the stream.
44
44
  * Ensures proper cleanup (cancelling and releasing the reader) on completion, early exit, or error.
45
45
  */
46
- (stream as AsyncIterableStream<T>)[Symbol.asyncIterator] = function (
46
+ (stream as unknown as AsyncIterable<T>)[Symbol.asyncIterator] = function (
47
47
  this: ReadableStream<T>,
48
48
  ): AsyncIterator<T> {
49
49
  const reader = this.getReader();
@@ -7,9 +7,13 @@ import { retryWithExponentialBackoffRespectingRetryHeaders } from '../util/retry
7
7
  export function prepareRetries({
8
8
  maxRetries,
9
9
  abortSignal,
10
+ parameter = 'maxRetries',
11
+ defaultMaxRetries = 2,
10
12
  }: {
11
13
  maxRetries: number | undefined;
12
14
  abortSignal: AbortSignal | undefined;
15
+ parameter?: string;
16
+ defaultMaxRetries?: number;
13
17
  }): {
14
18
  maxRetries: number;
15
19
  retry: RetryFunction;
@@ -17,22 +21,22 @@ export function prepareRetries({
17
21
  if (maxRetries != null) {
18
22
  if (!Number.isInteger(maxRetries)) {
19
23
  throw new InvalidArgumentError({
20
- parameter: 'maxRetries',
24
+ parameter,
21
25
  value: maxRetries,
22
- message: 'maxRetries must be an integer',
26
+ message: `${parameter} must be an integer`,
23
27
  });
24
28
  }
25
29
 
26
30
  if (maxRetries < 0) {
27
31
  throw new InvalidArgumentError({
28
- parameter: 'maxRetries',
32
+ parameter,
29
33
  value: maxRetries,
30
- message: 'maxRetries must be >= 0',
34
+ message: `${parameter} must be >= 0`,
31
35
  });
32
36
  }
33
37
  }
34
38
 
35
- const maxRetriesResult = maxRetries ?? 2;
39
+ const maxRetriesResult = maxRetries ?? defaultMaxRetries;
36
40
 
37
41
  return {
38
42
  maxRetries: maxRetriesResult,