33 lines
637 B
Markdown
33 lines
637 B
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
# Long-term Memory con Semantic Search
|
|
|
|
<v-clicks>
|
|
|
|
### InMemoryStore con embeddings
|
|
|
|
```typescript
|
|
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 }
|
|
);
|
|
```
|
|
|
|
</v-clicks>
|
|
|