04. ConversationEntityMemory
ConversationEntityMemory
Entity memory remembers given facts about a particular entity in a conversation. Entity memory extracts information about an entity (using LLM) and accumulates knowledge about that entity over time (also using LLM).
Copy
# API KEY A configuration file for managing environment variables
from dotenv import load_dotenv
# API KEY Load information
load_dotenv()Copy
TrueCopy
from langchain_openai import ChatOpenAI
from langchain.chains import ConversationChain
from langchain.memory import ConversationEntityMemory
from langchain.memory.prompt import ENTITY_MEMORY_CONVERSATION_TEMPLATEEntity To use memory efficiently, use the prompts provided.
Copy
# Entity Memory Prints the prompt contents using.
print(ENTITY_MEMORY_CONVERSATION_TEMPLATE.template)Copy
Copy
Start a conversation.
Based on the conversation you entered, ConversationEntityMemory stores key Entity information separately.
Copy
Copy
Entity는 memory.entity_store.store You can check it at.
Copy
Copy
Last updated