ai-retry 1.8.0 → 1.9.1
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/README.md +26 -19
- package/dist/{create-retryable-model-BdA-OoIc.mjs → create-retryable-model-Ch2cqC3Z.mjs} +68 -18
- package/dist/experimental/embedding-model/index.mjs +1 -1
- package/dist/experimental/embedding-model/retryables/index.d.mts +6 -6
- package/dist/experimental/image-model/index.d.mts +1 -1
- package/dist/experimental/image-model/index.mjs +1 -1
- package/dist/experimental/image-model/retryables/index.d.mts +1 -1
- package/dist/experimental/language-model/index.mjs +1 -1
- package/dist/index-D4w-HLk-.d.mts +34 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/index-CTbSMr1u.d.mts +0 -34
package/README.md
CHANGED
|
@@ -1141,28 +1141,28 @@ ai_retry.doGenerate outcome=success, attempts=2
|
|
|
1141
1141
|
|
|
1142
1142
|
**Operation span** attributes:
|
|
1143
1143
|
|
|
1144
|
-
| Attribute
|
|
1145
|
-
|
|
|
1146
|
-
| `ai_retry.operation`
|
|
1147
|
-
| `ai_retry.outcome`
|
|
1148
|
-
| `ai_retry.attempts`
|
|
1149
|
-
| `ai_retry.model.start`
|
|
1150
|
-
| `ai_retry.model.final`
|
|
1151
|
-
| `ai_retry.error.{name,message,cause.name,cause.message}` | the failing error (on failure)
|
|
1152
|
-
| `ai_retry.function.id`, `ai_retry.metadata.*`
|
|
1144
|
+
| Attribute | Description |
|
|
1145
|
+
| --------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
1146
|
+
| `ai_retry.operation` | `doGenerate`, `doStream`, or `doEmbed` |
|
|
1147
|
+
| `ai_retry.outcome` | `success` or `failure` |
|
|
1148
|
+
| `ai_retry.attempts` | total number of attempts |
|
|
1149
|
+
| `ai_retry.model.start` | the model the request started with (`provider/modelId`) |
|
|
1150
|
+
| `ai_retry.model.final` | the model that produced the final outcome |
|
|
1151
|
+
| `ai_retry.error.{name,message,status,cause.name,cause.message,cause.status}` | the failing error (on failure); `status` when it carries an HTTP status code |
|
|
1152
|
+
| `ai_retry.function.id`, `ai_retry.metadata.*` | from the telemetry settings |
|
|
1153
1153
|
|
|
1154
1154
|
**Attempt span** (`ai_retry.attempt`) attributes:
|
|
1155
1155
|
|
|
1156
|
-
| Attribute
|
|
1157
|
-
|
|
|
1158
|
-
| `ai_retry.attempt.number`
|
|
1159
|
-
| `ai_retry.attempt.model`
|
|
1160
|
-
| `ai_retry.attempt.outcome`
|
|
1161
|
-
| `ai_retry.attempt.type`
|
|
1162
|
-
| `ai_retry.attempt.finish_reason`
|
|
1163
|
-
| `ai_retry.attempt.delay_ms`
|
|
1164
|
-
| `ai_retry.attempt.timeout_ms`
|
|
1165
|
-
| `ai_retry.attempt.error.{name,message,cause.name,cause.message}` | the error (error attempts)
|
|
1156
|
+
| Attribute | Description |
|
|
1157
|
+
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
1158
|
+
| `ai_retry.attempt.number` | 1-based attempt index |
|
|
1159
|
+
| `ai_retry.attempt.model` | model used (`provider/modelId`) |
|
|
1160
|
+
| `ai_retry.attempt.outcome` | `success`, `retry`, or `failure` |
|
|
1161
|
+
| `ai_retry.attempt.type` | `result` or `error` |
|
|
1162
|
+
| `ai_retry.attempt.finish_reason` | finish reason (result attempts) |
|
|
1163
|
+
| `ai_retry.attempt.delay_ms` | backoff scheduled before the next attempt |
|
|
1164
|
+
| `ai_retry.attempt.timeout_ms` | timeout budget, when the retry set one |
|
|
1165
|
+
| `ai_retry.attempt.error.{name,message,status,cause.name,cause.message,cause.status}` | the error (error attempts); `status` when it carries an HTTP status code |
|
|
1166
1166
|
|
|
1167
1167
|
Attempt spans also carry the standard `gen_ai.request.model` / `gen_ai.provider.name` attributes so observability tools (Langfuse, etc.) recognize and render them.
|
|
1168
1168
|
|
|
@@ -1183,6 +1183,13 @@ In the second case, errors during stream processing will not always be retried,
|
|
|
1183
1183
|
> [!IMPORTANT]
|
|
1184
1184
|
> **Streaming limitation:** Retries and fallbacks only apply before the first content chunk is emitted. Once streaming begins delivering content, the response is committed to the current model. Mid-stream errors will propagate to the caller rather than triggering a fallback. If reliable retries are critical for your use case, consider using `generateText` instead of `streamText`.
|
|
1185
1185
|
|
|
1186
|
+
#### Preamble buffering
|
|
1187
|
+
|
|
1188
|
+
Every stream begins with a non-content preamble (`stream-start`, then optionally `response-metadata` and `text-start` / `reasoning-start`) that providers emit as soon as the response headers arrive, before any content flows. Because a retry can still happen during this window, `ai-retry` does not forward the preamble immediately. It buffers the leading non-content parts and flushes them only when the first content chunk arrives (or when the stream finishes with no content). If a retry fires before any content, the buffered preamble is discarded and replaced by the fallback's, so the consumer always sees exactly one preamble — the one belonging to the model that actually produced the output, with its own `warnings` and `response-metadata`. Without this, a fallback's `stream-start` would be emitted a second time after the primary's, which some consumers (e.g. `streamText`) reject.
|
|
1189
|
+
|
|
1190
|
+
> [!NOTE]
|
|
1191
|
+
> One side effect: the consumer's "stream started" signal now arrives at first-content time rather than when the response headers arrive (typically a sub-second difference). For UIs that show a typing indicator off `stream-start` this is negligible.
|
|
1192
|
+
|
|
1186
1193
|
### API Reference
|
|
1187
1194
|
|
|
1188
1195
|
#### `createRetryable(options: RetryableModelOptions): LanguageModelV3 | EmbeddingModelV3 | ImageModelV3`
|
|
@@ -311,13 +311,18 @@ function loadOtelApi() {
|
|
|
311
311
|
return otelApiPromise;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* `
|
|
314
|
+
* Normalize an unknown thrown value into the fields recorded on error spans:
|
|
315
|
+
* - `name`: the error class name (e.g. `AI_APICallError`, `TimeoutError`), or
|
|
316
|
+
* `typeof` for non-`Error` values.
|
|
317
|
+
* - `message`: the error message.
|
|
318
|
+
* - `status`: HTTP status code, when the error carries one (e.g. `APICallError`).
|
|
317
319
|
*/
|
|
318
|
-
function
|
|
319
|
-
|
|
320
|
-
|
|
320
|
+
function describeError(error) {
|
|
321
|
+
return {
|
|
322
|
+
name: error instanceof Error ? error.name : typeof error,
|
|
323
|
+
message: error instanceof Error ? error.message : String(error),
|
|
324
|
+
status: typeof error === "object" && error !== null && "statusCode" in error && typeof error.statusCode === "number" ? error.statusCode : void 0
|
|
325
|
+
};
|
|
321
326
|
}
|
|
322
327
|
/**
|
|
323
328
|
* Translates retry telemetry events into OpenTelemetry spans.
|
|
@@ -394,18 +399,22 @@ var OpenTelemetrySink = class {
|
|
|
394
399
|
}
|
|
395
400
|
#recordError(span, error, errorAttribute) {
|
|
396
401
|
const exception = error instanceof Error ? error : new Error(String(error));
|
|
397
|
-
|
|
398
|
-
span.setAttribute(`${errorAttribute}.
|
|
402
|
+
const info = describeError(error);
|
|
403
|
+
span.setAttribute(`${errorAttribute}.name`, info.name);
|
|
404
|
+
span.setAttribute(`${errorAttribute}.message`, info.message);
|
|
405
|
+
if (info.status !== void 0) span.setAttribute(`${errorAttribute}.status`, info.status);
|
|
399
406
|
/** One level of the error chain — the underlying cause, when present. */
|
|
400
407
|
const cause = error instanceof Error ? error.cause : void 0;
|
|
401
408
|
if (cause !== void 0) {
|
|
402
|
-
|
|
403
|
-
span.setAttribute(`${errorAttribute}.cause.
|
|
409
|
+
const causeInfo = describeError(cause);
|
|
410
|
+
span.setAttribute(`${errorAttribute}.cause.name`, causeInfo.name);
|
|
411
|
+
span.setAttribute(`${errorAttribute}.cause.message`, causeInfo.message);
|
|
412
|
+
if (causeInfo.status !== void 0) span.setAttribute(`${errorAttribute}.cause.status`, causeInfo.status);
|
|
404
413
|
}
|
|
405
414
|
span.recordException(exception);
|
|
406
415
|
span.setStatus({
|
|
407
416
|
code: this.#api.SpanStatusCode.ERROR,
|
|
408
|
-
message:
|
|
417
|
+
message: info.message
|
|
409
418
|
});
|
|
410
419
|
}
|
|
411
420
|
};
|
|
@@ -1193,6 +1202,16 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
1193
1202
|
let capturedWarnings = [];
|
|
1194
1203
|
let capturedResponseMetadata = {};
|
|
1195
1204
|
/**
|
|
1205
|
+
* Buffer for the leading non-content parts (`stream-start`,
|
|
1206
|
+
* `response-metadata`, `text-start`, `reasoning-start`, …) of this
|
|
1207
|
+
* attempt. While no content has been forwarded the preamble is held
|
|
1208
|
+
* here rather than enqueued, so a pre-content retry can discard it
|
|
1209
|
+
* and the consumer sees exactly one preamble — the one belonging to
|
|
1210
|
+
* the model that actually produced the output. Reset per attempt;
|
|
1211
|
+
* flushed on the first content part or at completion.
|
|
1212
|
+
*/
|
|
1213
|
+
let preambleBuffer = [];
|
|
1214
|
+
/**
|
|
1196
1215
|
* Set when a `finish` part triggers a retry decision. Causes the
|
|
1197
1216
|
* inner read loop to exit without enqueuing the finish part, and
|
|
1198
1217
|
* the outer loop to re-stream against the next model.
|
|
@@ -1261,11 +1280,25 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
1261
1280
|
}
|
|
1262
1281
|
}
|
|
1263
1282
|
/**
|
|
1264
|
-
* Mark that streaming has started once we receive actual
|
|
1283
|
+
* Mark that streaming has started once we receive actual
|
|
1284
|
+
* content. On the first content part, flush this attempt's
|
|
1285
|
+
* buffered preamble (in order) ahead of the content, then
|
|
1286
|
+
* forward normally from here on.
|
|
1265
1287
|
*/
|
|
1266
|
-
if (isStreamContentPart(value))
|
|
1267
|
-
|
|
1268
|
-
|
|
1288
|
+
if (isStreamContentPart(value)) {
|
|
1289
|
+
isStreaming = true;
|
|
1290
|
+
for (const buffered of preambleBuffer) controller.enqueue(buffered);
|
|
1291
|
+
preambleBuffer = [];
|
|
1292
|
+
controller.enqueue(value);
|
|
1293
|
+
} else if (!isStreaming)
|
|
1294
|
+
/**
|
|
1295
|
+
* Pre-content part: buffer it so a pre-content retry can
|
|
1296
|
+
* replace it with the next attempt's preamble.
|
|
1297
|
+
*/
|
|
1298
|
+
preambleBuffer.push(value);
|
|
1299
|
+
else
|
|
1300
|
+
/**
|
|
1301
|
+
* Content already flowing: forward directly.
|
|
1269
1302
|
*/
|
|
1270
1303
|
controller.enqueue(value);
|
|
1271
1304
|
}
|
|
@@ -1297,7 +1330,13 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
1297
1330
|
currentRetry,
|
|
1298
1331
|
recorder
|
|
1299
1332
|
});
|
|
1300
|
-
|
|
1333
|
+
/**
|
|
1334
|
+
* Cancelling a reader whose stream has already errored (e.g.
|
|
1335
|
+
* a mid-stream `controller.error`) rejects with that stored
|
|
1336
|
+
* error. Swallow it: the retry already succeeded and that
|
|
1337
|
+
* rejection must not abort the wrapped stream.
|
|
1338
|
+
*/
|
|
1339
|
+
await reader?.cancel().catch(() => {});
|
|
1301
1340
|
result = retriedResult.result;
|
|
1302
1341
|
attempts = retriedResult.attempts;
|
|
1303
1342
|
finalCallOptions = retriedResult.callOptions;
|
|
@@ -1309,6 +1348,13 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
1309
1348
|
outcome: "success",
|
|
1310
1349
|
finishReason: streamFinishReason
|
|
1311
1350
|
});
|
|
1351
|
+
/**
|
|
1352
|
+
* A stream that completes with no content part still has its
|
|
1353
|
+
* preamble buffered. Flush it so a zero-content completion emits
|
|
1354
|
+
* its `stream-start` (and any metadata/finish) before closing.
|
|
1355
|
+
*/
|
|
1356
|
+
for (const buffered of preambleBuffer) controller.enqueue(buffered);
|
|
1357
|
+
preambleBuffer = [];
|
|
1312
1358
|
controller.close();
|
|
1313
1359
|
break;
|
|
1314
1360
|
} catch (error) {
|
|
@@ -1399,9 +1445,13 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
1399
1445
|
recorder
|
|
1400
1446
|
});
|
|
1401
1447
|
/**
|
|
1402
|
-
* Cancel the previous reader and stream if we are retrying
|
|
1448
|
+
* Cancel the previous reader and stream if we are retrying.
|
|
1449
|
+
* Cancelling a reader whose stream has already errored (e.g. a
|
|
1450
|
+
* mid-stream `controller.error`) rejects with that stored
|
|
1451
|
+
* error. Swallow it: the retry already succeeded and that
|
|
1452
|
+
* rejection must not abort the wrapped stream.
|
|
1403
1453
|
*/
|
|
1404
|
-
await reader?.cancel();
|
|
1454
|
+
await reader?.cancel().catch(() => {});
|
|
1405
1455
|
result = retriedResult.result;
|
|
1406
1456
|
attempts = retriedResult.attempts;
|
|
1407
1457
|
finalCallOptions = retriedResult.callOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createRetryable$1 } from "../../create-retryable-model-
|
|
1
|
+
import { t as createRetryable$1 } from "../../create-retryable-model-Ch2cqC3Z.mjs";
|
|
2
2
|
import "../../error-CaTT-xX8.mjs";
|
|
3
3
|
import { aborted, error, httpStatus, timeout } from "./retryables/index.mjs";
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { k as RetryContext } from "../../../types-ydxC71oc.mjs";
|
|
2
2
|
import { n as Condition, t as StatusPattern } from "../../../error-CoF13EJO.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _ai_sdk_provider0 from "@ai-sdk/provider";
|
|
4
4
|
|
|
5
5
|
//#region src/experimental/embedding-model/retryables/index.d.ts
|
|
6
6
|
/**
|
|
@@ -11,10 +11,10 @@ import * as _ai_sdk_provider13 from "@ai-sdk/provider";
|
|
|
11
11
|
* from 'ai-retry/experimental/embedding-model/retryables';
|
|
12
12
|
*/
|
|
13
13
|
declare const error: {
|
|
14
|
-
<MODEL extends
|
|
15
|
-
isRetryable<MODEL extends
|
|
16
|
-
statusCode<MODEL extends
|
|
17
|
-
message<MODEL extends
|
|
18
|
-
}, httpStatus: <MODEL extends
|
|
14
|
+
<MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3, E = unknown>(predicate: (err: E, ctx: RetryContext<MODEL>) => boolean | Promise<boolean>): Condition<MODEL>;
|
|
15
|
+
isRetryable<MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3>(flag?: boolean): Condition<MODEL>;
|
|
16
|
+
statusCode<MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3>(...patterns: Array<number | RegExp>): Condition<MODEL>;
|
|
17
|
+
message<MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3>(...patterns: Array<string | RegExp>): Condition<MODEL>;
|
|
18
|
+
}, httpStatus: <MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3>(...patterns: Array<StatusPattern>) => Condition<MODEL>, timeout: <MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3>() => Condition<MODEL>, aborted: <MODEL extends _ai_sdk_provider0.EmbeddingModelV3 = _ai_sdk_provider0.EmbeddingModelV3>() => Condition<MODEL>;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { aborted, error, httpStatus, timeout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as RetryableModelOptions, s as ImageModel } from "../../types-ydxC71oc.mjs";
|
|
2
2
|
import "../../error-CoF13EJO.mjs";
|
|
3
|
-
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../index-
|
|
3
|
+
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../index-D4w-HLk-.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/experimental/image-model/index.d.ts
|
|
6
6
|
declare function createRetryable<MODEL extends ImageModel>(options: RetryableModelOptions<MODEL>): ImageModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createRetryable$1 } from "../../create-retryable-model-
|
|
1
|
+
import { t as createRetryable$1 } from "../../create-retryable-model-Ch2cqC3Z.mjs";
|
|
2
2
|
import "../../error-CaTT-xX8.mjs";
|
|
3
3
|
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../retryables-CPAbu_M3.mjs";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../../types-ydxC71oc.mjs";
|
|
2
2
|
import "../../../error-CoF13EJO.mjs";
|
|
3
|
-
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../../index-
|
|
3
|
+
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../../index-D4w-HLk-.mjs";
|
|
4
4
|
export { aborted, error, httpStatus, noImage, timeout };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createRetryable$1 } from "../../create-retryable-model-
|
|
1
|
+
import { t as createRetryable$1 } from "../../create-retryable-model-Ch2cqC3Z.mjs";
|
|
2
2
|
import "../../error-CaTT-xX8.mjs";
|
|
3
3
|
import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../retryables-M5l_6w9k.mjs";
|
|
4
4
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { k as RetryContext, s as ImageModel } from "./types-ydxC71oc.mjs";
|
|
2
|
+
import { n as Condition, t as StatusPattern } from "./error-CoF13EJO.mjs";
|
|
3
|
+
import * as _ai_sdk_provider13 from "@ai-sdk/provider";
|
|
4
|
+
|
|
5
|
+
//#region src/experimental/internal/no-image.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Match when image generation produced no images
|
|
8
|
+
* (`NoImageGeneratedError`).
|
|
9
|
+
*
|
|
10
|
+
* **Important:** returns a `Condition`, not a `Retryable`. Call
|
|
11
|
+
* `.switch()` or `.retry()` to plug it into `retries: [...]`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* noImage().switch({ model: fallback })
|
|
15
|
+
* noImage().retry({ maxAttempts: 3 })
|
|
16
|
+
*/
|
|
17
|
+
declare function noImage<MODEL extends ImageModel = ImageModel>(): Condition<MODEL>;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/experimental/image-model/retryables/index.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* Experimental composable conditions bound to `ImageModel`. For use with
|
|
22
|
+
* `generateImage`.
|
|
23
|
+
*
|
|
24
|
+
* import { error, noImage, ... }
|
|
25
|
+
* from 'ai-retry/experimental/image-model/retryables';
|
|
26
|
+
*/
|
|
27
|
+
declare const error: {
|
|
28
|
+
<MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3, E = unknown>(predicate: (err: E, ctx: RetryContext<MODEL>) => boolean | Promise<boolean>): Condition<MODEL>;
|
|
29
|
+
isRetryable<MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3>(flag?: boolean): Condition<MODEL>;
|
|
30
|
+
statusCode<MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3>(...patterns: Array<number | RegExp>): Condition<MODEL>;
|
|
31
|
+
message<MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3>(...patterns: Array<string | RegExp>): Condition<MODEL>;
|
|
32
|
+
}, httpStatus: <MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3>(...patterns: Array<StatusPattern>) => Condition<MODEL>, timeout: <MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3>() => Condition<MODEL>, aborted: <MODEL extends _ai_sdk_provider13.ImageModelV3 = _ai_sdk_provider13.ImageModelV3>() => Condition<MODEL>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { noImage as a, timeout as i, error as n, httpStatus as r, aborted as t };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getModelKey, t as createRetryable } from "./create-retryable-model-
|
|
1
|
+
import { n as getModelKey, t as createRetryable } from "./create-retryable-model-Ch2cqC3Z.mjs";
|
|
2
2
|
import { n as isErrorAttempt, s as isResultAttempt } from "./guards-D8UJtxDK.mjs";
|
|
3
3
|
|
|
4
4
|
export { createRetryable, getModelKey, isErrorAttempt, isResultAttempt };
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { k as RetryContext, s as ImageModel } from "./types-ydxC71oc.mjs";
|
|
2
|
-
import { n as Condition, t as StatusPattern } from "./error-CoF13EJO.mjs";
|
|
3
|
-
import * as _ai_sdk_provider0 from "@ai-sdk/provider";
|
|
4
|
-
|
|
5
|
-
//#region src/experimental/internal/no-image.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Match when image generation produced no images
|
|
8
|
-
* (`NoImageGeneratedError`).
|
|
9
|
-
*
|
|
10
|
-
* **Important:** returns a `Condition`, not a `Retryable`. Call
|
|
11
|
-
* `.switch()` or `.retry()` to plug it into `retries: [...]`.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* noImage().switch({ model: fallback })
|
|
15
|
-
* noImage().retry({ maxAttempts: 3 })
|
|
16
|
-
*/
|
|
17
|
-
declare function noImage<MODEL extends ImageModel = ImageModel>(): Condition<MODEL>;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/experimental/image-model/retryables/index.d.ts
|
|
20
|
-
/**
|
|
21
|
-
* Experimental composable conditions bound to `ImageModel`. For use with
|
|
22
|
-
* `generateImage`.
|
|
23
|
-
*
|
|
24
|
-
* import { error, noImage, ... }
|
|
25
|
-
* from 'ai-retry/experimental/image-model/retryables';
|
|
26
|
-
*/
|
|
27
|
-
declare const error: {
|
|
28
|
-
<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3, E = unknown>(predicate: (err: E, ctx: RetryContext<MODEL>) => boolean | Promise<boolean>): Condition<MODEL>;
|
|
29
|
-
isRetryable<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(flag?: boolean): Condition<MODEL>;
|
|
30
|
-
statusCode<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(...patterns: Array<number | RegExp>): Condition<MODEL>;
|
|
31
|
-
message<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(...patterns: Array<string | RegExp>): Condition<MODEL>;
|
|
32
|
-
}, httpStatus: <MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(...patterns: Array<StatusPattern>) => Condition<MODEL>, timeout: <MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>() => Condition<MODEL>, aborted: <MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>() => Condition<MODEL>;
|
|
33
|
-
//#endregion
|
|
34
|
-
export { noImage as a, timeout as i, error as n, httpStatus as r, aborted as t };
|