@zenning/ai 5.3.2 → 6.0.13
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 +1501 -362
- package/LICENSE +13 -0
- package/README.md +26 -21
- package/dist/index.d.mts +3579 -2691
- package/dist/index.d.ts +3579 -2691
- package/dist/index.js +5243 -3804
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5235 -3810
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +106 -9
- package/dist/internal/index.d.ts +106 -9
- package/dist/internal/index.js +321 -174
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +295 -147
- package/dist/internal/index.mjs.map +1 -1
- package/dist/test/index.d.mts +54 -38
- package/dist/test/index.d.ts +54 -38
- package/dist/test/index.js +48 -14
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +45 -12
- package/dist/test/index.mjs.map +1 -1
- package/package.json +27 -31
- package/dist/mcp-stdio/index.d.mts +0 -89
- package/dist/mcp-stdio/index.d.ts +0 -89
- package/dist/mcp-stdio/index.js +0 -349
- package/dist/mcp-stdio/index.js.map +0 -1
- package/dist/mcp-stdio/index.mjs +0 -322
- package/dist/mcp-stdio/index.mjs.map +0 -1
- package/mcp-stdio.d.ts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
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 and agents 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 provider-agnostic TypeScript toolkit designed to help you build AI-powered applications and agents using popular UI frameworks like Next.js, React, Svelte, Vue, Angular, 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
|
|
|
@@ -50,16 +50,20 @@ const { text } = await generateText({
|
|
|
50
50
|
### Generating Structured Data
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
import {
|
|
53
|
+
import { generateText, Output } from 'ai';
|
|
54
54
|
import { z } from 'zod';
|
|
55
55
|
|
|
56
|
-
const {
|
|
57
|
-
model: 'openai/gpt-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
const { output } = await generateText({
|
|
57
|
+
model: 'openai/gpt-5',
|
|
58
|
+
output: Output.object({
|
|
59
|
+
schema: z.object({
|
|
60
|
+
recipe: z.object({
|
|
61
|
+
name: z.string(),
|
|
62
|
+
ingredients: z.array(
|
|
63
|
+
z.object({ name: z.string(), amount: z.string() }),
|
|
64
|
+
),
|
|
65
|
+
steps: z.array(z.string()),
|
|
66
|
+
}),
|
|
63
67
|
}),
|
|
64
68
|
}),
|
|
65
69
|
prompt: 'Generate a lasagna recipe.',
|
|
@@ -69,13 +73,13 @@ const { object } = await generateObject({
|
|
|
69
73
|
### Agents
|
|
70
74
|
|
|
71
75
|
```ts
|
|
72
|
-
import {
|
|
76
|
+
import { ToolLoopAgent } from 'ai';
|
|
73
77
|
|
|
74
|
-
const sandboxAgent = new
|
|
75
|
-
model: 'openai/gpt-5
|
|
78
|
+
const sandboxAgent = new ToolLoopAgent({
|
|
79
|
+
model: 'openai/gpt-5',
|
|
76
80
|
system: 'You are an agent with access to a shell environment.',
|
|
77
81
|
tools: {
|
|
78
|
-
|
|
82
|
+
shell: openai.tools.localShell({
|
|
79
83
|
execute: async ({ action }) => {
|
|
80
84
|
const [cmd, ...args] = action.command;
|
|
81
85
|
const sandbox = await getSandbox(); // Vercel Sandbox
|
|
@@ -101,12 +105,12 @@ npm install @ai-sdk/react
|
|
|
101
105
|
|
|
102
106
|
```ts
|
|
103
107
|
import { openai } from '@ai-sdk/openai';
|
|
104
|
-
import {
|
|
108
|
+
import { ToolLoopAgent, InferAgentUIMessage } from 'ai';
|
|
105
109
|
|
|
106
|
-
export const imageGenerationAgent = new
|
|
110
|
+
export const imageGenerationAgent = new ToolLoopAgent({
|
|
107
111
|
model: openai('gpt-5'),
|
|
108
112
|
tools: {
|
|
109
|
-
|
|
113
|
+
generateImage: openai.tools.imageGeneration({
|
|
110
114
|
partialImages: 3,
|
|
111
115
|
}),
|
|
112
116
|
},
|
|
@@ -121,13 +125,14 @@ export type ImageGenerationAgentMessage = InferAgentUIMessage<
|
|
|
121
125
|
|
|
122
126
|
```tsx
|
|
123
127
|
import { imageGenerationAgent } from '@/agent/image-generation-agent';
|
|
124
|
-
import {
|
|
128
|
+
import { createAgentUIStreamResponse } from 'ai';
|
|
125
129
|
|
|
126
130
|
export async function POST(req: Request) {
|
|
127
131
|
const { messages } = await req.json();
|
|
128
132
|
|
|
129
|
-
return
|
|
130
|
-
|
|
133
|
+
return createAgentUIStreamResponse({
|
|
134
|
+
agent: imageGenerationAgent,
|
|
135
|
+
messages,
|
|
131
136
|
});
|
|
132
137
|
}
|
|
133
138
|
```
|
|
@@ -181,7 +186,7 @@ export default function Page() {
|
|
|
181
186
|
switch (part.type) {
|
|
182
187
|
case 'text':
|
|
183
188
|
return <div key={index}>{part.text}</div>;
|
|
184
|
-
case 'tool-
|
|
189
|
+
case 'tool-generateImage':
|
|
185
190
|
return <ImageGenerationView key={index} invocation={part} />;
|
|
186
191
|
}
|
|
187
192
|
})}
|
|
@@ -206,7 +211,7 @@ We've built [templates](https://ai-sdk.dev/docs/introduction#templates) that inc
|
|
|
206
211
|
|
|
207
212
|
## Community
|
|
208
213
|
|
|
209
|
-
The AI SDK community can be found on [
|
|
214
|
+
The AI SDK community can be found on [the Vercel Community](https://community.vercel.com/c/ai-sdk/62) where you can ask questions, voice ideas, and share your projects with other people.
|
|
210
215
|
|
|
211
216
|
## Contributing
|
|
212
217
|
|