Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ai

Package Overview
Dependencies
Maintainers
11
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai - npm Package Compare versions

Comparing version 3.4.10 to 3.4.11

11

CHANGELOG.md
# ai
## 3.4.11
### Patch Changes
- caedcda: feat (ai/ui): add setData helper to useChat
- Updated dependencies [caedcda]
- @ai-sdk/svelte@0.0.52
- @ai-sdk/react@0.0.63
- @ai-sdk/solid@0.0.50
- @ai-sdk/vue@0.0.55
## 3.4.10

@@ -4,0 +15,0 @@

10

package.json
{
"name": "ai",
"version": "3.4.10",
"version": "3.4.11",
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",

@@ -69,7 +69,7 @@ "license": "Apache-2.0",

"@ai-sdk/provider-utils": "1.0.20",
"@ai-sdk/react": "0.0.62",
"@ai-sdk/solid": "0.0.49",
"@ai-sdk/svelte": "0.0.51",
"@ai-sdk/react": "0.0.63",
"@ai-sdk/solid": "0.0.50",
"@ai-sdk/svelte": "0.0.52",
"@ai-sdk/ui-utils": "0.0.46",
"@ai-sdk/vue": "0.0.54",
"@ai-sdk/vue": "0.0.55",
"@opentelemetry/api": "1.9.0",

@@ -76,0 +76,0 @@ "eventsource-parser": "1.1.2",

@@ -104,111 +104,2 @@ ![hero illustration](./assets/hero.gif)

### AI SDK RSC
The [AI SDK RSC](https://sdk.vercel.ai/docs/ai-sdk-rsc/overview) module provides an alternative API that also helps you build chatbots and generative user interfaces for frameworks that support [React Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components) (RSC).
This API leverages the benefits of [Streaming](https://nextjs.org/docs/app/building-your-application/rendering/server-components#streaming) and [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations) offered by RSC, thus improving the developer experience of managing states between server/client and building generative user interfaces.
###### @/app/actions.tsx (Next.js App Router)
```tsx
import { streamUI } from 'ai/rsc';
import { z } from 'zod';
async function submitMessage() {
'use server';
const stream = await streamUI({
model: openai('gpt-4-turbo'),
messages: [
{ role: 'system', content: 'You are a friendly bot!' },
{ role: 'user', content: input },
],
text: ({ content, done }) => {
return <div>{content}</div>;
},
tools: {
deploy: {
description: 'Deploy repository to vercel',
parameters: z.object({
repositoryName: z
.string()
.describe('The name of the repository, example: vercel/ai-chatbot'),
}),
generate: async function* ({ repositoryName }) {
yield <div>Cloning repository {repositoryName}...</div>;
await new Promise(resolve => setTimeout(resolve, 3000));
yield <div>Building repository {repositoryName}...</div>;
await new Promise(resolve => setTimeout(resolve, 2000));
return <div>{repositoryName} deployed!</div>;
},
},
},
});
return {
ui: stream.value,
};
}
```
###### @/app/ai.ts (Next.js App Router)
```tsx
import { createAI } from 'ai/rsc';
import { submitMessage } from '@/app/actions';
export const AI = createAI({
initialAIState: {},
initialUIState: {},
actions: {
submitMessage,
},
});
```
###### @/app/layout.tsx (Next.js App Router)
```tsx
import { ReactNode } from 'react';
import { AI } from '@/app/ai';
export default function Layout({ children }: { children: ReactNode }) {
<AI>{children}</AI>;
}
```
###### @/app/page.tsx (Next.js App Router)
```tsx
'use client';
import { useActions } from 'ai/rsc';
import { ReactNode, useState } from 'react';
export default function Page() {
const [input, setInput] = useState('');
const [messages, setMessages] = useState<ReactNode[]>([]);
const { submitMessage } = useActions();
return (
<div>
<input
value={input}
onChange={event => {
setInput(event.target.value);
}}
/>
<button
onClick={async () => {
const { ui } = await submitMessage(input);
setMessages(currentMessages => [...currentMessages, ui]);
}}
>
Submit
</button>
</div>
);
}
```
## Templates

@@ -215,0 +106,0 @@

@@ -69,2 +69,4 @@ import { UseChatOptions as UseChatOptions$1, Message, CreateMessage, ChatRequestOptions, JSONValue, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils';

data: Readable<JSONValue[] | undefined>;
/** Set the data of the chat. You can use this to transform or clear the chat data. */
setData: (data: JSONValue[] | undefined | ((data: JSONValue[] | undefined) => JSONValue[] | undefined)) => void;
};

@@ -71,0 +73,0 @@ /**

@@ -811,2 +811,8 @@ "use strict";

};
const setData = (dataArg) => {
if (typeof dataArg === "function") {
dataArg = dataArg((0, import_store.get)(streamData));
}
streamData.set(dataArg);
};
const input = (0, import_store.writable)(initialInput);

@@ -878,2 +884,3 @@ const handleSubmit = (event, options = {}) => {

data: streamData,
setData,
addToolResult

@@ -880,0 +887,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc