diff options
| author | Dhravya Shah <[email protected]> | 2025-11-27 09:53:11 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-11-27 09:53:11 -0700 |
| commit | 2f8bafac4ecdbf5eccf49219b898fd6586f338a3 (patch) | |
| tree | 0b97ae1eaab5257a5658da38bcff0e4acd36c602 /apps/docs/test.ts | |
| parent | runtime styles injection + let user proxy requests for data in graph package ... (diff) | |
| download | supermemory-2f8bafac4ecdbf5eccf49219b898fd6586f338a3.tar.xz supermemory-2f8bafac4ecdbf5eccf49219b898fd6586f338a3.zip | |
update quickstart
Diffstat (limited to 'apps/docs/test.ts')
| -rw-r--r-- | apps/docs/test.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/docs/test.ts b/apps/docs/test.ts new file mode 100644 index 00000000..21c8bb8e --- /dev/null +++ b/apps/docs/test.ts @@ -0,0 +1,42 @@ +import Supermemory from "supermemory" + +const client = new Supermemory() +const USER_ID = "dhravya" + +const conversation = [ + { role: "assistant", content: "Hello, how are you doing?" }, + { + role: "user", + content: "Hello! I am Dhravya. I am 20 years old. I love to code!", + }, + { role: "user", content: "Can I go to the club?" }, +] + +// Get user profile + relevant memories for context +const profile = await client.profile({ + containerTag: USER_ID, + q: conversation.at(-1)!.content, +}) + +const context = `Static profile: +${profile.profile.static.join("\n")} + +Dynamic profile: +${profile.profile.dynamic.join("\n")} + +Relevant memories: +${profile.searchResults?.results.map((r) => r["content"]).join("\n")}` + +// Build messages with memory-enriched context +const messages = [ + { role: "system", content: `User context:\n${context}` }, + ...conversation, +] + +// const response = await llm.chat({ messages }); + +// Store conversation for future context +await client.add({ + content: conversation.map((m) => `${m.role}: ${m.content}`).join("\n"), + containerTag: USER_ID, +}) |