637 B
637 B
layout
| layout |
|---|
| default |
Long-term Memory con Semantic Search
InMemoryStore con embeddings
import { InMemoryStore } from "@langchain/langgraph";
import { OpenAIEmbeddings } from "@langchain/openai";
const embeddings = new OpenAIEmbeddings({ model: "text-embedding-3-small" });
const store = new InMemoryStore({
index: { embeddings, dims: 1536 }
});
// Guardar memorias
await store.put(["user_123", "memories"], "1", { text: "I love pizza" });
// Buscar por similitud semántica
const items = await store.search(
["user_123", "memories"],
{ query: "I'm hungry", limit: 2 }
);