ai-retry 2.0.0-beta.1 → 2.0.0-beta.2
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 +11 -12
- package/dist/{create-retryable-model-CCvLZL7h.mjs → create-retryable-model-AsDcTL4O.mjs} +1 -1
- package/dist/{create-retryable-model-ushVtD_m.mjs → create-retryable-model-Bk2V0Etk.mjs} +1 -1
- package/dist/{create-retryable-model-D4v2D0iX.mjs → create-retryable-model-BmUUjbnL.mjs} +1 -1
- package/dist/embedding-model/conditions/index.d.mts +2 -2
- package/dist/embedding-model/index.d.mts +2 -2
- package/dist/embedding-model/index.mjs +2 -2
- package/dist/image-model/conditions/index.d.mts +3 -3
- package/dist/image-model/index.d.mts +3 -3
- package/dist/image-model/index.mjs +2 -2
- package/dist/{index-5jhZQN3C.d.mts → index-BelYKSAb.d.mts} +2 -2
- package/dist/{index-bEq1CHFY.d.mts → index-DEZS_l48.d.mts} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/language-model/conditions/index.d.mts +3 -3
- package/dist/language-model/index.d.mts +3 -3
- package/dist/language-model/index.mjs +2 -2
- package/dist/{or-CMOEoNU-.d.mts → or-D5SqlYlL.d.mts} +1 -1
- package/dist/retryables/index.d.mts +1 -1
- package/dist/{telemetry-B0Pblnhb.mjs → telemetry-B9VxnSN2.mjs} +0 -1
- package/dist/{types-DzfKbxXv.d.mts → types-CEH_V5nM.d.mts} +0 -4
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -740,7 +740,6 @@ The settings resemble the AI SDK's `telemetry` shape, but stay opt-in and keep a
|
|
|
740
740
|
interface RetryTelemetrySettings {
|
|
741
741
|
isEnabled?: boolean; // off by default while experimental
|
|
742
742
|
tracer?: Tracer; // defaults to trace.getTracer('ai-retry')
|
|
743
|
-
functionId?: string; // groups telemetry by function
|
|
744
743
|
metadata?: Record<string, AttributeValue>;
|
|
745
744
|
}
|
|
746
745
|
```
|
|
@@ -770,7 +769,7 @@ ai_retry.doGenerate outcome=success, attempts=2
|
|
|
770
769
|
| `ai_retry.model.start` | the model the request started with (`provider/modelId`) |
|
|
771
770
|
| `ai_retry.model.final` | the model that produced the final outcome |
|
|
772
771
|
| `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 |
|
|
773
|
-
| `ai_retry.
|
|
772
|
+
| `ai_retry.metadata.*` | from the telemetry settings `metadata` |
|
|
774
773
|
|
|
775
774
|
**Attempt span** (`ai_retry.attempt`) attributes:
|
|
776
775
|
|
|
@@ -815,16 +814,16 @@ The function-style helpers (`contentFilterTriggered`, `requestTimeout`, `request
|
|
|
815
814
|
|
|
816
815
|
Each function-style retryable has a one-line equivalent in the new shape (imports from `ai-retry/language-model` unless noted):
|
|
817
816
|
|
|
818
|
-
| Function-style (deprecated) | Condition API
|
|
819
|
-
| ------------------------------------------- |
|
|
820
|
-
| `contentFilterTriggered(m)` | `finishReason('content-filter').switch({ model: m })`
|
|
821
|
-
| `requestTimeout(m)` | `timeout().switch({ model: m, timeout: 60_000 })`
|
|
822
|
-
| `requestNotRetryable(m)` | `error.isRetryable(false).switch({ model: m })`
|
|
823
|
-
| `schemaMismatch(m)` | `schemaInvalid().switch({ model: m })`
|
|
824
|
-
| `serviceOverloaded(m)` | `httpStatus(529).switch({ model: m })`
|
|
825
|
-
| `serviceUnavailable(m)` | `httpStatus(503).switch({ model: m })`
|
|
826
|
-
| `noImageGenerated(m)` | `noImage().switch({ model: m })` (from `ai-retry/image-model`)
|
|
827
|
-
| `retryAfterDelay({ delay, backoffFactor })` | `error.isRetryable(true).retry({ delay, backoffFactor })`
|
|
817
|
+
| Function-style (deprecated) | Condition API |
|
|
818
|
+
| ------------------------------------------- | -------------------------------------------------------------- |
|
|
819
|
+
| `contentFilterTriggered(m)` | `finishReason('content-filter').switch({ model: m })` |
|
|
820
|
+
| `requestTimeout(m)` | `timeout().switch({ model: m, timeout: 60_000 })` |
|
|
821
|
+
| `requestNotRetryable(m)` | `error.isRetryable(false).switch({ model: m })` |
|
|
822
|
+
| `schemaMismatch(m)` | `schemaInvalid().switch({ model: m })` |
|
|
823
|
+
| `serviceOverloaded(m)` | `httpStatus(529).switch({ model: m })` |
|
|
824
|
+
| `serviceUnavailable(m)` | `httpStatus(503).switch({ model: m })` |
|
|
825
|
+
| `noImageGenerated(m)` | `noImage().switch({ model: m })` (from `ai-retry/image-model`) |
|
|
826
|
+
| `retryAfterDelay({ delay, backoffFactor })` | `error.isRetryable(true).retry({ delay, backoffFactor })` |
|
|
828
827
|
|
|
829
828
|
#### Preamble buffering
|
|
830
829
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as prepareRetryError, c as resolveImageModel, f as calculateExponentialBackoff, o as findRetryModel, p as BaseRetryableModel, r as mergeImageModelCallOptions, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-
|
|
1
|
+
import { a as prepareRetryError, c as resolveImageModel, f as calculateExponentialBackoff, o as findRetryModel, p as BaseRetryableModel, r as mergeImageModelCallOptions, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-B9VxnSN2.mjs";
|
|
2
2
|
import { o as isModel } from "./guards-CKn5dl__.mjs";
|
|
3
3
|
import { delay } from "@ai-sdk/provider-utils";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as prepareRetryError, f as calculateExponentialBackoff, n as mergeEmbeddingModelCallOptions, o as findRetryModel, p as BaseRetryableModel, s as resolveEmbeddingModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-
|
|
1
|
+
import { a as prepareRetryError, f as calculateExponentialBackoff, n as mergeEmbeddingModelCallOptions, o as findRetryModel, p as BaseRetryableModel, s as resolveEmbeddingModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-B9VxnSN2.mjs";
|
|
2
2
|
import { o as isModel } from "./guards-CKn5dl__.mjs";
|
|
3
3
|
import { delay } from "@ai-sdk/provider-utils";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as prepareRetryError, f as calculateExponentialBackoff, i as mergeLanguageModelCallOptions, l as resolveLanguageModel, o as findRetryModel, p as BaseRetryableModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-
|
|
1
|
+
import { a as prepareRetryError, f as calculateExponentialBackoff, i as mergeLanguageModelCallOptions, l as resolveLanguageModel, o as findRetryModel, p as BaseRetryableModel, t as createRetryTelemetry, u as countModelAttempts } from "./telemetry-B9VxnSN2.mjs";
|
|
2
2
|
import { i as isGenerateResult, l as isStreamContentPart, o as isModel, r as isErrorAttempt } from "./guards-CKn5dl__.mjs";
|
|
3
3
|
import { delay } from "@ai-sdk/provider-utils";
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as RetryContext, T as ResolvableEmbeddingModel } from "../../types-
|
|
2
|
-
import { a as Condition, i as StatusPattern, n as not, r as and, t as or } from "../../or-
|
|
1
|
+
import { F as RetryContext, T as ResolvableEmbeddingModel } from "../../types-CEH_V5nM.mjs";
|
|
2
|
+
import { a as Condition, i as StatusPattern, n as not, r as and, t as or } from "../../or-D5SqlYlL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/embedding-model/conditions/index.d.ts
|
|
5
5
|
declare const error: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as RetryableModelOptions, T as ResolvableEmbeddingModel, r as EmbeddingModel } from "../types-
|
|
2
|
-
import { n as not, r as and, t as or } from "../or-
|
|
1
|
+
import { B as RetryableModelOptions, T as ResolvableEmbeddingModel, r as EmbeddingModel } from "../types-CEH_V5nM.mjs";
|
|
2
|
+
import { n as not, r as and, t as or } from "../or-D5SqlYlL.mjs";
|
|
3
3
|
import { aborted, error, httpStatus, timeout } from "./conditions/index.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/embedding-model/create-retryable-model.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../telemetry-
|
|
2
|
-
import { t as createRetryableModel } from "../create-retryable-model-
|
|
1
|
+
import "../telemetry-B9VxnSN2.mjs";
|
|
2
|
+
import { t as createRetryableModel } from "../create-retryable-model-Bk2V0Etk.mjs";
|
|
3
3
|
import { i as or, n as and, t as not } from "../not-6hBRaJRl.mjs";
|
|
4
4
|
import { aborted, error, httpStatus, timeout } from "./conditions/index.mjs";
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../types-
|
|
2
|
-
import { n as not, r as and, t as or } from "../../or-
|
|
3
|
-
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../index-
|
|
1
|
+
import "../../types-CEH_V5nM.mjs";
|
|
2
|
+
import { n as not, r as and, t as or } from "../../or-D5SqlYlL.mjs";
|
|
3
|
+
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../../index-DEZS_l48.mjs";
|
|
4
4
|
export { aborted, and, error, httpStatus, noImage, not, or, timeout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as RetryableModelOptions, E as ResolvableImageModel, d as ImageModel } from "../types-
|
|
2
|
-
import { n as not, r as and, t as or } from "../or-
|
|
3
|
-
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../index-
|
|
1
|
+
import { B as RetryableModelOptions, E as ResolvableImageModel, d as ImageModel } from "../types-CEH_V5nM.mjs";
|
|
2
|
+
import { n as not, r as and, t as or } from "../or-D5SqlYlL.mjs";
|
|
3
|
+
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../index-DEZS_l48.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/image-model/create-retryable-model.d.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../telemetry-
|
|
2
|
-
import { t as createRetryableModel } from "../create-retryable-model-
|
|
1
|
+
import "../telemetry-B9VxnSN2.mjs";
|
|
2
|
+
import { t as createRetryableModel } from "../create-retryable-model-AsDcTL4O.mjs";
|
|
3
3
|
import { i as or, n as and, t as not } from "../not-6hBRaJRl.mjs";
|
|
4
4
|
import { a as noImage, i as timeout, n as error, r as httpStatus, t as aborted } from "../conditions-CfeJD4K4.mjs";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as ResolvableLanguageModel, F as RetryContext, v as LanguageModelResult } from "./types-
|
|
2
|
-
import { a as Condition, i as StatusPattern } from "./or-
|
|
1
|
+
import { D as ResolvableLanguageModel, F as RetryContext, v as LanguageModelResult } from "./types-CEH_V5nM.mjs";
|
|
2
|
+
import { a as Condition, i as StatusPattern } from "./or-D5SqlYlL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/internal/conditions/result.d.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ResolvableImageModel, F as RetryContext } from "./types-
|
|
2
|
-
import { a as Condition, i as StatusPattern } from "./or-
|
|
1
|
+
import { E as ResolvableImageModel, F as RetryContext } from "./types-CEH_V5nM.mjs";
|
|
2
|
+
import { a as Condition, i as StatusPattern } from "./or-D5SqlYlL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/internal/conditions/no-image.d.ts
|
|
5
5
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Result, B as RetryableModelOptions, C as ProviderOptions, D as ResolvableLanguageModel, E as ResolvableImageModel, F as RetryContext, H as SuccessAttempt, I as RetryErrorAttempt, L as RetryResultAttempt, M as Retry, N as RetryAttempt, O as ResolvableModel, P as RetryCallOptions, R as RetryTelemetrySettings, S as OnRetryOverrides, T as ResolvableEmbeddingModel, U as SuccessContext, V as RetryableOptions, _ as LanguageModelGenerate, a as EmbeddingModelEmbed, b as LanguageModelStream, c as GatewayEmbeddingModelId, d as ImageModel, f as ImageModelCallOptions, g as LanguageModelCallOptions, h as LanguageModel, i as EmbeddingModelCallOptions, j as Retries, k as ResolvedModel, l as GatewayImageModelId, m as ImageModelRetryCallOptions, n as CallOptions, o as EmbeddingModelRetryCallOptions, p as ImageModelGenerate, r as EmbeddingModel, s as FailureContext, t as AnyResolvableModel, u as GatewayLanguageModelId, v as LanguageModelResult, w as Reset, x as LanguageModelStreamPart, y as LanguageModelRetryCallOptions, z as Retryable } from "./types-
|
|
1
|
+
import { A as Result, B as RetryableModelOptions, C as ProviderOptions, D as ResolvableLanguageModel, E as ResolvableImageModel, F as RetryContext, H as SuccessAttempt, I as RetryErrorAttempt, L as RetryResultAttempt, M as Retry, N as RetryAttempt, O as ResolvableModel, P as RetryCallOptions, R as RetryTelemetrySettings, S as OnRetryOverrides, T as ResolvableEmbeddingModel, U as SuccessContext, V as RetryableOptions, _ as LanguageModelGenerate, a as EmbeddingModelEmbed, b as LanguageModelStream, c as GatewayEmbeddingModelId, d as ImageModel, f as ImageModelCallOptions, g as LanguageModelCallOptions, h as LanguageModel, i as EmbeddingModelCallOptions, j as Retries, k as ResolvedModel, l as GatewayImageModelId, m as ImageModelRetryCallOptions, n as CallOptions, o as EmbeddingModelRetryCallOptions, p as ImageModelGenerate, r as EmbeddingModel, s as FailureContext, t as AnyResolvableModel, u as GatewayLanguageModelId, v as LanguageModelResult, w as Reset, x as LanguageModelStreamPart, y as LanguageModelRetryCallOptions, z as Retryable } from "./types-CEH_V5nM.mjs";
|
|
2
2
|
import "@ai-sdk/provider";
|
|
3
3
|
|
|
4
4
|
//#region src/internal/create-retryable-model.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as getModelKey, l as resolveLanguageModel } from "./telemetry-
|
|
1
|
+
import { d as getModelKey, l as resolveLanguageModel } from "./telemetry-B9VxnSN2.mjs";
|
|
2
2
|
import { a as isImageModel, c as isResultAttempt, n as isEmbeddingModel, o as isModel, r as isErrorAttempt } from "./guards-CKn5dl__.mjs";
|
|
3
|
-
import { t as createRetryableModel$1 } from "./create-retryable-model-
|
|
4
|
-
import { t as createRetryableModel$2 } from "./create-retryable-model-
|
|
5
|
-
import { t as createRetryableModel$3 } from "./create-retryable-model-
|
|
3
|
+
import { t as createRetryableModel$1 } from "./create-retryable-model-Bk2V0Etk.mjs";
|
|
4
|
+
import { t as createRetryableModel$2 } from "./create-retryable-model-AsDcTL4O.mjs";
|
|
5
|
+
import { t as createRetryableModel$3 } from "./create-retryable-model-BmUUjbnL.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/internal/create-retryable-model.ts
|
|
8
8
|
function createRetryableModel(options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../types-
|
|
2
|
-
import { n as not, r as and, t as or } from "../../or-
|
|
3
|
-
import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../index-
|
|
1
|
+
import "../../types-CEH_V5nM.mjs";
|
|
2
|
+
import { n as not, r as and, t as or } from "../../or-D5SqlYlL.mjs";
|
|
3
|
+
import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../../index-BelYKSAb.mjs";
|
|
4
4
|
export { aborted, and, error, finishReason, httpStatus, not, or, result, schemaInvalid, timeout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as RetryableModelOptions, D as ResolvableLanguageModel, h as LanguageModel } from "../types-
|
|
2
|
-
import { n as not, r as and, t as or } from "../or-
|
|
3
|
-
import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../index-
|
|
1
|
+
import { B as RetryableModelOptions, D as ResolvableLanguageModel, h as LanguageModel } from "../types-CEH_V5nM.mjs";
|
|
2
|
+
import { n as not, r as and, t as or } from "../or-D5SqlYlL.mjs";
|
|
3
|
+
import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../index-BelYKSAb.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/language-model/create-retryable-model.d.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../telemetry-
|
|
2
|
-
import { t as createRetryableModel } from "../create-retryable-model-
|
|
1
|
+
import "../telemetry-B9VxnSN2.mjs";
|
|
2
|
+
import { t as createRetryableModel } from "../create-retryable-model-BmUUjbnL.mjs";
|
|
3
3
|
import { i as or, n as and, t as not } from "../not-6hBRaJRl.mjs";
|
|
4
4
|
import { a as result, i as httpStatus, n as error, o as schemaInvalid, r as finishReason, s as timeout, t as aborted } from "../conditions-DAetW5_1.mjs";
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as RetryContext, M as Retry, t as AnyResolvableModel, z as Retryable } from "./types-
|
|
1
|
+
import { F as RetryContext, M as Retry, t as AnyResolvableModel, z as Retryable } from "./types-CEH_V5nM.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/internal/conditions/condition.d.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as ResolvableLanguageModel, E as ResolvableImageModel, V as RetryableOptions, t as AnyResolvableModel, z as Retryable } from "../types-
|
|
1
|
+
import { D as ResolvableLanguageModel, E as ResolvableImageModel, V as RetryableOptions, t as AnyResolvableModel, z as Retryable } from "../types-CEH_V5nM.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/retryables/content-filter-triggered.d.ts
|
|
4
4
|
/**
|
|
@@ -365,7 +365,6 @@ var OpenTelemetrySink = class {
|
|
|
365
365
|
"ai_retry.model.start": `${info.provider}/${info.modelId}`,
|
|
366
366
|
"gen_ai.operation.name": info.genAiOperation
|
|
367
367
|
};
|
|
368
|
-
if (this.#settings.functionId !== void 0) attributes["ai_retry.function.id"] = this.#settings.functionId;
|
|
369
368
|
if (this.#settings.metadata) for (const [key, value] of Object.entries(this.#settings.metadata)) attributes[`ai_retry.metadata.${key}`] = value;
|
|
370
369
|
this.#operationSpan = this.#tracer.startSpan(`ai_retry.${info.operation}`, { attributes }, context.active());
|
|
371
370
|
this.#operationContext = trace.setSpan(context.active(), this.#operationSpan);
|
|
@@ -175,10 +175,6 @@ interface RetryTelemetrySettings {
|
|
|
175
175
|
* OpenTelemetry SDK is registered.
|
|
176
176
|
*/
|
|
177
177
|
tracer?: Tracer;
|
|
178
|
-
/**
|
|
179
|
-
* Identifier for this function. Used to group telemetry data by function.
|
|
180
|
-
*/
|
|
181
|
-
functionId?: string;
|
|
182
178
|
/**
|
|
183
179
|
* Additional information to include in the telemetry data. Recorded on the
|
|
184
180
|
* operation span as `ai_retry.metadata.<key>` attributes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-retry",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "Retry and fallback mechanisms for AI SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
"@ai-sdk/google": "4.0.0-beta.82",
|
|
41
41
|
"@ai-sdk/groq": "4.0.0-beta.54",
|
|
42
42
|
"@ai-sdk/openai": "4.0.0-beta.74",
|
|
43
|
+
"@ai-sdk/otel": "1.0.0-beta.128",
|
|
43
44
|
"@ai-sdk/provider": "4.0.0-beta.19",
|
|
44
45
|
"@ai-sdk/provider-utils": "5.0.0-beta.49",
|
|
45
46
|
"@ai-sdk/test-server": "2.0.0-beta.7",
|
|
46
47
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
47
|
-
"@langfuse/otel": "^5.3
|
|
48
|
-
"@langfuse/tracing": "^5.3
|
|
48
|
+
"@langfuse/otel": "^5.5.3",
|
|
49
|
+
"@langfuse/tracing": "^5.5.3",
|
|
50
|
+
"@langfuse/vercel-ai-sdk": "5.5.0-beta.3",
|
|
49
51
|
"@opentelemetry/api": "1.9.0",
|
|
50
52
|
"@opentelemetry/context-async-hooks": "^2.7.1",
|
|
51
53
|
"@opentelemetry/sdk-node": "^0.218.0",
|