ai-retry 1.7.0 → 1.7.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 +37 -35
- package/dist/{create-retryable-model-CgYBIeV6.mjs → create-retryable-model-HLobeUXU.mjs} +36 -19
- 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.d.mts +1 -1
- package/dist/experimental/language-model/index.mjs +1 -1
- package/dist/experimental/language-model/retryables/index.d.mts +1 -1
- package/dist/{index-DOM9pSF9.d.mts → index-DfqLMa2f.d.mts} +6 -6
- package/dist/index-DmNbfl6t.d.mts +30 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/index-Dvxg4bnp.d.mts +0 -30
package/README.md
CHANGED
|
@@ -598,13 +598,20 @@ console.log(result.object); // { name: "Alice", age: 30 }
|
|
|
598
598
|
> Each entry point also re-exports `createRetryable` already typed for that model family, so you can either import everything from one path:
|
|
599
599
|
>
|
|
600
600
|
> ```ts
|
|
601
|
-
> import {
|
|
601
|
+
> import {
|
|
602
|
+
> createRetryable,
|
|
603
|
+
> error,
|
|
604
|
+
> httpStatus,
|
|
605
|
+
> } from 'ai-retry/experimental/language-model';
|
|
602
606
|
> ```
|
|
603
607
|
>
|
|
604
608
|
> or pull retryables from the dedicated `/retryables` subpath:
|
|
605
609
|
>
|
|
606
610
|
> ```ts
|
|
607
|
-
> import {
|
|
611
|
+
> import {
|
|
612
|
+
> error,
|
|
613
|
+
> httpStatus,
|
|
614
|
+
> } from 'ai-retry/experimental/language-model/retryables';
|
|
608
615
|
> // or
|
|
609
616
|
> import * as retryables from 'ai-retry/experimental/language-model/retryables';
|
|
610
617
|
> ```
|
|
@@ -647,14 +654,14 @@ Pick the entry point that matches the model you pass to `createRetryable`. Each
|
|
|
647
654
|
|
|
648
655
|
The primitive builders `error(...)` and `result(...)` take a predicate and turn it into a condition; their namespaces bundle the most common field matchers on top.
|
|
649
656
|
|
|
650
|
-
| Helper | Matches when
|
|
651
|
-
| --------------------------------- |
|
|
652
|
-
| `error(predicate)` | The current attempt failed and `predicate(err, ctx)` returns true
|
|
653
|
-
| `error.isRetryable(flag)` | `APICallError.isRetryable === flag` (default `true`)
|
|
654
|
-
| `error.statusCode(...patterns)` | Numbers match exactly; regex matches the stringified code (e.g. `/^5\d\d$/` for 5xx)
|
|
655
|
-
| `error.message(...patterns)` | Substring (case-insensitive) or regex match against the error message
|
|
656
|
-
| `result(predicate)` | The current attempt succeeded and `predicate(res, ctx)` returns true
|
|
657
|
-
| `result.finishReason(...reasons)` | The result's `finishReason.unified` matches one of the given values
|
|
657
|
+
| Helper | Matches when | Available in |
|
|
658
|
+
| --------------------------------- | ------------------------------------------------------------------------------------ | ---------------------- |
|
|
659
|
+
| `error(predicate)` | The current attempt failed and `predicate(err, ctx)` returns true | all three entry points |
|
|
660
|
+
| `error.isRetryable(flag)` | `APICallError.isRetryable === flag` (default `true`) | all three entry points |
|
|
661
|
+
| `error.statusCode(...patterns)` | Numbers match exactly; regex matches the stringified code (e.g. `/^5\d\d$/` for 5xx) | all three entry points |
|
|
662
|
+
| `error.message(...patterns)` | Substring (case-insensitive) or regex match against the error message | all three entry points |
|
|
663
|
+
| `result(predicate)` | The current attempt succeeded and `predicate(res, ctx)` returns true | `language-model` only |
|
|
664
|
+
| `result.finishReason(...reasons)` | The result's `finishReason.unified` matches one of the given values | `language-model` only |
|
|
658
665
|
|
|
659
666
|
```typescript
|
|
660
667
|
import { APICallError } from 'ai';
|
|
@@ -680,22 +687,20 @@ Convenience matchers built on top of the low-level ones for the common cases. Ea
|
|
|
680
687
|
|
|
681
688
|
What each one matches:
|
|
682
689
|
|
|
683
|
-
| Helper | Matches when
|
|
684
|
-
| -------------------------- |
|
|
685
|
-
| `httpStatus(...patterns)` | Numbers match the status code; strings match the message (substring); regex matches either
|
|
686
|
-
| `timeout()` | `Error.name === 'TimeoutError'` (`AbortSignal.timeout()` fired)
|
|
687
|
-
| `aborted()` | `Error.name === 'AbortError'` (manual `controller.abort()`)
|
|
688
|
-
| `finishReason(...reasons)` | The result's `finishReason.unified` matches one of the given values
|
|
689
|
-
| `schemaInvalid()` | The result text fails JSON-schema validation against the call's `responseFormat`
|
|
690
|
-
| `noImage()` | The image model threw `NoImageGeneratedError`
|
|
690
|
+
| Helper | Matches when |
|
|
691
|
+
| -------------------------- | ------------------------------------------------------------------------------------------ |
|
|
692
|
+
| `httpStatus(...patterns)` | Numbers match the status code; strings match the message (substring); regex matches either |
|
|
693
|
+
| `timeout()` | `Error.name === 'TimeoutError'` (`AbortSignal.timeout()` fired) |
|
|
694
|
+
| `aborted()` | `Error.name === 'AbortError'` (manual `controller.abort()`) |
|
|
695
|
+
| `finishReason(...reasons)` | The result's `finishReason.unified` matches one of the given values |
|
|
696
|
+
| `schemaInvalid()` | The result text fails JSON-schema validation against the call's `responseFormat` |
|
|
697
|
+
| `noImage()` | The image model threw `NoImageGeneratedError` |
|
|
691
698
|
|
|
692
699
|
Each high-level helper is a thin wrapper around the low-level ones. For example, `timeout()` is roughly:
|
|
693
700
|
|
|
694
701
|
```typescript
|
|
695
702
|
function timeout() {
|
|
696
|
-
return error(
|
|
697
|
-
(err) => err instanceof Error && err.name === 'TimeoutError',
|
|
698
|
-
);
|
|
703
|
+
return error((err) => err instanceof Error && err.name === 'TimeoutError');
|
|
699
704
|
}
|
|
700
705
|
```
|
|
701
706
|
|
|
@@ -719,10 +724,7 @@ Every condition exposes two terminal actions that turn it into a `Retryable`:
|
|
|
719
724
|
Compose conditions with `.and`, `.or`, `.not`:
|
|
720
725
|
|
|
721
726
|
```typescript
|
|
722
|
-
import {
|
|
723
|
-
error,
|
|
724
|
-
httpStatus,
|
|
725
|
-
} from 'ai-retry/experimental/language-model';
|
|
727
|
+
import { error, httpStatus } from 'ai-retry/experimental/language-model';
|
|
726
728
|
|
|
727
729
|
httpStatus(429).or(error.message('overloaded'));
|
|
728
730
|
httpStatus(503).and(error.message('temporary'));
|
|
@@ -733,16 +735,16 @@ error.isRetryable(true).not();
|
|
|
733
735
|
|
|
734
736
|
Each stable retryable has an equivalent in the new shape (imports from `ai-retry/experimental/language-model` unless noted):
|
|
735
737
|
|
|
736
|
-
| Built-in
|
|
737
|
-
|
|
|
738
|
-
| `contentFilterTriggered(m)`
|
|
739
|
-
| `requestTimeout(m)`
|
|
740
|
-
| `requestNotRetryable(m)`
|
|
741
|
-
| `schemaMismatch(m)`
|
|
742
|
-
| `serviceOverloaded(m)`
|
|
743
|
-
| `serviceUnavailable(m)`
|
|
744
|
-
| `noImageGenerated(m)`
|
|
745
|
-
| `retryAfterDelay({ delay, backoffFactor })`
|
|
738
|
+
| Built-in | Composable form |
|
|
739
|
+
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
740
|
+
| `contentFilterTriggered(m)` | `error(/* check e.data.error.code === 'content_filter' */).or(finishReason('content-filter')).switch({ model: m })` |
|
|
741
|
+
| `requestTimeout(m)` | `timeout().switch({ model: m, timeout: 60_000 })` |
|
|
742
|
+
| `requestNotRetryable(m)` | `error.isRetryable(false).switch({ model: m })` |
|
|
743
|
+
| `schemaMismatch(m)` | `schemaInvalid().switch({ model: m })` |
|
|
744
|
+
| `serviceOverloaded(m)` | `httpStatus(529, 'overloaded').switch({ model: m })` |
|
|
745
|
+
| `serviceUnavailable(m)` | `error.statusCode(503).switch({ model: m })` |
|
|
746
|
+
| `noImageGenerated(m)` | `noImage().switch({ model: m })` (from `image-model`) |
|
|
747
|
+
| `retryAfterDelay({ delay, backoffFactor })` | `error.isRetryable(true).retry({ delay, backoffFactor })` |
|
|
746
748
|
|
|
747
749
|
> [!NOTE]
|
|
748
750
|
> `error.isRetryable(true)` matches whatever the AI SDK's `APICallError` marks retryable. By default that's status codes 408, 409, 429, and any 5xx, plus network errors and provider-specific overrides (e.g. Anthropic flips it on `error.type === 'overloaded_error'`). It picks up more cases than a manual status-code list.
|
|
@@ -664,8 +664,9 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
664
664
|
callOptions: retryCallOptions
|
|
665
665
|
};
|
|
666
666
|
} catch (error) {
|
|
667
|
-
const { retryModel, attempt } = await this.handleError(error, attempts, retryCallOptions);
|
|
667
|
+
const { retryModel, attempt, finalError } = await this.handleError(error, attempts, retryCallOptions);
|
|
668
668
|
attempts.push(attempt);
|
|
669
|
+
if (!retryModel) throw finalError;
|
|
669
670
|
/**
|
|
670
671
|
* If the inbound abort signal is already aborted and the chosen
|
|
671
672
|
* retry does not supply a fresh deadline, the retry would die
|
|
@@ -706,7 +707,13 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
706
707
|
};
|
|
707
708
|
}
|
|
708
709
|
/**
|
|
709
|
-
* Handle an error and determine if a retry is needed
|
|
710
|
+
* Handle an error and determine if a retry is needed.
|
|
711
|
+
*
|
|
712
|
+
* Returns a `finalError` (and undefined `retryModel`) when no retry
|
|
713
|
+
* matched, so callers can decide how to surface it: throwing for the
|
|
714
|
+
* generate path, or enqueuing a `{ type: 'error' }` stream part for
|
|
715
|
+
* the stream path. If multiple attempts were made, the original error
|
|
716
|
+
* is wrapped in a `RetryError`.
|
|
710
717
|
*/
|
|
711
718
|
async handleError(error, attempts, callOptions) {
|
|
712
719
|
const errorAttempt = {
|
|
@@ -715,9 +722,6 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
715
722
|
model: this.currentModel,
|
|
716
723
|
options: callOptions
|
|
717
724
|
};
|
|
718
|
-
/**
|
|
719
|
-
* Save the current attempt
|
|
720
|
-
*/
|
|
721
725
|
const updatedAttempts = [...attempts, errorAttempt];
|
|
722
726
|
const context = {
|
|
723
727
|
current: errorAttempt,
|
|
@@ -725,17 +729,10 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
725
729
|
};
|
|
726
730
|
this.options.onError?.(context);
|
|
727
731
|
const retryModel = await findRetryModel(this.options.retries, context);
|
|
728
|
-
/**
|
|
729
|
-
* Handler didn't return any models to try next, rethrow the error.
|
|
730
|
-
* If we retried the request, wrap the error into a `RetryError` for better visibility.
|
|
731
|
-
*/
|
|
732
|
-
if (!retryModel) {
|
|
733
|
-
if (updatedAttempts.length > 1) throw prepareRetryError(error, updatedAttempts);
|
|
734
|
-
throw error;
|
|
735
|
-
}
|
|
736
732
|
return {
|
|
737
733
|
retryModel,
|
|
738
|
-
attempt: errorAttempt
|
|
734
|
+
attempt: errorAttempt,
|
|
735
|
+
finalError: retryModel ? void 0 : updatedAttempts.length > 1 ? prepareRetryError(error, updatedAttempts) : error
|
|
739
736
|
};
|
|
740
737
|
}
|
|
741
738
|
async doGenerate(callOptions) {
|
|
@@ -916,20 +913,40 @@ var RetryableLanguageModel = class extends BaseRetryableModel {
|
|
|
916
913
|
});
|
|
917
914
|
/**
|
|
918
915
|
* Check if the error from the stream can be retried.
|
|
919
|
-
* Otherwise it will rethrow the error.
|
|
920
916
|
*/
|
|
921
|
-
const { retryModel, attempt } = await this.handleError(error, attempts, retryCallOptions);
|
|
917
|
+
const { retryModel, attempt, finalError } = await this.handleError(error, attempts, retryCallOptions);
|
|
922
918
|
/**
|
|
923
919
|
* Save the attempt
|
|
924
920
|
*/
|
|
925
921
|
attempts.push(attempt);
|
|
926
922
|
/**
|
|
923
|
+
* No retry matched. Surface the error as a stream part so
|
|
924
|
+
* `streamText`'s `onError` fires for the consumer. Throwing
|
|
925
|
+
* here would escape `start()` and become a stream rejection,
|
|
926
|
+
* which silently bypasses `onError`.
|
|
927
|
+
*/
|
|
928
|
+
if (!retryModel) {
|
|
929
|
+
controller.enqueue({
|
|
930
|
+
type: "error",
|
|
931
|
+
error: finalError
|
|
932
|
+
});
|
|
933
|
+
controller.close();
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
927
937
|
* If the inbound abort signal is already aborted and the chosen
|
|
928
938
|
* retry does not supply a fresh deadline, the retry would die
|
|
929
|
-
* instantly with the same abort.
|
|
930
|
-
* misleading retry against a dead signal.
|
|
939
|
+
* instantly with the same abort. Surface the error rather than
|
|
940
|
+
* fire a misleading retry against a dead signal.
|
|
931
941
|
*/
|
|
932
|
-
if (callOptions.abortSignal?.aborted && retryModel.timeout === void 0)
|
|
942
|
+
if (callOptions.abortSignal?.aborted && retryModel.timeout === void 0) {
|
|
943
|
+
controller.enqueue({
|
|
944
|
+
type: "error",
|
|
945
|
+
error
|
|
946
|
+
});
|
|
947
|
+
controller.close();
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
933
950
|
if (retryModel.delay) {
|
|
934
951
|
/**
|
|
935
952
|
* Calculate exponential backoff delay based on the number of attempts for this specific model.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createRetryable$1 } from "../../create-retryable-model-
|
|
1
|
+
import { t as createRetryable$1 } from "../../create-retryable-model-HLobeUXU.mjs";
|
|
2
2
|
import "../../error-_63RHJTp.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-DYMm5YMu.mjs";
|
|
2
2
|
import { n as Condition, t as StatusPattern } from "../../../error-CPbAtI-h.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 { N as RetryableModelOptions, s as ImageModel } from "../../types-DYMm5YMu.mjs";
|
|
2
2
|
import "../../error-CPbAtI-h.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-DmNbfl6t.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-HLobeUXU.mjs";
|
|
2
2
|
import "../../error-_63RHJTp.mjs";
|
|
3
3
|
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../retryables-D0wMy6Qt.mjs";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../../types-DYMm5YMu.mjs";
|
|
2
2
|
import "../../../error-CPbAtI-h.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-DmNbfl6t.mjs";
|
|
4
4
|
export { aborted, error, httpStatus, noImage, timeout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { N as RetryableModelOptions, d as LanguageModel, o as GatewayLanguageModelId } from "../../types-DYMm5YMu.mjs";
|
|
2
2
|
import "../../error-CPbAtI-h.mjs";
|
|
3
|
-
import { a as schemaInvalid, i as timeout, n as error, o as finishReason, r as httpStatus, s as result, t as aborted } from "../../index-
|
|
3
|
+
import { a as schemaInvalid, i as timeout, n as error, o as finishReason, r as httpStatus, s as result, t as aborted } from "../../index-DfqLMa2f.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/experimental/language-model/index.d.ts
|
|
6
6
|
declare function createRetryable(options: Omit<RetryableModelOptions<LanguageModel>, 'model'> & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createRetryable$1 } from "../../create-retryable-model-
|
|
1
|
+
import { t as createRetryable$1 } from "../../create-retryable-model-HLobeUXU.mjs";
|
|
2
2
|
import "../../error-_63RHJTp.mjs";
|
|
3
3
|
import { a as schemaInvalid, i as timeout, n as error, o as finishReason, r as httpStatus, s as result, t as aborted } from "../../retryables-nm5-elvB.mjs";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../../types-DYMm5YMu.mjs";
|
|
2
2
|
import "../../../error-CPbAtI-h.mjs";
|
|
3
|
-
import { a as schemaInvalid, i as timeout, n as error, o as finishReason, r as httpStatus, s as result, t as aborted } from "../../../index-
|
|
3
|
+
import { a as schemaInvalid, i as timeout, n as error, o as finishReason, r as httpStatus, s as result, t as aborted } from "../../../index-DfqLMa2f.mjs";
|
|
4
4
|
export { aborted, error, finishReason, httpStatus, result, schemaInvalid, timeout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { k as RetryContext, m as LanguageModelResult, x as ResolvableLanguageModel } from "./types-DYMm5YMu.mjs";
|
|
2
2
|
import { n as Condition, t as StatusPattern } from "./error-CPbAtI-h.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _ai_sdk_provider13 from "@ai-sdk/provider";
|
|
4
4
|
|
|
5
5
|
//#region src/experimental/internal/result.d.ts
|
|
6
6
|
/**
|
|
@@ -51,10 +51,10 @@ declare function schemaInvalid<MODEL extends ResolvableLanguageModel = Resolvabl
|
|
|
51
51
|
* from 'ai-retry/experimental/language-model/retryables';
|
|
52
52
|
*/
|
|
53
53
|
declare const error: {
|
|
54
|
-
<MODEL extends
|
|
55
|
-
isRetryable<MODEL extends
|
|
56
|
-
statusCode<MODEL extends
|
|
57
|
-
message<MODEL extends
|
|
58
|
-
}, httpStatus: <MODEL extends
|
|
54
|
+
<MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3, E = unknown>(predicate: (err: E, ctx: RetryContext<MODEL>) => boolean | Promise<boolean>): Condition<MODEL>;
|
|
55
|
+
isRetryable<MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3>(flag?: boolean): Condition<MODEL>;
|
|
56
|
+
statusCode<MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3>(...patterns: Array<number | RegExp>): Condition<MODEL>;
|
|
57
|
+
message<MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3>(...patterns: Array<string | RegExp>): Condition<MODEL>;
|
|
58
|
+
}, httpStatus: <MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3>(...patterns: Array<StatusPattern>) => Condition<MODEL>, timeout: <MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3>() => Condition<MODEL>, aborted: <MODEL extends _ai_sdk_provider13.LanguageModelV3 = _ai_sdk_provider13.LanguageModelV3>() => Condition<MODEL>;
|
|
59
59
|
//#endregion
|
|
60
60
|
export { schemaInvalid as a, timeout as i, error as n, finishReason as o, httpStatus as r, result as s, aborted as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { k as RetryContext, s as ImageModel } from "./types-DYMm5YMu.mjs";
|
|
2
|
+
import { n as Condition, t as StatusPattern } from "./error-CPbAtI-h.mjs";
|
|
3
|
+
import * as _ai_sdk_provider27 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
|
+
* @example
|
|
11
|
+
* noImage().switch({ model: fallback })
|
|
12
|
+
*/
|
|
13
|
+
declare function noImage<MODEL extends ImageModel = ImageModel>(): Condition<MODEL>;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/experimental/image-model/retryables/index.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Experimental composable conditions bound to `ImageModel`. For use with
|
|
18
|
+
* `generateImage`.
|
|
19
|
+
*
|
|
20
|
+
* import { error, noImage, ... }
|
|
21
|
+
* from 'ai-retry/experimental/image-model/retryables';
|
|
22
|
+
*/
|
|
23
|
+
declare const error: {
|
|
24
|
+
<MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3, E = unknown>(predicate: (err: E, ctx: RetryContext<MODEL>) => boolean | Promise<boolean>): Condition<MODEL>;
|
|
25
|
+
isRetryable<MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3>(flag?: boolean): Condition<MODEL>;
|
|
26
|
+
statusCode<MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3>(...patterns: Array<number | RegExp>): Condition<MODEL>;
|
|
27
|
+
message<MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3>(...patterns: Array<string | RegExp>): Condition<MODEL>;
|
|
28
|
+
}, httpStatus: <MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3>(...patterns: Array<StatusPattern>) => Condition<MODEL>, timeout: <MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3>() => Condition<MODEL>, aborted: <MODEL extends _ai_sdk_provider27.ImageModelV3 = _ai_sdk_provider27.ImageModelV3>() => Condition<MODEL>;
|
|
29
|
+
//#endregion
|
|
30
|
+
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-HLobeUXU.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,30 +0,0 @@
|
|
|
1
|
-
import { k as RetryContext, s as ImageModel } from "./types-DYMm5YMu.mjs";
|
|
2
|
-
import { n as Condition, t as StatusPattern } from "./error-CPbAtI-h.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
|
-
* @example
|
|
11
|
-
* noImage().switch({ model: fallback })
|
|
12
|
-
*/
|
|
13
|
-
declare function noImage<MODEL extends ImageModel = ImageModel>(): Condition<MODEL>;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/experimental/image-model/retryables/index.d.ts
|
|
16
|
-
/**
|
|
17
|
-
* Experimental composable conditions bound to `ImageModel`. For use with
|
|
18
|
-
* `generateImage`.
|
|
19
|
-
*
|
|
20
|
-
* import { error, noImage, ... }
|
|
21
|
-
* from 'ai-retry/experimental/image-model/retryables';
|
|
22
|
-
*/
|
|
23
|
-
declare const error: {
|
|
24
|
-
<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3, E = unknown>(predicate: (err: E, ctx: RetryContext<MODEL>) => boolean | Promise<boolean>): Condition<MODEL>;
|
|
25
|
-
isRetryable<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(flag?: boolean): Condition<MODEL>;
|
|
26
|
-
statusCode<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(...patterns: Array<number | RegExp>): Condition<MODEL>;
|
|
27
|
-
message<MODEL extends _ai_sdk_provider0.ImageModelV3 = _ai_sdk_provider0.ImageModelV3>(...patterns: Array<string | RegExp>): Condition<MODEL>;
|
|
28
|
-
}, 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>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { noImage as a, timeout as i, error as n, httpStatus as r, aborted as t };
|