@memoid/sdk
v0.2.0
Published
JavaScript SDK for Memoid - AI Memory Layer
Maintainers
Readme
Memoid JavaScript SDK
JavaScript/TypeScript SDK for Memoid - AI Memory Layer for intelligent applications.
Installation
npm install memoid
# or
yarn add memoid
# or
pnpm add memoidQuick Start
import { MemoryClient } from "memoid";
const client = new MemoryClient("your-api-key");
// Add memory from conversation
const memories = await client.add(
[
{ role: "user", content: "I'm vegetarian and love Italian food" },
{ role: "assistant", content: "Great! I'll remember that." },
],
{ user_id: "user_123" }
);
// Search memories
const results = await client.search("What dietary restrictions?", {
user_id: "user_123",
});
results.forEach((result) => {
console.log(`${result.memory} (score: ${result.score})`);
});API Reference
MemoryClient
const client = new MemoryClient(apiKey, options?);Options:
baseUrl: API base URL (default:https://api.memoid.dev)timeout: Request timeout in ms (default:30000)
add(messages, options?)
Add memories from a conversation.
const memories = await client.add(
[{ role: "user", content: "My name is John" }],
{ user_id: "user_123" }
);get(memoryId)
Get a specific memory by ID.
getAll(options?)
Get all memories with optional filtering.
const memories = await client.getAll({
user_id: "user_123",
limit: 50,
});search(query, options?)
Search memories using natural language.
const results = await client.search("user preferences", {
user_id: "user_123",
limit: 10,
});update(memoryId, memory, metadata?)
Update a memory.
delete(memoryId)
Delete a memory.
deleteAll(options?)
Delete all memories with optional filtering.
getGraph(options?)
Get the knowledge graph.
const graph = await client.getGraph({ user_id: "user_123" });
console.log(graph.entities, graph.relations);TypeScript
Full TypeScript support with exported types:
import type { Memory, SearchResult, Graph } from "memoid";License
MIT
