load_memory_variables() — langchain Function Reference
Architecture documentation for the load_memory_variables() function in vectorstore_token_buffer_memory.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9aadbae5_f7ca_b833_7138_d5eb70fbfb2d["load_memory_variables()"] 5131526a_5463_d58d_257b_58b635bce851["ConversationVectorStoreTokenBufferMemory"] 9aadbae5_f7ca_b833_7138_d5eb70fbfb2d -->|defined in| 5131526a_5463_d58d_257b_58b635bce851 style 9aadbae5_f7ca_b833_7138_d5eb70fbfb2d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/memory/vectorstore_token_buffer_memory.py lines 123–143
def load_memory_variables(self, inputs: dict[str, Any]) -> dict[str, Any]:
"""Return history and memory buffer."""
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
memory_variables = self.memory_retriever.load_memory_variables(inputs)
previous_history = memory_variables[self.memory_retriever.memory_key]
except AssertionError: # happens when db is empty
previous_history = ""
current_history = super().load_memory_variables(inputs)
template = SystemMessagePromptTemplate.from_template(
self.previous_history_template,
)
messages = [
template.format(
previous_history=previous_history,
current_time=datetime.now().astimezone().strftime(TIMESTAMP_FORMAT),
),
]
messages.extend(current_history[self.memory_key])
return {self.memory_key: messages}
Domain
Subdomains
Source
Frequently Asked Questions
What does load_memory_variables() do?
load_memory_variables() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/memory/vectorstore_token_buffer_memory.py.
Where is load_memory_variables() defined?
load_memory_variables() is defined in libs/langchain/langchain_classic/memory/vectorstore_token_buffer_memory.py at line 123.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free