Home / Function/ test_conversation_memory() — langchain Function Reference

test_conversation_memory() — langchain Function Reference

Architecture documentation for the test_conversation_memory() function in test_conversation.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a99517e5_8c1d_a769_f3e4_9ae2a995c426["test_conversation_memory()"]
  bad7138b_753c_8c4e_915e_8bf58ada3cec["test_conversation.py"]
  a99517e5_8c1d_a769_f3e4_9ae2a995c426 -->|defined in| bad7138b_753c_8c4e_915e_8bf58ada3cec
  style a99517e5_8c1d_a769_f3e4_9ae2a995c426 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/chains/test_conversation.py lines 110–131

def test_conversation_memory(memory: BaseMemory) -> None:
    """Test basic conversation memory functionality."""
    # This is a good input because the input is not the same as baz.
    good_inputs = {"foo": "bar", "baz": "foo"}
    # This is a good output because these is one variable.
    good_outputs = {"bar": "foo"}
    memory.save_context(good_inputs, good_outputs)
    # This is a bad input because there are two variables that aren't the same as baz.
    bad_inputs = {"foo": "bar", "foo1": "bar"}
    with pytest.raises(ValueError, match="One input key expected"):
        memory.save_context(bad_inputs, good_outputs)
    # This is a bad input because the only variable is the same as baz.
    bad_inputs = {"baz": "bar"}
    with pytest.raises(ValueError, match=re.escape("One input key expected got []")):
        memory.save_context(bad_inputs, good_outputs)
    # This is a bad output because it is empty.
    with pytest.raises(ValueError, match="Got multiple output keys"):
        memory.save_context(good_inputs, {})
    # This is a bad output because there are two keys.
    bad_outputs = {"foo": "bar", "foo1": "bar"}
    with pytest.raises(ValueError, match="Got multiple output keys"):
        memory.save_context(good_inputs, bad_outputs)

Domain

Subdomains

Frequently Asked Questions

What does test_conversation_memory() do?
test_conversation_memory() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/chains/test_conversation.py.
Where is test_conversation_memory() defined?
test_conversation_memory() is defined in libs/langchain/tests/unit_tests/chains/test_conversation.py at line 110.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free