@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/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 { generateObject } from 'ai';
53
+ import { generateText, Output } from 'ai';
54
54
  import { z } from 'zod';
55
55
 
56
- const { object } = await generateObject({
57
- model: 'openai/gpt-4.1',
58
- schema: z.object({
59
- recipe: z.object({
60
- name: z.string(),
61
- ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
62
- steps: z.array(z.string()),
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 { Agent } from 'ai';
76
+ import { ToolLoopAgent } from 'ai';
73
77
 
74
- const sandboxAgent = new Agent({
75
- model: 'openai/gpt-5-codex',
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
- local_shell: openai.tools.localShell({
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 { Agent, InferAgentUIMessage } from 'ai';
108
+ import { ToolLoopAgent, InferAgentUIMessage } from 'ai';
105
109
 
106
- export const imageGenerationAgent = new Agent({
110
+ export const imageGenerationAgent = new ToolLoopAgent({
107
111
  model: openai('gpt-5'),
108
112
  tools: {
109
- image_generation: openai.tools.imageGeneration({
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 { validateUIMessages } from 'ai';
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 imageGenerationAgent.respond({
130
- messages: await validateUIMessages({ messages }),
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-image_generation':
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 [GitHub Discussions](https://github.com/vercel/ai/discussions) where you can ask questions, voice ideas, and share your projects with other people.
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