ai 7.0.146 → 7.0.148

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/index.js +1 -1
  6. package/docs/02-foundations/01-overview.mdx +1 -1
  7. package/docs/02-foundations/02-providers-and-models.mdx +2 -2
  8. package/docs/02-foundations/03-prompts.mdx +3 -3
  9. package/docs/02-foundations/04-tools.mdx +2 -2
  10. package/docs/02-getting-started/00-choosing-a-provider.mdx +1 -1
  11. package/docs/02-getting-started/02-nextjs-app-router.mdx +4 -4
  12. package/docs/02-getting-started/03-nextjs-pages-router.mdx +4 -4
  13. package/docs/02-getting-started/04-svelte.mdx +3 -3
  14. package/docs/02-getting-started/05-nuxt.mdx +3 -3
  15. package/docs/02-getting-started/06-nodejs.mdx +2 -2
  16. package/docs/02-getting-started/07-expo.mdx +4 -4
  17. package/docs/02-getting-started/08-tanstack-start.mdx +4 -4
  18. package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +1 -1
  19. package/docs/03-ai-sdk-core/18-tools.mdx +24 -5
  20. package/docs/03-ai-sdk-core/37-speech.mdx +1 -1
  21. package/docs/03-ai-sdk-core/41-skill-uploads.mdx +24 -10
  22. package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +33 -1
  23. package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +5 -5
  24. package/docs/03-ai-sdk-harnesses/06-workflow-utilities.mdx +12 -0
  25. package/docs/03-ai-sdk-harnesses/07-ui.mdx +2 -2
  26. package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +2 -2
  27. package/docs/05-ai-sdk-rsc/01-overview.mdx +1 -1
  28. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +1 -1
  29. package/docs/06-advanced/01-prompt-engineering.mdx +1 -1
  30. package/docs/06-advanced/03-backpressure.mdx +1 -1
  31. package/docs/06-advanced/10-vercel-deployment-guide.mdx +1 -1
  32. package/docs/06-advanced/11-secure-url-fetching.mdx +2 -2
  33. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +1 -1
  34. package/docs/07-reference/01-ai-sdk-core/14-upload-skill.mdx +3 -3
  35. package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +1 -1
  36. package/docs/08-migration-guides/index.mdx +12 -12
  37. package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +1 -1
  38. package/package.json +11 -11
  39. package/src/generate-text/output.ts +1 -1
  40. package/src/ui/process-ui-message-stream.ts +1 -0
@@ -16,7 +16,7 @@ description: An overview of AI SDK RSC.
16
16
  Server Components.
17
17
  </Note>
18
18
 
19
- [React Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components) (RSC) allow you to write UI that can be rendered on the server and streamed to the client. RSCs enable [ Server Actions ](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#with-client-components), a new way to call server-side code directly from the client just like any other function with end-to-end type-safety. This combination opens the door to a new way of building AI applications, allowing the large language model (LLM) to generate and stream UI directly from the server to the client.
19
+ [React Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components) (RSC) allow you to write UI that can be rendered on the server and streamed to the client. RSCs enable [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#with-client-components), a new way to call server-side code directly from the client just like any other function with end-to-end type-safety. This combination opens the door to a new way of building AI applications, allowing the large language model (LLM) to generate and stream UI directly from the server to the client.
20
20
 
21
21
  ## AI SDK RSC Functions
22
22
 
@@ -166,7 +166,7 @@ export default function Page() {
166
166
 
167
167
  In AI SDK RSC, `streamUI` does not support parallel tool calls. You will have to use a combination of `streamText`, `createStreamableUI` and `createStreamableValue`.
168
168
 
169
- With AI SDK UI, `useChat` comes with built-in support for parallel tool calls. You can define multiple tools in the `streamText` and have them called them in parallel. The `useChat` hook will then handle the parallel tool calls for you automatically.
169
+ With AI SDK UI, `useChat` comes with built-in support for parallel tool calls. You can define multiple tools in the `streamText` and have them called in parallel. The `useChat` hook will then handle the parallel tool calls for you automatically.
170
170
 
171
171
  ### Multi-Step Tool Calls
172
172
 
@@ -17,7 +17,7 @@ Prompts are the starting points for LLMs. They are the inputs that trigger the m
17
17
 
18
18
  ## Why is prompt engineering needed?
19
19
 
20
- Prompt engineering currently plays a pivotal role in shaping the responses of LLMs. It allows us to tweak the model to respond more effectively to a broader range of queries. This includes the use of techniques like semantic search, command grammars, and the ReActive model architecture. The performance, context window, and cost of LLMs varies between models and model providers which adds further constraints to the mix. For example, the GPT-4 model is more expensive than GPT-3.5-turbo and significantly slower, but it can also be more effective at certain tasks. And so, like many things in software engineering, there is a trade-offs between cost and performance.
20
+ Prompt engineering currently plays a pivotal role in shaping the responses of LLMs. It allows us to tweak the model to respond more effectively to a broader range of queries. This includes the use of techniques like semantic search, command grammars, and the ReActive model architecture. The performance, context window, and cost of LLMs varies between models and model providers which adds further constraints to the mix. For example, the GPT-4 model is more expensive than GPT-3.5-turbo and significantly slower, but it can also be more effective at certain tasks. And so, like many things in software engineering, there is a trade-off between cost and performance.
21
21
 
22
22
  To assist with comparing and tweaking LLMs, we've built an AI playground that allows you to compare the performance of different models side-by-side online. When you're ready, you can even generate code with the AI SDK to quickly use your prompt and your selected model into your own applications.
23
23
 
@@ -120,7 +120,7 @@ function createStream(iterator) {
120
120
  }
121
121
  // Collect data from stream
122
122
  async function run() {
123
- // Set up a stream that of integers
123
+ // Set up a stream of integers
124
124
  const stream = createStream(integers());
125
125
 
126
126
  // Read values from our stream
@@ -16,7 +16,7 @@ Vercel allows for automatic deployments on every branch push and merges onto the
16
16
  To follow along with this guide, you will need:
17
17
 
18
18
  - a Vercel account
19
- - an account with a Git provider (this tutorial will use [Github](https://github.com))
19
+ - an account with a Git provider (this tutorial will use [GitHub](https://github.com))
20
20
  - an OpenAI API key
21
21
 
22
22
  This guide will teach you how to deploy the application you built in the Next.js (App Router) quickstart tutorial to Vercel. If you haven’t completed the quickstart guide, you can start with [this repo](https://github.com/vercel-labs/ai-sdk-deployment-guide).
@@ -28,8 +28,8 @@ When the SDK fetches a URL taken from a provider response, it:
28
28
 
29
29
  - **Rejects private, loopback, and link-local targets** — IPv4 (`10/8`,
30
30
  `172.16/12`, `192.168/16`, `127/8`, `169.254/16`, CGNAT, multicast, …) and the
31
- equivalent IPv6 ranges, plus `localhost` and `.local`. Non-`http(s)` schemes
32
- are rejected too.
31
+ equivalent IPv6 ranges, plus `localhost`, `.local`, `.localhost`, and
32
+ `.internal` hostnames. Non-`http(s)` schemes are rejected too.
33
33
  - **Re-validates every redirect hop** — a URL that passes but then redirects to
34
34
  an internal address is blocked; the redirect is never followed blindly.
35
35
  - **Validates DNS at connection time on Node.js** — every resolved address is
@@ -7,7 +7,7 @@ description: API Reference for generateText.
7
7
 
8
8
  Generates text and calls tools for a given prompt using a language model.
9
9
 
10
- It is ideal for non-interactive use cases such as automation tasks where you need to write text (e.g. drafting email or summarizing web pages) and for agents that use tools.
10
+ It is ideal for non-interactive use cases such as automation tasks where you need to write text (e.g. drafting emails or summarizing web pages) and for agents that use tools.
11
11
 
12
12
  ```ts
13
13
  import { generateText } from 'ai';
@@ -17,7 +17,7 @@ const { providerReference } = await uploadSkill({
17
17
  files: [
18
18
  {
19
19
  path: 'my-skill/SKILL.md',
20
- content: readFileSync('./SKILL.md'),
20
+ data: readFileSync('./SKILL.md'),
21
21
  },
22
22
  ],
23
23
  displayTitle: 'My Skill',
@@ -42,9 +42,9 @@ const { providerReference } = await uploadSkill({
42
42
  },
43
43
  {
44
44
  name: 'files',
45
- type: 'SkillsV4File[]',
45
+ type: 'UploadSkillFile[]',
46
46
  description:
47
- 'The files that make up the skill. Each file has a relative `path` and `content` (either a `Uint8Array` or a base64-encoded string).',
47
+ "The files that make up the skill. Each file must have a relative `path` and `data`. The `data` can be a string, a `Uint8Array`, or an object with `type: 'text'` and a string `text` value, or `type: 'data'` and a string `data` value.",
48
48
  },
49
49
  {
50
50
  name: 'displayTitle',
@@ -224,7 +224,7 @@ When used with useChat (`UIMessage` format), dynamic tools appear as `dynamic-to
224
224
  switch (part.type) {
225
225
  case 'dynamic-tool':
226
226
  return (
227
- <div>
227
+ <div key={part.toolCallId}>
228
228
  <h4>Tool: {part.toolName}</h4>
229
229
  <pre>{JSON.stringify(part.input, null, 2)}</pre>
230
230
  </div>
@@ -6,18 +6,18 @@ collapsed: true
6
6
 
7
7
  # Migration Guides
8
8
 
9
- - [ Migrate AI SDK 6.x to 7.0 ](/docs/migration-guides/migration-guide-7-0)
10
- - [ Migrate AI SDK 5.x to 6.0 ](/docs/migration-guides/migration-guide-6-0)
11
- - [ Migrate AI SDK 4.x to 5.0 ](/docs/migration-guides/migration-guide-5-0)
12
- - [ Migrate your data to AI SDK 5.0 ](/docs/migration-guides/migration-guide-5-0-data)
13
- - [ Migrate AI SDK 4.1 to 4.2 ](/docs/migration-guides/migration-guide-4-2)
14
- - [ Migrate AI SDK 4.0 to 4.1 ](/docs/migration-guides/migration-guide-4-1)
15
- - [ Migrate AI SDK 3.4 to 4.0 ](/docs/migration-guides/migration-guide-4-0)
16
- - [ Migrate AI SDK 3.3 to 3.4 ](/docs/migration-guides/migration-guide-3-4)
17
- - [ Migrate AI SDK 3.2 to 3.3 ](/docs/migration-guides/migration-guide-3-3)
18
- - [ Migrate AI SDK 3.1 to 3.2 ](/docs/migration-guides/migration-guide-3-2)
19
- - [ Migrate AI SDK 3.0 to 3.1 ](/docs/migration-guides/migration-guide-3-1)
9
+ - [Migrate AI SDK 6.x to 7.0](/docs/migration-guides/migration-guide-7-0)
10
+ - [Migrate AI SDK 5.x to 6.0](/docs/migration-guides/migration-guide-6-0)
11
+ - [Migrate AI SDK 4.x to 5.0](/docs/migration-guides/migration-guide-5-0)
12
+ - [Migrate your data to AI SDK 5.0](/docs/migration-guides/migration-guide-5-0-data)
13
+ - [Migrate AI SDK 4.1 to 4.2](/docs/migration-guides/migration-guide-4-2)
14
+ - [Migrate AI SDK 4.0 to 4.1](/docs/migration-guides/migration-guide-4-1)
15
+ - [Migrate AI SDK 3.4 to 4.0](/docs/migration-guides/migration-guide-4-0)
16
+ - [Migrate AI SDK 3.3 to 3.4](/docs/migration-guides/migration-guide-3-4)
17
+ - [Migrate AI SDK 3.2 to 3.3](/docs/migration-guides/migration-guide-3-3)
18
+ - [Migrate AI SDK 3.1 to 3.2](/docs/migration-guides/migration-guide-3-2)
19
+ - [Migrate AI SDK 3.0 to 3.1](/docs/migration-guides/migration-guide-3-1)
20
20
 
21
21
  ## Versioning
22
22
 
23
- - [ Versioning ](/docs/migration-guides/versioning)
23
+ - [Versioning](/docs/migration-guides/versioning)
@@ -38,7 +38,7 @@ const tools = {
38
38
  };
39
39
  ```
40
40
 
41
- 2. Client-side execution with `useChat` (omitting the `execute` function), you must provide results using `addToolOutput`:
41
+ 2. For client-side execution with `useChat` (omitting the `execute` function), you must provide results using `addToolOutput`:
42
42
 
43
43
  ```tsx
44
44
  import { useChat } from '@ai-sdk/react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.146",
3
+ "version": "7.0.148",
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,20 +42,20 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/gateway": "4.0.119",
45
+ "@ai-sdk/gateway": "4.0.121",
46
46
  "@ai-sdk/provider": "4.0.31",
47
- "@ai-sdk/provider-utils": "5.0.64"
47
+ "@ai-sdk/provider-utils": "5.0.65"
48
48
  },
49
49
  "devDependencies": {
50
- "@ai-sdk/amazon-bedrock": "5.0.120",
51
- "@ai-sdk/deepseek": "3.0.69",
52
- "@ai-sdk/google": "4.0.101",
53
- "@ai-sdk/groq": "4.0.66",
54
- "@ai-sdk/huggingface": "2.0.74",
55
- "@ai-sdk/moonshotai": "3.0.73",
56
- "@ai-sdk/openai": "4.0.98",
50
+ "@ai-sdk/amazon-bedrock": "5.0.121",
51
+ "@ai-sdk/deepseek": "3.0.70",
52
+ "@ai-sdk/google": "4.0.102",
53
+ "@ai-sdk/groq": "4.0.67",
54
+ "@ai-sdk/huggingface": "2.0.75",
55
+ "@ai-sdk/moonshotai": "3.0.74",
56
+ "@ai-sdk/openai": "4.0.99",
57
57
  "@ai-sdk/test-server": "2.0.4",
58
- "@ai-sdk/xai": "5.0.26",
58
+ "@ai-sdk/xai": "5.0.27",
59
59
  "@edge-runtime/vm": "^5.0.0",
60
60
  "@smithy/eventstream-codec": "^4.3.3",
61
61
  "@smithy/util-utf8": "^4.3.3",
@@ -491,7 +491,7 @@ function getArrayLengthValidationError({
491
491
 
492
492
  /**
493
493
  * Output specification for choice generation.
494
- * When the model generates a text response, it will return a one of the choice options.
494
+ * When the model generates a text response, it will return one of the choice options.
495
495
  *
496
496
  * @param options - The available choices.
497
497
  * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
@@ -271,6 +271,7 @@ export function processUIMessageStream<UI_MESSAGE extends UIMessage>({
271
271
 
272
272
  if (part != null) {
273
273
  part.state = options.state;
274
+ anyPart.type = `tool-${options.toolName}`;
274
275
  anyPart.input = anyOptions.input;
275
276
  anyPart.output = anyOptions.output;
276
277
  anyPart.errorText = anyOptions.errorText;