diff --git a/.changeset/two-pianos-tell.md b/.changeset/two-pianos-tell.md new file mode 100644 index 000000000..5e186d77b --- /dev/null +++ b/.changeset/two-pianos-tell.md @@ -0,0 +1,5 @@ +--- +"@assistant-ui/react-ai-sdk": patch +--- + +feat(ai-sdk): replace ai package dependency with @ai-sdk/react diff --git a/packages/react-ai-sdk/package.json b/packages/react-ai-sdk/package.json index a0ebafbdc..c64ceb7e6 100644 --- a/packages/react-ai-sdk/package.json +++ b/packages/react-ai-sdk/package.json @@ -27,6 +27,8 @@ "build": "tsup src/index.ts --format cjs,esm --dts --sourcemap --clean" }, "dependencies": { + "@ai-sdk/react": "*", + "@ai-sdk/ui-utils": "*", "@radix-ui/react-use-callback-ref": "^1.1.0", "zod": "^3.23.8", "zustand": "^4.5.5" @@ -34,7 +36,6 @@ "peerDependencies": { "@assistant-ui/react": "^0.5.76", "@types/react": "*", - "ai": "^3.2.x", "react": "^18" }, "peerDependenciesMeta": { diff --git a/packages/react-ai-sdk/src/ui/getVercelAIMessages.tsx b/packages/react-ai-sdk/src/ui/getVercelAIMessages.tsx index df438d003..0cc22249f 100644 --- a/packages/react-ai-sdk/src/ui/getVercelAIMessages.tsx +++ b/packages/react-ai-sdk/src/ui/getVercelAIMessages.tsx @@ -2,7 +2,7 @@ import { getExternalStoreMessage, type ThreadMessage, } from "@assistant-ui/react"; -import type { Message } from "ai"; +import type { Message } from "@ai-sdk/ui-utils"; export const getVercelAIMessages = (message: ThreadMessage) => { return getExternalStoreMessage(message) as Message[]; diff --git a/packages/react-ai-sdk/src/ui/use-assistant/useVercelUseAssistantRuntime.tsx b/packages/react-ai-sdk/src/ui/use-assistant/useVercelUseAssistantRuntime.tsx index 5a749e9cc..efc538e24 100644 --- a/packages/react-ai-sdk/src/ui/use-assistant/useVercelUseAssistantRuntime.tsx +++ b/packages/react-ai-sdk/src/ui/use-assistant/useVercelUseAssistantRuntime.tsx @@ -1,4 +1,4 @@ -import type { useAssistant } from "ai/react"; +import type { useAssistant } from "@ai-sdk/react"; import { useExternalMessageConverter, useExternalStoreRuntime, diff --git a/packages/react-ai-sdk/src/ui/use-chat/useVercelUseChatRuntime.tsx b/packages/react-ai-sdk/src/ui/use-chat/useVercelUseChatRuntime.tsx index dd05bf38c..da322e553 100644 --- a/packages/react-ai-sdk/src/ui/use-chat/useVercelUseChatRuntime.tsx +++ b/packages/react-ai-sdk/src/ui/use-chat/useVercelUseChatRuntime.tsx @@ -1,4 +1,4 @@ -import type { useChat } from "ai/react"; +import type { useChat } from "@ai-sdk/react"; import { convertMessage } from "../utils/convertMessage"; import { useExternalMessageConverter, diff --git a/packages/react-ai-sdk/src/ui/utils/convertMessage.ts b/packages/react-ai-sdk/src/ui/utils/convertMessage.ts index 15207ffc9..4db71eca9 100644 --- a/packages/react-ai-sdk/src/ui/utils/convertMessage.ts +++ b/packages/react-ai-sdk/src/ui/utils/convertMessage.ts @@ -1,4 +1,4 @@ -import { Message } from "ai"; +import { Message } from "@ai-sdk/ui-utils"; import { useExternalMessageConverter } from "@assistant-ui/react"; import { ToolCallContentPart } from "@assistant-ui/react"; import { TextContentPart } from "@assistant-ui/react"; diff --git a/packages/react-ai-sdk/src/ui/utils/sliceMessagesUntil.tsx b/packages/react-ai-sdk/src/ui/utils/sliceMessagesUntil.tsx index 0a33e09dd..651bd2636 100644 --- a/packages/react-ai-sdk/src/ui/utils/sliceMessagesUntil.tsx +++ b/packages/react-ai-sdk/src/ui/utils/sliceMessagesUntil.tsx @@ -1,4 +1,4 @@ -import type { Message } from "ai"; +import type { Message } from "@ai-sdk/ui-utils"; export const sliceMessagesUntil = ( messages: Message[], diff --git a/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts b/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts index 1f5714657..4cb68f483 100644 --- a/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts +++ b/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts @@ -1,5 +1,5 @@ import { AppendMessage } from "@assistant-ui/react"; -import { CreateMessage } from "ai"; +import { CreateMessage } from "@ai-sdk/ui-utils"; export const toCreateMessage = async ( message: AppendMessage, diff --git a/packages/react-ai-sdk/src/ui/utils/useInputSync.tsx b/packages/react-ai-sdk/src/ui/utils/useInputSync.tsx index 8d34d86d1..2293daf7e 100644 --- a/packages/react-ai-sdk/src/ui/utils/useInputSync.tsx +++ b/packages/react-ai-sdk/src/ui/utils/useInputSync.tsx @@ -1,5 +1,5 @@ import { useEffect } from "react"; -import { useAssistant, useChat } from "ai/react"; +import { useAssistant, useChat } from "@ai-sdk/react"; import { AssistantRuntime } from "@assistant-ui/react"; import { useCallbackRef } from "@radix-ui/react-use-callback-ref"; diff --git a/packages/react-ai-sdk/src/ui/utils/vercelAttachmentAdapter.ts b/packages/react-ai-sdk/src/ui/utils/vercelAttachmentAdapter.ts index 2323b9621..c0016d9ba 100644 --- a/packages/react-ai-sdk/src/ui/utils/vercelAttachmentAdapter.ts +++ b/packages/react-ai-sdk/src/ui/utils/vercelAttachmentAdapter.ts @@ -1,5 +1,5 @@ import { AttachmentAdapter } from "@assistant-ui/react"; -import { generateId } from "ai"; +import { generateId } from "@ai-sdk/ui-utils"; export const vercelAttachmentAdapter: AttachmentAdapter = { accept: diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ce330d0e..f41218ea4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1184,6 +1184,12 @@ importers: packages/react-ai-sdk: dependencies: + '@ai-sdk/react': + specifier: '*' + version: 0.0.62(react@18.3.1)(zod@3.23.8) + '@ai-sdk/ui-utils': + specifier: '*' + version: 0.0.46(zod@3.23.8) '@assistant-ui/react': specifier: ^0.5.76 version: link:../react @@ -1193,9 +1199,6 @@ importers: '@types/react': specifier: '*' version: 18.3.11 - ai: - specifier: ^3.2.x - version: 3.4.9(openai@4.67.3(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.5.12(typescript@5.6.3))(zod@3.23.8) react: specifier: ^18 version: 18.3.1