0aff31e2d3
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
789 B
Markdown
40 lines
789 B
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
# Checkpointer: MemorySaver
|
|
|
|
<div class="mt-4 text-xs">
|
|
|
|
<v-click>
|
|
|
|
**MemorySaver**: Persistencia en memoria (desarrollo/testing)
|
|
|
|
```typescript
|
|
import { createAgent } from "langchain";
|
|
import { MemorySaver } from "@langchain/langgraph";
|
|
|
|
const agent = createAgent({
|
|
model: "mistral:mistral-large-latest",
|
|
tools: [weatherTool],
|
|
checkpointer: new MemorySaver(), // En memoria RAM
|
|
});
|
|
|
|
const config = { configurable: { thread_id: "conv-1" } };
|
|
|
|
// Primera conversación
|
|
await agent.invoke(
|
|
{ messages: [{ role: "user", content: "Hola, soy María" }] }, config
|
|
);
|
|
|
|
// Segunda conversación - recuerda el contexto
|
|
await agent.invoke(
|
|
{ messages: [{ role: "user", content: "¿Cómo me llamo?" }] }, config
|
|
);
|
|
// "Tu nombre es María"
|
|
```
|
|
|
|
</v-click>
|
|
|
|
</div>
|