ai 5.1.0-beta.17 → 5.1.0-beta.19
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 +20 -0
- package/README.md +110 -45
- package/dist/index.d.mts +42 -42
- package/dist/index.d.ts +42 -42
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.1.0-beta.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- aa0515c: feat(ai): move Agent to stable
|
|
8
|
+
- e7d9b00: feat(agent): add optional name property to agent
|
|
9
|
+
- b1aeea7: feat(ai): set default stopWhen on Agent to stepCountIs(20)
|
|
10
|
+
|
|
11
|
+
## 5.1.0-beta.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 0adc679: feat(provider): shared spec v3
|
|
16
|
+
- 9b8d17e: fix(agent): move provider options to main agent config
|
|
17
|
+
- Updated dependencies [0adc679]
|
|
18
|
+
- Updated dependencies [2b0caef]
|
|
19
|
+
- @ai-sdk/provider-utils@3.1.0-beta.6
|
|
20
|
+
- @ai-sdk/provider@2.1.0-beta.4
|
|
21
|
+
- @ai-sdk/gateway@1.1.0-beta.13
|
|
22
|
+
|
|
3
23
|
## 5.1.0-beta.17
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# AI SDK
|
|
4
4
|
|
|
5
|
-
The [AI SDK](https://ai-sdk.dev/docs) is a TypeScript toolkit designed to help you build AI-powered applications using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
|
|
5
|
+
The [AI SDK](https://ai-sdk.dev/docs) is a TypeScript toolkit designed to help you build AI-powered applications and agents using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
|
|
6
6
|
|
|
7
7
|
To learn more about how to use the AI SDK, check out our [API Reference](https://ai-sdk.dev/docs/reference) and [Documentation](https://ai-sdk.dev/docs).
|
|
8
8
|
|
|
@@ -11,56 +11,141 @@ To learn more about how to use the AI SDK, check out our [API Reference](https:/
|
|
|
11
11
|
You will need Node.js 18+ and pnpm installed on your local development machine.
|
|
12
12
|
|
|
13
13
|
```shell
|
|
14
|
-
npm
|
|
14
|
+
npm i ai
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
### AI SDK Core
|
|
17
|
+
## Unified Provider Architecture
|
|
20
18
|
|
|
21
|
-
The
|
|
22
|
-
|
|
23
|
-
You will then install the model provider of your choice.
|
|
19
|
+
The AI SDK provides a [unified API](https://ai-sdk.dev/docs/foundations/providers-and-models) to interact with model providers like [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai), [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic), [Google](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai), and [more](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
24
20
|
|
|
25
21
|
```shell
|
|
26
|
-
npm
|
|
22
|
+
npm i @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
|
|
27
23
|
```
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
Alternatively you can use the [Vercel AI Gateway](https://vercel.com/docs/ai-gateway).
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Generating Text
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { generateText } from 'ai';
|
|
33
|
+
|
|
34
|
+
const { text } = await generateText({
|
|
35
|
+
model: 'openai/gpt-5', // use Vercel AI Gateway
|
|
36
|
+
prompt: 'What is an agent?',
|
|
37
|
+
});
|
|
38
|
+
```
|
|
30
39
|
|
|
31
40
|
```ts
|
|
32
41
|
import { generateText } from 'ai';
|
|
33
|
-
import { openai } from '@ai-sdk/openai';
|
|
42
|
+
import { openai } from '@ai-sdk/openai';
|
|
34
43
|
|
|
35
44
|
const { text } = await generateText({
|
|
36
|
-
model: openai('gpt-
|
|
37
|
-
|
|
38
|
-
prompt: 'Why is the sky blue?',
|
|
45
|
+
model: openai('gpt-5'), // use OpenAI Responses API
|
|
46
|
+
prompt: 'What is an agent?',
|
|
39
47
|
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Agent
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
```ts
|
|
53
|
+
import { Agent } from 'ai';
|
|
54
|
+
|
|
55
|
+
const sandboxAgent = new Agent({
|
|
56
|
+
model: 'openai/gpt-5-codex',
|
|
57
|
+
system: 'You are an agent with access to a shell environment.',
|
|
58
|
+
tools: {
|
|
59
|
+
local_shell: openai.tools.localShell({
|
|
60
|
+
execute: async ({ action }) => {
|
|
61
|
+
const [cmd, ...args] = action.command;
|
|
62
|
+
const sandbox = await getSandbox(); // Vercel Sandbox
|
|
63
|
+
const command = await sandbox.runCommand({ cmd, args });
|
|
64
|
+
return { output: await command.stdout() };
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
});
|
|
42
69
|
```
|
|
43
70
|
|
|
44
|
-
###
|
|
71
|
+
### UI Integration
|
|
45
72
|
|
|
46
73
|
The [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, and Vue.
|
|
47
74
|
|
|
48
|
-
You need to install the package for your framework
|
|
75
|
+
You need to install the package for your framework, e.g.:
|
|
49
76
|
|
|
50
77
|
```shell
|
|
51
|
-
npm
|
|
78
|
+
npm i @ai-sdk/react
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Agent @/agent/image-generation-agent.ts
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { openai } from '@ai-sdk/openai';
|
|
85
|
+
import { Agent, InferAgentUIMessage } from 'ai';
|
|
86
|
+
|
|
87
|
+
export const imageGenerationAgent = new Agent({
|
|
88
|
+
model: openai('gpt-5'),
|
|
89
|
+
tools: {
|
|
90
|
+
image_generation: openai.tools.imageGeneration({
|
|
91
|
+
partialImages: 3,
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export type ImageGenerationAgentMessage = InferAgentUIMessage<
|
|
97
|
+
typeof imageGenerationAgent
|
|
98
|
+
>;
|
|
52
99
|
```
|
|
53
100
|
|
|
54
|
-
|
|
101
|
+
#### Route (Next.js App Router) @/app/api/chat/route.ts
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { imageGenerationAgent } from '@/agent/image-generation-agent';
|
|
105
|
+
import { validateUIMessages } from 'ai';
|
|
106
|
+
|
|
107
|
+
export async function POST(req: Request) {
|
|
108
|
+
const { messages } = await req.json();
|
|
109
|
+
|
|
110
|
+
return imageGenerationAgent.respond({
|
|
111
|
+
messages: await validateUIMessages({ messages }),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### UI Component for Tool @/component/image-generation-view.tsx
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { openai } from '@ai-sdk/openai';
|
|
120
|
+
import { UIToolInvocation } from 'ai';
|
|
121
|
+
|
|
122
|
+
export default function ImageGenerationView({
|
|
123
|
+
invocation,
|
|
124
|
+
}: {
|
|
125
|
+
invocation: UIToolInvocation<ReturnType<typeof openai.tools.imageGeneration>>;
|
|
126
|
+
}) {
|
|
127
|
+
switch (invocation.state) {
|
|
128
|
+
case 'input-available':
|
|
129
|
+
return <div>Generating image...</div>;
|
|
130
|
+
case 'output-available':
|
|
131
|
+
return <img src={`data:image/png;base64,${invocation.output.result}`} />;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Page @/app/page.tsx
|
|
55
137
|
|
|
56
138
|
```tsx
|
|
57
139
|
'use client';
|
|
58
140
|
|
|
59
|
-
import {
|
|
141
|
+
import { ImageGenerationAgentMessage } from '@/agent/image-generation-agent';
|
|
142
|
+
import ImageGenerationView from '@/component/image-generation-view';
|
|
60
143
|
import { useChat } from '@ai-sdk/react';
|
|
61
144
|
|
|
62
145
|
export default function Page() {
|
|
63
|
-
const { messages, status, sendMessage } =
|
|
146
|
+
const { messages, status, sendMessage } =
|
|
147
|
+
useChat<ImageGenerationAgentMessage>();
|
|
148
|
+
|
|
64
149
|
const [input, setInput] = useState('');
|
|
65
150
|
const handleSubmit = e => {
|
|
66
151
|
e.preventDefault();
|
|
@@ -76,9 +161,9 @@ export default function Page() {
|
|
|
76
161
|
{message.parts.map((part, index) => {
|
|
77
162
|
switch (part.type) {
|
|
78
163
|
case 'text':
|
|
79
|
-
return <
|
|
80
|
-
|
|
81
|
-
|
|
164
|
+
return <div key={index}>{part.text}</div>;
|
|
165
|
+
case 'tool-image_generation':
|
|
166
|
+
return <ImageGenerationView key={index} invocation={part} />;
|
|
82
167
|
}
|
|
83
168
|
})}
|
|
84
169
|
</div>
|
|
@@ -87,7 +172,6 @@ export default function Page() {
|
|
|
87
172
|
<form onSubmit={handleSubmit}>
|
|
88
173
|
<input
|
|
89
174
|
value={input}
|
|
90
|
-
placeholder="Send a message..."
|
|
91
175
|
onChange={e => setInput(e.target.value)}
|
|
92
176
|
disabled={status !== 'ready'}
|
|
93
177
|
/>
|
|
@@ -97,28 +181,9 @@ export default function Page() {
|
|
|
97
181
|
}
|
|
98
182
|
```
|
|
99
183
|
|
|
100
|
-
###### @/app/api/chat/route.ts (Next.js App Router)
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
import { streamText } from 'ai';
|
|
104
|
-
import { openai } from '@ai-sdk/openai';
|
|
105
|
-
|
|
106
|
-
export async function POST(req: Request) {
|
|
107
|
-
const { messages } = await req.json();
|
|
108
|
-
|
|
109
|
-
const result = streamText({
|
|
110
|
-
model: openai('gpt-4o'),
|
|
111
|
-
system: 'You are a helpful assistant.',
|
|
112
|
-
messages,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return result.toUIMessageStreamResponse();
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
184
|
## Templates
|
|
120
185
|
|
|
121
|
-
We've built [templates](https://
|
|
186
|
+
We've built [templates](https://ai-sdk.dev/docs/introduction#templates) that include AI SDK integrations for different use cases, providers, and frameworks. You can use these templates to get started with your AI-powered application.
|
|
122
187
|
|
|
123
188
|
## Community
|
|
124
189
|
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMess
|
|
|
3
3
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
|
-
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware,
|
|
6
|
+
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
7
7
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
8
8
|
import * as z3 from 'zod/v3';
|
|
9
9
|
import * as z4 from 'zod/v4';
|
|
@@ -304,7 +304,7 @@ Additional provider-specific metadata that is returned from the provider.
|
|
|
304
304
|
This is needed to enable provider-specific functionality that can be
|
|
305
305
|
fully encapsulated in the provider.
|
|
306
306
|
*/
|
|
307
|
-
type ProviderMetadata =
|
|
307
|
+
type ProviderMetadata = SharedV3ProviderMetadata;
|
|
308
308
|
|
|
309
309
|
/**
|
|
310
310
|
Speech model that is used by the AI SDK Core functions.
|
|
@@ -1597,16 +1597,16 @@ type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
|
|
1597
1597
|
declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
1598
1598
|
type: z.ZodLiteral<"text-start">;
|
|
1599
1599
|
id: z.ZodString;
|
|
1600
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1600
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1601
1601
|
}, z.core.$strict>, z.ZodObject<{
|
|
1602
1602
|
type: z.ZodLiteral<"text-delta">;
|
|
1603
1603
|
id: z.ZodString;
|
|
1604
1604
|
delta: z.ZodString;
|
|
1605
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1605
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1606
1606
|
}, z.core.$strict>, z.ZodObject<{
|
|
1607
1607
|
type: z.ZodLiteral<"text-end">;
|
|
1608
1608
|
id: z.ZodString;
|
|
1609
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1609
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1610
1610
|
}, z.core.$strict>, z.ZodObject<{
|
|
1611
1611
|
type: z.ZodLiteral<"error">;
|
|
1612
1612
|
errorText: z.ZodString;
|
|
@@ -1626,7 +1626,7 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1626
1626
|
toolName: z.ZodString;
|
|
1627
1627
|
input: z.ZodUnknown;
|
|
1628
1628
|
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1629
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1629
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1630
1630
|
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1631
1631
|
}, z.core.$strict>, z.ZodObject<{
|
|
1632
1632
|
type: z.ZodLiteral<"tool-input-error">;
|
|
@@ -1634,7 +1634,7 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1634
1634
|
toolName: z.ZodString;
|
|
1635
1635
|
input: z.ZodUnknown;
|
|
1636
1636
|
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1637
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1637
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1638
1638
|
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1639
1639
|
errorText: z.ZodString;
|
|
1640
1640
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -1653,34 +1653,34 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1653
1653
|
}, z.core.$strict>, z.ZodObject<{
|
|
1654
1654
|
type: z.ZodLiteral<"reasoning-start">;
|
|
1655
1655
|
id: z.ZodString;
|
|
1656
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1656
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1657
1657
|
}, z.core.$strict>, z.ZodObject<{
|
|
1658
1658
|
type: z.ZodLiteral<"reasoning-delta">;
|
|
1659
1659
|
id: z.ZodString;
|
|
1660
1660
|
delta: z.ZodString;
|
|
1661
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1661
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1662
1662
|
}, z.core.$strict>, z.ZodObject<{
|
|
1663
1663
|
type: z.ZodLiteral<"reasoning-end">;
|
|
1664
1664
|
id: z.ZodString;
|
|
1665
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1665
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1666
1666
|
}, z.core.$strict>, z.ZodObject<{
|
|
1667
1667
|
type: z.ZodLiteral<"source-url">;
|
|
1668
1668
|
sourceId: z.ZodString;
|
|
1669
1669
|
url: z.ZodString;
|
|
1670
1670
|
title: z.ZodOptional<z.ZodString>;
|
|
1671
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1671
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1672
1672
|
}, z.core.$strict>, z.ZodObject<{
|
|
1673
1673
|
type: z.ZodLiteral<"source-document">;
|
|
1674
1674
|
sourceId: z.ZodString;
|
|
1675
1675
|
mediaType: z.ZodString;
|
|
1676
1676
|
title: z.ZodString;
|
|
1677
1677
|
filename: z.ZodOptional<z.ZodString>;
|
|
1678
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1678
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1679
1679
|
}, z.core.$strict>, z.ZodObject<{
|
|
1680
1680
|
type: z.ZodLiteral<"file">;
|
|
1681
1681
|
url: z.ZodString;
|
|
1682
1682
|
mediaType: z.ZodString;
|
|
1683
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.
|
|
1683
|
+
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV3ProviderMetadata, unknown>>>;
|
|
1684
1684
|
}, z.core.$strict>, z.ZodObject<{
|
|
1685
1685
|
type: z.ZodCustom<`data-${string}`, `data-${string}`>;
|
|
1686
1686
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -2184,6 +2184,10 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2184
2184
|
};
|
|
2185
2185
|
|
|
2186
2186
|
type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
|
|
2187
|
+
/**
|
|
2188
|
+
* The name of the agent.
|
|
2189
|
+
*/
|
|
2190
|
+
name?: string;
|
|
2187
2191
|
/**
|
|
2188
2192
|
* The system prompt to use.
|
|
2189
2193
|
*/
|
|
@@ -2204,7 +2208,7 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2204
2208
|
Condition for stopping the generation when there are tool results in the last step.
|
|
2205
2209
|
When the condition is an array, any of the conditions can be met to stop the generation.
|
|
2206
2210
|
|
|
2207
|
-
@default stepCountIs(
|
|
2211
|
+
@default stepCountIs(20)
|
|
2208
2212
|
*/
|
|
2209
2213
|
stopWhen?: StopCondition<NoInfer<TOOLS>> | Array<StopCondition<NoInfer<TOOLS>>>;
|
|
2210
2214
|
/**
|
|
@@ -2237,6 +2241,12 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2237
2241
|
*/
|
|
2238
2242
|
onStepFinish?: GenerateTextOnStepFinishCallback<NoInfer<TOOLS>>;
|
|
2239
2243
|
/**
|
|
2244
|
+
Additional provider-specific options. They are passed through
|
|
2245
|
+
to the provider from the AI SDK and enable provider-specific
|
|
2246
|
+
functionality that can be fully encapsulated in the provider.
|
|
2247
|
+
*/
|
|
2248
|
+
providerOptions?: ProviderOptions;
|
|
2249
|
+
/**
|
|
2240
2250
|
* Context that is passed into tool calls.
|
|
2241
2251
|
*
|
|
2242
2252
|
* Experimental (can break in patch releases).
|
|
@@ -2252,38 +2262,28 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2252
2262
|
currentDate?: () => Date;
|
|
2253
2263
|
};
|
|
2254
2264
|
};
|
|
2265
|
+
/**
|
|
2266
|
+
* The Agent class provides a structured way to encapsulate LLM configuration, tools,
|
|
2267
|
+
* and behavior into reusable components.
|
|
2268
|
+
*
|
|
2269
|
+
* It handles the agent loop for you, allowing the LLM to call tools multiple times in
|
|
2270
|
+
* sequence to accomplish complex tasks.
|
|
2271
|
+
*
|
|
2272
|
+
* Define agents once and use them across your application.
|
|
2273
|
+
*/
|
|
2255
2274
|
declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
|
|
2256
2275
|
private readonly settings;
|
|
2257
2276
|
constructor(settings: AgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
/**
|
|
2261
|
-
Additional provider-specific metadata. They are passed through
|
|
2262
|
-
from the provider to the AI SDK and enable provider-specific
|
|
2263
|
-
results that can be fully encapsulated in the provider.
|
|
2277
|
+
/**
|
|
2278
|
+
* The name of the agent.
|
|
2264
2279
|
*/
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
to the provider from the AI SDK and enable provider-specific
|
|
2269
|
-
functionality that can be fully encapsulated in the provider.
|
|
2270
|
-
*/
|
|
2271
|
-
providerOptions?: ProviderOptions;
|
|
2272
|
-
}): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2273
|
-
stream(options: Prompt & {
|
|
2274
|
-
/**
|
|
2275
|
-
Additional provider-specific metadata. They are passed through
|
|
2276
|
-
from the provider to the AI SDK and enable provider-specific
|
|
2277
|
-
results that can be fully encapsulated in the provider.
|
|
2280
|
+
get name(): string | undefined;
|
|
2281
|
+
/**
|
|
2282
|
+
* The tools that the agent can use.
|
|
2278
2283
|
*/
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
to the provider from the AI SDK and enable provider-specific
|
|
2283
|
-
functionality that can be fully encapsulated in the provider.
|
|
2284
|
-
*/
|
|
2285
|
-
providerOptions?: ProviderOptions;
|
|
2286
|
-
}): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
|
|
2284
|
+
get tools(): TOOLS;
|
|
2285
|
+
generate(options: Prompt): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2286
|
+
stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
|
|
2287
2287
|
/**
|
|
2288
2288
|
* Creates a response object that streams UI messages to the client.
|
|
2289
2289
|
*/
|
|
@@ -4620,4 +4620,4 @@ declare global {
|
|
|
4620
4620
|
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
4621
4621
|
}
|
|
4622
4622
|
|
|
4623
|
-
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|
|
4623
|
+
export { AbstractChat, Agent, AgentSettings, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|