mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-06 02:47:54 +00:00
37 lines
868 B
TypeScript
37 lines
868 B
TypeScript
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?" },
|
|
]
|
|
|
|
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")}`
|
|
|
|
const _messages = [
|
|
{ role: "system", content: `User context:\n${context}` },
|
|
...conversation,
|
|
]
|
|
|
|
await client.add({
|
|
content: conversation.map((m) => `${m.role}: ${m.content}`).join("\n"),
|
|
containerTag: USER_ID,
|
|
})
|