ai 7.0.104 → 7.0.105
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/CHANGELOG.md +9 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-core/32-evaluation.mdx +26 -7
- package/docs/03-ai-sdk-core/45-provider-management.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/14-evaluate.mdx +9 -9
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +3 -2
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +7 -5
- package/package.json +2 -2
- package/src/model/resolve-model.ts +2 -4
|
@@ -11,8 +11,8 @@ is one state, not a batch of unrelated inputs.
|
|
|
11
11
|
|
|
12
12
|
This API and the evaluation model specification are experimental and may change
|
|
13
13
|
in patch releases. Pass an evaluation model instance, resolve a model through a
|
|
14
|
-
provider registry, or use a string ID
|
|
15
|
-
|
|
14
|
+
provider registry, or use a string ID. Strings resolve through Vercel AI Gateway
|
|
15
|
+
unless you configure an evaluation-capable default provider.
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
import { experimental_evaluate, type Experimental_EvaluationModel } from 'ai';
|
|
@@ -125,8 +125,26 @@ evaluation models.
|
|
|
125
125
|
|
|
126
126
|
### Default-provider strings
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
String IDs use Vercel AI Gateway by default. Configure Gateway authentication
|
|
129
|
+
with `AI_GATEWAY_API_KEY` or Vercel OIDC, then pass a Gateway model ID:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { experimental_evaluate } from 'ai';
|
|
133
|
+
|
|
134
|
+
const result = await experimental_evaluate({
|
|
135
|
+
model: 'typesafe-ai/jev-latest',
|
|
136
|
+
state: 'I was charged twice. Please refund the extra charge.',
|
|
137
|
+
questions: {
|
|
138
|
+
refund: {
|
|
139
|
+
type: 'boolean',
|
|
140
|
+
instructions: 'Is the customer asking for a refund?',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
To resolve strings through your own provider or aliases, configure the default
|
|
147
|
+
provider once at application startup:
|
|
130
148
|
|
|
131
149
|
```ts
|
|
132
150
|
// Using the registry above, expose an alias through a custom provider:
|
|
@@ -152,9 +170,10 @@ also resolve through this global default. Prefer model instances in aliases to
|
|
|
152
170
|
avoid resolution cycles. Global configuration affects other AI SDK functions
|
|
153
171
|
too; avoid changing it per request in a shared process.
|
|
154
172
|
|
|
155
|
-
|
|
156
|
-
method
|
|
157
|
-
`NoSuchProviderError`; missing models or evaluation
|
|
173
|
+
An explicitly configured default provider must expose an `evaluationModel`
|
|
174
|
+
method; Gateway is used only when no default provider is configured. Missing
|
|
175
|
+
registry providers throw `NoSuchProviderError`; missing models or evaluation
|
|
176
|
+
capabilities throw
|
|
158
177
|
`NoSuchModelError` with `modelType: 'evaluationModel'`. Unsupported model versions
|
|
159
178
|
throw `UnsupportedModelVersionError`, including models returned by registries.
|
|
160
179
|
The stable `ProviderV4` and `ProviderRegistryProvider` interfaces are unchanged;
|
|
@@ -473,8 +473,8 @@ This simplifies provider usage and makes it easier to switch between providers w
|
|
|
473
473
|
|
|
474
474
|
Custom providers accept `evaluationModels` aliases, and registries expose
|
|
475
475
|
`evaluationModel('provider:model')`. These methods return model instances for
|
|
476
|
-
`experimental_evaluate`.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
476
|
+
`experimental_evaluate`. Direct string IDs use Gateway by default, or an
|
|
477
|
+
explicitly configured default provider with an `evaluationModel` method. Registry
|
|
478
|
+
middleware for language and image models does not apply to evaluation.
|
|
479
|
+
See [Evaluation](/docs/ai-sdk-core/evaluation#model-aliases-and-registries)
|
|
480
480
|
for aliases, default-provider configuration, and capability differences.
|
|
@@ -14,15 +14,15 @@ state. See [Evaluation](/docs/ai-sdk-core/evaluation) for examples and semantics
|
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
16
16
|
|
|
17
|
-
| Parameter | Type | Description
|
|
18
|
-
| ----------------- | ------------------------------------------------- |
|
|
19
|
-
| `model` | `Experimental_EvaluationModel` | Required experimental v4 model instance or a string ID resolved by an explicitly configured evaluation-capable default provider. |
|
|
20
|
-
| `state` | `string \| object \| array` | Required JSON-compatible shared state.
|
|
21
|
-
| `questions` | `Record<string, Experimental_EvaluationQuestion>` | Required nonempty question map.
|
|
22
|
-
| `maxRetries` | `number` | Nonnegative integer; defaults to 2.
|
|
23
|
-
| `abortSignal` | `AbortSignal` | Cancels evaluation.
|
|
24
|
-
| `headers` | `Record<string, string>` | Additional HTTP headers.
|
|
25
|
-
| `providerOptions` | `ProviderOptions` | Provider-specific options.
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| ----------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| `model` | `Experimental_EvaluationModel` | Required experimental v4 model instance or a string ID resolved by Gateway or an explicitly configured evaluation-capable default provider. |
|
|
20
|
+
| `state` | `string \| object \| array` | Required JSON-compatible shared state. |
|
|
21
|
+
| `questions` | `Record<string, Experimental_EvaluationQuestion>` | Required nonempty question map. |
|
|
22
|
+
| `maxRetries` | `number` | Nonnegative integer; defaults to 2. |
|
|
23
|
+
| `abortSignal` | `AbortSignal` | Cancels evaluation. |
|
|
24
|
+
| `headers` | `Record<string, string>` | Additional HTTP headers. |
|
|
25
|
+
| `providerOptions` | `ProviderOptions` | Provider-specific options. |
|
|
26
26
|
|
|
27
27
|
## Result
|
|
28
28
|
|
|
@@ -312,6 +312,7 @@ retain experimental evaluation access.
|
|
|
312
312
|
Unavailable evaluation capabilities or models throw `NoSuchModelError` with
|
|
313
313
|
`modelType: 'evaluationModel'`; unknown registry providers throw
|
|
314
314
|
`NoSuchProviderError`. These capabilities are structural extensions and are not
|
|
315
|
-
added to the stable `ProviderV4` contract.
|
|
316
|
-
|
|
315
|
+
added to the stable `ProviderV4` contract. Direct evaluation string IDs default
|
|
316
|
+
to Gateway when no default provider is configured.
|
|
317
|
+
See [Evaluation](/docs/ai-sdk-core/evaluation#model-aliases-and-registries)
|
|
317
318
|
for runnable usage patterns.
|
|
@@ -207,13 +207,15 @@ The `customProvider` function returns a `Provider` instance. It has the followin
|
|
|
207
207
|
Pass `evaluationModels: Record<string, Experimental_EvaluationModel>` to define
|
|
208
208
|
aliases for evaluation model instances or string IDs. The returned provider adds
|
|
209
209
|
`evaluationModel(alias): Experimental_EvaluationModelV4`. String aliases resolve
|
|
210
|
-
through an explicitly configured default provider with
|
|
211
|
-
method. Unknown aliases use the fallback provider's evaluation
|
|
212
|
-
available; model failures and unsupported questions do not trigger
|
|
210
|
+
through Gateway by default, or an explicitly configured default provider with
|
|
211
|
+
an `evaluationModel` method. Unknown aliases use the fallback provider's evaluation
|
|
212
|
+
factory when available; model failures and unsupported questions do not trigger
|
|
213
|
+
substitution.
|
|
213
214
|
|
|
214
215
|
Unavailable evaluation capabilities or models throw `NoSuchModelError` with
|
|
215
216
|
`modelType: 'evaluationModel'`; unknown registry providers throw
|
|
216
217
|
`NoSuchProviderError`. These capabilities are structural extensions and are not
|
|
217
|
-
added to the stable `ProviderV4` contract.
|
|
218
|
-
|
|
218
|
+
added to the stable `ProviderV4` contract. Direct evaluation string IDs default
|
|
219
|
+
to Gateway when no default provider is configured.
|
|
220
|
+
See [Evaluation](/docs/ai-sdk-core/evaluation#model-aliases-and-registries)
|
|
219
221
|
for runnable usage patterns.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.105",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.85",
|
|
46
46
|
"@ai-sdk/provider": "4.0.17",
|
|
47
47
|
"@ai-sdk/provider-utils": "5.0.43"
|
|
48
48
|
},
|
|
@@ -222,10 +222,8 @@ export function resolveEvaluationModel(
|
|
|
222
222
|
): EvaluationModelV4 {
|
|
223
223
|
if (typeof model === 'string') {
|
|
224
224
|
// Use the original provider so experimental methods and their receiver survive.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
| EvaluationProvider
|
|
228
|
-
| undefined;
|
|
225
|
+
const provider = (globalThis.AI_SDK_DEFAULT_PROVIDER ??
|
|
226
|
+
gateway) as EvaluationProvider;
|
|
229
227
|
|
|
230
228
|
if (typeof provider?.evaluationModel !== 'function') {
|
|
231
229
|
throw new NoSuchModelError({
|