ai 0.0.0-156c9f7b-20250115085202 → 0.0.0-677c097b-20250505090413
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 +774 -2
- package/README.md +22 -9
- package/dist/index.d.mts +3081 -1016
- package/dist/index.d.ts +3081 -1016
- package/dist/index.js +3120 -975
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3060 -931
- package/dist/index.mjs.map +1 -1
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +352 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +337 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/package.json +15 -11
- package/react/dist/index.d.mts +13 -1
- package/react/dist/index.d.ts +13 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +108 -18
- package/rsc/dist/rsc-server.d.mts +108 -18
- package/rsc/dist/rsc-server.mjs +603 -274
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +1 -3
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/test/dist/index.d.mts +2 -4
- package/test/dist/index.d.ts +2 -4
- package/test/dist/index.js +4 -14
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +7 -14
- package/test/dist/index.mjs.map +1 -1
package/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
# AI SDK
|
4
4
|
|
5
|
-
The [AI SDK](https://sdk.
|
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.
|
6
6
|
|
7
|
-
To learn more about how to use the AI SDK, check out our [API Reference](https://sdk.
|
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
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -18,7 +18,7 @@ npm install ai
|
|
18
18
|
|
19
19
|
### AI SDK Core
|
20
20
|
|
21
|
-
The [AI SDK Core](https://sdk.
|
21
|
+
The [AI SDK Core](https://ai-sdk.dev/docs/ai-sdk-core/overview) module provides a unified API 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.
|
22
22
|
|
23
23
|
You will then install the model provider of your choice.
|
24
24
|
|
@@ -43,25 +43,38 @@ console.log(text);
|
|
43
43
|
|
44
44
|
### AI SDK UI
|
45
45
|
|
46
|
-
The [AI SDK UI](https://sdk.
|
46
|
+
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
|
+
|
48
|
+
You need to install the package for your framework:
|
49
|
+
|
50
|
+
```shell
|
51
|
+
npm install @ai-sdk/react
|
52
|
+
```
|
47
53
|
|
48
54
|
###### @/app/page.tsx (Next.js App Router)
|
49
55
|
|
50
56
|
```tsx
|
51
57
|
'use client';
|
52
58
|
|
53
|
-
import { useChat } from 'ai/react';
|
59
|
+
import { useChat } from '@ai-sdk/react';
|
54
60
|
|
55
61
|
export default function Page() {
|
56
|
-
const { messages, input, handleSubmit, handleInputChange,
|
62
|
+
const { messages, input, handleSubmit, handleInputChange, status } =
|
57
63
|
useChat();
|
58
64
|
|
59
65
|
return (
|
60
66
|
<div>
|
61
67
|
{messages.map(message => (
|
62
68
|
<div key={message.id}>
|
63
|
-
<
|
64
|
-
|
69
|
+
<strong>{`${message.role}: `}</strong>
|
70
|
+
{message.parts.map((part, index) => {
|
71
|
+
switch (part.type) {
|
72
|
+
case 'text':
|
73
|
+
return <span key={index}>{part.text}</span>;
|
74
|
+
|
75
|
+
// other cases can handle images, tool calls, etc
|
76
|
+
}
|
77
|
+
})}
|
65
78
|
</div>
|
66
79
|
))}
|
67
80
|
|
@@ -70,7 +83,7 @@ export default function Page() {
|
|
70
83
|
value={input}
|
71
84
|
placeholder="Send a message..."
|
72
85
|
onChange={handleInputChange}
|
73
|
-
disabled={
|
86
|
+
disabled={status !== 'ready'}
|
74
87
|
/>
|
75
88
|
</form>
|
76
89
|
</div>
|