test_memory.py — langchain Source File
Architecture documentation for test_memory.py, a python file in the langchain codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c1a133d6_0288_19b9_9ac4_17239e49295e["test_memory.py"] f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] c1a133d6_0288_19b9_9ac4_17239e49295e --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 8d1ab66e_47c1_1140_c3a5_5112af3b1cac["langchain_classic.base_memory"] c1a133d6_0288_19b9_9ac4_17239e49295e --> 8d1ab66e_47c1_1140_c3a5_5112af3b1cac 4db3ebff_aeb8_15bb_9f00_c7f2efff99df["langchain_classic.chains.conversation.memory"] c1a133d6_0288_19b9_9ac4_17239e49295e --> 4db3ebff_aeb8_15bb_9f00_c7f2efff99df 5b90a9d7_08ea_fab8_2528_673d880c66bf["langchain_classic.memory"] c1a133d6_0288_19b9_9ac4_17239e49295e --> 5b90a9d7_08ea_fab8_2528_673d880c66bf 55289260_666e_fae6_ddf7_d3d78be29813["tests.unit_tests.llms.fake_llm"] c1a133d6_0288_19b9_9ac4_17239e49295e --> 55289260_666e_fae6_ddf7_d3d78be29813 style c1a133d6_0288_19b9_9ac4_17239e49295e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import pytest
from langchain_classic.base_memory import BaseMemory
from langchain_classic.chains.conversation.memory import (
ConversationBufferMemory,
ConversationBufferWindowMemory,
ConversationSummaryMemory,
)
from langchain_classic.memory import ReadOnlySharedMemory, SimpleMemory
from tests.unit_tests.llms.fake_llm import FakeLLM
def test_simple_memory() -> None:
"""Test SimpleMemory."""
memory = SimpleMemory(memories={"baz": "foo"})
output = memory.load_memory_variables({})
assert output == {"baz": "foo"}
assert memory.memory_variables == ["baz"]
@pytest.mark.parametrize(
"memory",
[
ConversationBufferMemory(memory_key="baz"),
ConversationSummaryMemory(llm=FakeLLM(), memory_key="baz"),
ConversationBufferWindowMemory(memory_key="baz"),
],
)
def test_readonly_memory(memory: BaseMemory) -> None:
read_only_memory = ReadOnlySharedMemory(memory=memory)
memory.save_context({"input": "bar"}, {"output": "foo"})
assert read_only_memory.load_memory_variables({}) == memory.load_memory_variables(
{},
)
Domain
Subdomains
Dependencies
- langchain_classic.base_memory
- langchain_classic.chains.conversation.memory
- langchain_classic.memory
- pytest
- tests.unit_tests.llms.fake_llm
Source
Frequently Asked Questions
What does test_memory.py do?
test_memory.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in test_memory.py?
test_memory.py defines 2 function(s): test_readonly_memory, test_simple_memory.
What does test_memory.py depend on?
test_memory.py imports 5 module(s): langchain_classic.base_memory, langchain_classic.chains.conversation.memory, langchain_classic.memory, pytest, tests.unit_tests.llms.fake_llm.
Where is test_memory.py in the architecture?
test_memory.py is located at libs/langchain/tests/unit_tests/chains/test_memory.py (domain: LangChainCore, subdomain: Runnables, directory: libs/langchain/tests/unit_tests/chains).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free