From e8c79b4de38b7c6467556e33eabd54f705795535 Mon Sep 17 00:00:00 2001 From: Sreeram Sreedhar Date: Sat, 9 May 2026 15:12:12 -0400 Subject: [PATCH] updated docs --- apps/docs/integrations/convex.mdx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/docs/integrations/convex.mdx b/apps/docs/integrations/convex.mdx index 259f0119..37130a84 100644 --- a/apps/docs/integrations/convex.mdx +++ b/apps/docs/integrations/convex.mdx @@ -22,6 +22,12 @@ Install the packages: npm install supermemory convex ``` +For the AI chat example, also install the AI SDK packages: + +```bash +npm install @supermemory/tools @ai-sdk/openai ai +``` + Set up your environment variable in Convex: ```bash @@ -96,7 +102,9 @@ export const chat = action({ args: { userId: v.string(), message: v.string() }, handler: async (ctx, { userId, message }) => { // Wrap the model - automatically injects context and saves memories - const model = withSupermemory(openai("gpt-4o-mini"), userId, { + const model = withSupermemory(openai("gpt-4o-mini"), { + containerTag: userId, + customId: `convex-chat-${userId}`, mode: "full", addMemory: "always", }); @@ -161,6 +169,8 @@ export const addMemory = action({ await memory.add({ content, containerTag: userId }); // Store in Convex + // Note: in production, handle partial failures — if the Convex mutation + // fails after the Supermemory write succeeds, the two stores will be out of sync. await ctx.runMutation(api.memory.storeMemory, { userId, content }); }, });