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
True
Copy
from langchain_openai import ChatOpenAI
from langchain.chains import ConversationChain
from langchain.memory import ConversationEntityMemory
from langchain.memory.prompt import ENTITY_MEMORY_CONVERSATION_TEMPLATE
Entity 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.
You are an assistant to a human, powered by a large language model trained by OpenAI.
You are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like text based on the input you receive, allowing you to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
You are constantly learning and improving, and your capabilities are constantly evolving. You are able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. You have access to some personalized information provided by the human in the Context section below. Additionally, you are able to generate your own text based on the input you receive, allowing you to engage in discussions and provide explanations and descriptions on a wide range of topics.
Overall, you are a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether the human needs help with a specific question or just wants to have a conversation about a particular topic, you are here to assist.
Context:
{entities}
Current conversation:
{history}
Last line:
Human: {input}
You:
conversation.predict( input="Teddy and Shirley are colleagues working at the same company." "Teddy is a developer and Shirley is a designer." "They recently quit their jobs at the company and are planning to start their own company." )
'You told me that Teddy and Shirley are colleagues working in the same company, Teddy is a developer and Shirley is a designer. It's interesting to hear that they are planning to start a company. It will be a challenging but rewarding experience to start a new business by applying their ideas and capabilities. I hope Teddy and Shirley will achieve even greater success together. Do you already have an idea of what kind of company you will start and what services or products you will provide?'
{'Teddy': 'Teddy is a developer and is planning to start his own company with Shirley.', 'Shirley': 'Shirley works as a designer at a company and is planning to start his own company with Teddy.'}