diff --git a/docs/third-party-libraries/ai.mdx b/docs/third-party-libraries/ai.mdx new file mode 100644 index 0000000000..c26e09d053 --- /dev/null +++ b/docs/third-party-libraries/ai.mdx @@ -0,0 +1,83 @@ +--- +title: AI +description: A Jōtai utility package compatible with Vercel AI SDK. +nav: 9.01 +keywords: ai,vercel +--- + +[jotai-ai](https://github.com/himself65/jotai-ai) is a utility package compatible with [Vercel AI SDK](https://sdk.vercel.ai/docs). + +## install + +``` +yarn add jotai-ai +``` + +## chatAtoms + +`chatAtoms` is a collection of atoms for a chatbot like [`useChat`](https://sdk.vercel.ai/docs/api-reference/use-chat). + +```js +import { useAtomValue, useAtom, useSetAtom } from 'jotai' +import { chatAtoms } from 'jotai-ai' + +const { + messagesAtom, + inputAtom, + submitAtom, + isLoadingAtom, +} = chatAtoms() + +function Messages () { + const messages = useAtomValue(messagesAtom) + return ( + <> + {messages.length > 0 + ? messages.map(m => ( +