05. (ConversationKGMemory)
ConversationKGMemory
Leverage the power of knowledge graphs to store and retrieve information.
This helps the model understand relationships between different entities, and improves its ability to respond based on complex networks and historical context.
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.memory import ConversationKGMemoryCopy
llm = ChatOpenAI(temperature=0)
memory = ConversationKGMemory(llm=llm, return_messages=True)
memory.save_context(
{"input": "This is Pangyo My name is Shirley Kim, and I live in."},
{"output": "Who is Kim Shirley?"},
)
memory.save_context(
{"input": "Kim Shirley is our company's new designer."},
{"output": "nice to meet you."},
)Copy
Copy
Utilizing memory in Chain
Copy
Let's start the first conversation. Let's give some basic information about the character.
Copy
Copy
We're going to ask questions about a person named Shirley.
Copy
Copy
Last updated