diff --git a/docs/changelog.mdx b/docs/changelog.mdx index 0357ef3b8..96f39925c 100644 --- a/docs/changelog.mdx +++ b/docs/changelog.mdx @@ -992,6 +992,11 @@ mode: "wide" + +**New Features:** +- **Vercel AI SDK:** Migration to AI SDK V5. + + **New Features:** - **Vercel AI SDK:** Added param `filter_memories`. diff --git a/docs/integrations/vercel-ai-sdk.mdx b/docs/integrations/vercel-ai-sdk.mdx index 3566f2e7e..098f1ed95 100644 --- a/docs/integrations/vercel-ai-sdk.mdx +++ b/docs/integrations/vercel-ai-sdk.mdx @@ -7,7 +7,7 @@ title: Vercel AI SDK The [**Mem0 AI SDK Provider**](https://www.npmjs.com/package/@mem0/vercel-ai-provider) is a library developed by **Mem0** to integrate with the Vercel AI SDK. This library brings enhanced AI interaction capabilities to your applications by introducing persistent memory functionality. - 🎉 Exciting news! Mem0 AI SDK now supports Graph Memory. + 🎉 Exciting news! Mem0 AI SDK now supports Vercel AI SDK V5. ## Overview @@ -42,13 +42,11 @@ npm install @mem0/vercel-ai-provider mem0ApiKey: "m0-xxx", apiKey: "provider-api-key", config: { - compatibility: "strict", + // Options for LLM Provider }, // Optional Mem0 Global Config mem0Config: { user_id: "mem0-user-id", - org_id: "mem0-org-id", - project_id: "mem0-project-id", }, }); ``` @@ -60,10 +58,10 @@ npm install @mem0/vercel-ai-provider 3. Add Memories to Enhance Context: ```typescript - import { LanguageModelV1Prompt } from "ai"; + import { LanguageModelV2Prompt } from "@ai-sdk/provider"; import { addMemories } from "@mem0/vercel-ai-provider"; - const messages: LanguageModelV1Prompt = [ + const messages: LanguageModelV2Prompt = [ { role: "user", content: [{ type: "text", text: "I love red cars." }] }, ]; @@ -73,9 +71,9 @@ npm install @mem0/vercel-ai-provider ### Standalone Features: ```typescript - await addMemories(messages, { user_id: "borat", mem0ApiKey: "m0-xxx", org_id: "org_xx", project_id: "proj_xx" }); - await retrieveMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx", org_id: "org_xx", project_id: "proj_xx" }); - await getMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx", org_id: "org_xx", project_id: "proj_xx" }); + await addMemories(messages, { user_id: "borat", mem0ApiKey: "m0-xxx" }); + await retrieveMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx" }); + await getMemories(prompt, { user_id: "borat", mem0ApiKey: "m0-xxx" }); ``` > For standalone features, such as `addMemories`, `retrieveMemories`, and `getMemories`, you must either set `MEM0_API_KEY` as an environment variable or pass it directly in the function call. @@ -144,7 +142,7 @@ npm install @mem0/vercel-ai-provider const mem0 = createMem0(); - const { textStream } = await streamText({ + const { textStream } = streamText({ model: mem0("gpt-4-turbo", { user_id: "borat", }), @@ -231,9 +229,7 @@ The `getMemories` function will return an object with two keys: `results` and `r |----------|-------------------| | OpenAI | openai | | Anthropic | anthropic | -| Gemini | gemini | | Google | google | -| Mistral | mistral | | Groq | groq | > **Note**: You can use `google` as provider for Gemini (Google) models. They are same and internally they use `@ai-sdk/google` package.