ai 6.0.282 → 6.0.283

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.283
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [dc9fa12]
8
+ - @ai-sdk/gateway@3.0.194
9
+
3
10
  ## 6.0.282
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1334,7 +1334,7 @@ function detectMediaType({
1334
1334
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1335
1335
 
1336
1336
  // src/version.ts
1337
- var VERSION = true ? "6.0.282" : "0.0.0-test";
1337
+ var VERSION = true ? "6.0.283" : "0.0.0-test";
1338
1338
 
1339
1339
  // src/util/download/download.ts
1340
1340
  var download = async ({
package/dist/index.mjs CHANGED
@@ -1224,7 +1224,7 @@ import {
1224
1224
  } from "@ai-sdk/provider-utils";
1225
1225
 
1226
1226
  // src/version.ts
1227
- var VERSION = true ? "6.0.282" : "0.0.0-test";
1227
+ var VERSION = true ? "6.0.283" : "0.0.0-test";
1228
1228
 
1229
1229
  // src/util/download/download.ts
1230
1230
  var download = async ({
@@ -164,7 +164,7 @@ function detectMediaType({
164
164
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
165
165
 
166
166
  // src/version.ts
167
- var VERSION = true ? "6.0.282" : "0.0.0-test";
167
+ var VERSION = true ? "6.0.283" : "0.0.0-test";
168
168
 
169
169
  // src/util/download/download.ts
170
170
  var download = async ({
@@ -144,7 +144,7 @@ import {
144
144
  } from "@ai-sdk/provider-utils";
145
145
 
146
146
  // src/version.ts
147
- var VERSION = true ? "6.0.282" : "0.0.0-test";
147
+ var VERSION = true ? "6.0.283" : "0.0.0-test";
148
148
 
149
149
  // src/util/download/download.ts
150
150
  var download = async ({
@@ -111,6 +111,13 @@ Let's take a look at what is happening in this code:
111
111
 
112
112
  This API route creates a POST request endpoint at `/api/chat`.
113
113
 
114
+ <Note>
115
+ If a deployed Expo API Route buffers the response despite the streaming
116
+ headers above, test the same handler without the deployment adapter to isolate
117
+ the cause. As a workaround, host the chat endpoint in a separate Vercel
118
+ Function and set `EXPO_PUBLIC_API_BASE_URL` to that function's base URL.
119
+ </Note>
120
+
114
121
  ## Choosing a Provider
115
122
 
116
123
  The AI SDK supports dozens of model providers through [first-party](/providers/ai-sdk-providers), [OpenAI-compatible](/providers/openai-compatible-providers), and [ community ](/providers/community-providers) packages.
@@ -179,6 +179,83 @@ const result = streamText({
179
179
  });
180
180
  ```
181
181
 
182
+ ### ToolLoopAgent
183
+
184
+ You can provide a sequence of mock responses to test an agent that calls a tool
185
+ and continues to a final response:
186
+
187
+ ```ts
188
+ import { ToolLoopAgent, tool } from 'ai';
189
+ import { MockLanguageModelV3 } from 'ai/test';
190
+ import { expect, it } from 'vitest';
191
+ import { z } from 'zod';
192
+
193
+ it('executes a tool and continues the loop', async () => {
194
+ const weatherRequests: string[] = [];
195
+ const usage = {
196
+ inputTokens: {
197
+ total: 10,
198
+ noCache: 10,
199
+ cacheRead: undefined,
200
+ cacheWrite: undefined,
201
+ },
202
+ outputTokens: {
203
+ total: 5,
204
+ text: 5,
205
+ reasoning: undefined,
206
+ },
207
+ };
208
+
209
+ const model = new MockLanguageModelV3({
210
+ doGenerate: [
211
+ {
212
+ content: [
213
+ {
214
+ type: 'tool-call',
215
+ toolCallId: 'call-1',
216
+ toolName: 'weather',
217
+ input: '{"city":"San Francisco"}',
218
+ },
219
+ ],
220
+ finishReason: { unified: 'tool-calls', raw: undefined },
221
+ usage,
222
+ warnings: [],
223
+ },
224
+ {
225
+ content: [
226
+ { type: 'text', text: 'It is 72°F in San Francisco.' },
227
+ ],
228
+ finishReason: { unified: 'stop', raw: undefined },
229
+ usage,
230
+ warnings: [],
231
+ },
232
+ ],
233
+ });
234
+
235
+ const agent = new ToolLoopAgent({
236
+ model,
237
+ tools: {
238
+ weather: tool({
239
+ description: 'Get the weather for a city.',
240
+ inputSchema: z.object({ city: z.string() }),
241
+ execute: async ({ city }) => {
242
+ weatherRequests.push(city);
243
+ return { temperature: 72 };
244
+ },
245
+ }),
246
+ },
247
+ });
248
+
249
+ const result = await agent.generate({
250
+ prompt: 'What is the weather in San Francisco?',
251
+ });
252
+
253
+ expect(weatherRequests).toEqual(['San Francisco']);
254
+ expect(result.text).toBe('It is 72°F in San Francisco.');
255
+ expect(model.doGenerateCalls).toHaveLength(2);
256
+ });
257
+ ```
258
+
182
259
  ### Simulate UI Message Stream Responses
183
260
 
184
261
  You can also simulate [UI Message Stream](/docs/ai-sdk-ui/stream-protocol#ui-message-stream) responses for testing,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.282",
3
+ "version": "6.0.283",
4
4
  "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.",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@opentelemetry/api": "^1.9.0",
48
- "@ai-sdk/gateway": "3.0.193",
48
+ "@ai-sdk/gateway": "3.0.194",
49
49
  "@ai-sdk/provider": "3.0.16",
50
50
  "@ai-sdk/provider-utils": "4.0.51"
51
51
  },