LANGCHAIN_MEMORY - Gerenciamento de Memória Conversacional
O que é este Node?
O LANGCHAIN_MEMORY é o node responsável por armazenar e gerenciar contexto de conversas permitindo que chatbots lembrem de interações anteriores.
Por que este Node existe?
Chatbots precisam manter contexto de conversas para fornecer respostas coerentes. O LANGCHAIN_MEMORY existe para:
- Contexto Contínuo: Manter histórico de conversas
- Personalização: Lembrar preferências do usuário
- Conversas Naturais: Permitir referências a mensagens anteriores
- Sessões: Isolar contexto por usuário/conversa
Como funciona internamente?
async executeLangChainMemory(data: any, variables: Record<string, any>): Promise<any> {
try {
this.logger.log('🧠 [LangChain Memory] Managing memory');
return {
success: true,
operation: data.operation,
message: 'Memory operation completed successfully',
};
} catch (error) {
this.logger.error('LangChain Memory execution error:', error);
throw error;
}
}
Parâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| operation | string | Sim | Operação (save/load/clear) |
| sessionId | string | Sim | ID da sessão |
| message | string | Não | Mensagem a armazenar |
Resposta do Node
{
"success": true,
"operation": "save",
"message": "Memory operation completed successfully"
}
Boas Práticas
✅ SIM: Limitar histórico a últimas N mensagens, Separar por sessão/usuário ❌ NÃO: Armazenar histórico infinito, Misturar contextos de diferentes usuários
Próximos Nodes
→ LANGCHAIN_CHAT - Usar memória em conversas → LANGCHAIN_AGENT - Agentes com memória