getmnemo-vercel-ai 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +94 -13
  2. package/package.json +6 -3
package/README.md CHANGED
@@ -1,28 +1,28 @@
1
- # @ledgermem/vercel-ai
1
+ # getmnemo-vercel-ai
2
2
 
3
- LedgerMem adapter for the [Vercel AI SDK](https://sdk.vercel.dev). Drop-in
3
+ [Mnemo](https://mnemohq.com) adapter for the [Vercel AI SDK](https://sdk.vercel.dev). Drop-in
4
4
  `tool()` definitions that let any model search and write persistent memory,
5
5
  plus a small React hook for client-side memory views.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install @ledgermem/vercel-ai @ledgermem/memory ai
10
+ npm install getmnemo-vercel-ai ai
11
11
  ```
12
12
 
13
- Set `LEDGERMEM_API_KEY` and `LEDGERMEM_WORKSPACE_ID` in your environment, or
14
- pass them explicitly.
13
+ `getmnemo` (the core SDK) is bundled as a dependency. Set `GETMNEMO_API_KEY`
14
+ and `GETMNEMO_WORKSPACE_ID` in your environment, or pass them explicitly.
15
15
 
16
16
  ## Quickstart (30 seconds)
17
17
 
18
18
  ```ts
19
19
  import { streamText } from "ai";
20
20
  import { openai } from "@ai-sdk/openai";
21
- import { ledgermemTools } from "@ledgermem/vercel-ai";
21
+ import { getmnemoTools } from "getmnemo-vercel-ai";
22
22
 
23
23
  const result = await streamText({
24
24
  model: openai("gpt-4o"),
25
- tools: ledgermemTools, // memorySearch + memoryAdd
25
+ tools: getmnemoTools, // memorySearch + memoryAdd
26
26
  maxSteps: 5,
27
27
  messages: [{ role: "user", content: "What did I tell you about my coffee?" }],
28
28
  });
@@ -30,34 +30,115 @@ const result = await streamText({
30
30
  for await (const chunk of result.textStream) process.stdout.write(chunk);
31
31
  ```
32
32
 
33
+ `getmnemoTools` is lazy — it reads `GETMNEMO_API_KEY` and
34
+ `GETMNEMO_WORKSPACE_ID` from `process.env` the first time a tool runs.
35
+
33
36
  ## Per-user memory (route handler)
34
37
 
38
+ Use `createMnemoTools` when you need per-request scoping. The `metadata` you
39
+ pass is merged into every `memoryAdd` call (and cannot be overwritten by the
40
+ model), so it's the right place for a `userId`:
41
+
35
42
  ```ts
36
- import { createLedgerMemTools } from "@ledgermem/vercel-ai";
43
+ import { streamText } from "ai";
44
+ import { openai } from "@ai-sdk/openai";
45
+ import { createMnemoTools } from "getmnemo-vercel-ai";
37
46
 
38
47
  export async function POST(req: Request) {
39
48
  const { messages, userId } = await req.json();
40
- const tools = createLedgerMemTools({ metadata: { userId } });
41
- return streamText({ model: openai("gpt-4o"), tools, messages }).toDataStreamResponse();
49
+ const tools = createMnemoTools({ metadata: { userId } });
50
+
51
+ const result = streamText({
52
+ model: openai("gpt-4o"),
53
+ tools,
54
+ maxSteps: 5,
55
+ messages,
56
+ });
57
+
58
+ return result.toDataStreamResponse();
42
59
  }
43
60
  ```
44
61
 
62
+ `createMnemoTools` also accepts `apiKey` / `workspaceId` (instead of env vars),
63
+ a pre-built `client`, and a `defaultLimit` for searches the model doesn't size:
64
+
65
+ ```ts
66
+ const tools = createMnemoTools({
67
+ apiKey: process.env.GETMNEMO_API_KEY,
68
+ workspaceId: process.env.GETMNEMO_WORKSPACE_ID,
69
+ defaultLimit: 8,
70
+ });
71
+ ```
72
+
73
+ ## One-shot generation
74
+
75
+ The same tools work with `generateText`:
76
+
77
+ ```ts
78
+ import { generateText } from "ai";
79
+ import { openai } from "@ai-sdk/openai";
80
+ import { getmnemoTools } from "getmnemo-vercel-ai";
81
+
82
+ const { text } = await generateText({
83
+ model: openai("gpt-4o"),
84
+ tools: getmnemoTools,
85
+ maxSteps: 5,
86
+ prompt: "Remember that I'm vegetarian, then suggest a dinner.",
87
+ });
88
+ ```
89
+
90
+ ## Direct SDK access
91
+
92
+ Need to read or write memory outside a model loop? Use the core client
93
+ directly:
94
+
95
+ ```ts
96
+ import { Mnemo } from "getmnemo";
97
+
98
+ const memory = new Mnemo({
99
+ apiKey: process.env.GETMNEMO_API_KEY!,
100
+ workspaceId: process.env.GETMNEMO_WORKSPACE_ID!,
101
+ });
102
+
103
+ await memory.add({ content: "User prefers oat milk." });
104
+ const { hits } = await memory.search({ query: "what milk does the user like?" });
105
+ ```
106
+
45
107
  ## React hook
46
108
 
109
+ For client-side memory views (sidebars, inspectors), use `useMnemo`. It reads
110
+ `NEXT_PUBLIC_GETMNEMO_API_KEY` / `NEXT_PUBLIC_GETMNEMO_WORKSPACE_ID` by default
111
+ — but note those keys are public, so prefer a server route for production
112
+ writes. The hook returns `SearchHit` objects, keyed by `memoryId`:
113
+
47
114
  ```tsx
48
115
  "use client";
49
- import { useLedgerMem } from "@ledgermem/vercel-ai/react";
116
+ import { useMnemo } from "getmnemo-vercel-ai/react";
117
+ import type { SearchHit } from "getmnemo";
50
118
 
51
119
  export function MemorySidebar() {
52
- const { results, search, loading } = useLedgerMem({ initialQuery: "preferences" });
120
+ const { results, search, loading } = useMnemo<SearchHit>({
121
+ initialQuery: "preferences",
122
+ });
123
+
124
+ if (loading) return <p>Loading…</p>;
125
+
53
126
  return (
54
127
  <ul>
55
- {results.map((m: any) => <li key={m.id}>{m.content}</li>)}
128
+ {results.map((m) => (
129
+ <li key={m.memoryId}>{m.content}</li>
130
+ ))}
56
131
  </ul>
57
132
  );
58
133
  }
59
134
  ```
60
135
 
136
+ `useMnemo` also exposes `add(content, metadata?)`, `remove(id)`, and `error`.
137
+
138
+ ## Docs
139
+
140
+ Full documentation at [mnemohq.com](https://mnemohq.com).
141
+
61
142
  ## License
62
143
 
63
144
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getmnemo-vercel-ai",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Mnemo adapter for the Vercel AI SDK — drop-in tools for streamText / generateText / useChat.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,10 @@
34
34
  "rag",
35
35
  "tools"
36
36
  ],
37
- "author": "Mnemo <founders@getmnemo.xyz>",
37
+ "author": {
38
+ "name": "Mnemo",
39
+ "url": "https://mnemohq.com"
40
+ },
38
41
  "license": "MIT",
39
42
  "repository": {
40
43
  "type": "git",
@@ -67,5 +70,5 @@
67
70
  "engines": {
68
71
  "node": ">=18.17.0"
69
72
  },
70
- "homepage": "https://getmnemo.xyz"
73
+ "homepage": "https://mnemohq.com"
71
74
  }