Home / Function/ test_input_messages() — langchain Function Reference

test_input_messages() — langchain Function Reference

Architecture documentation for the test_input_messages() function in test_history.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f00b6048_fbb2_8ea1_99d8_efd8fedde6a8["test_input_messages()"]
  0af0dfde_fe33_f3e5_b5e6_a3d18260dc67["test_history.py"]
  f00b6048_fbb2_8ea1_99d8_efd8fedde6a8 -->|defined in| 0af0dfde_fe33_f3e5_b5e6_a3d18260dc67
  e035a3b1_d1a1_c458_c801_af1fc0272f8b["_get_get_session_history()"]
  f00b6048_fbb2_8ea1_99d8_efd8fedde6a8 -->|calls| e035a3b1_d1a1_c458_c801_af1fc0272f8b
  style f00b6048_fbb2_8ea1_99d8_efd8fedde6a8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_history.py lines 54–82

def test_input_messages() -> None:
    runnable = RunnableLambda[Any, str](
        lambda messages: (
            "you said: "
            + "\n".join(str(m.content) for m in messages if isinstance(m, HumanMessage))
        )
    )
    store: dict[str, InMemoryChatMessageHistory] = {}
    get_session_history = _get_get_session_history(store=store)
    with_history = RunnableWithMessageHistory(runnable, get_session_history)
    config: RunnableConfig = {"configurable": {"session_id": "1"}}
    output = with_history.invoke([HumanMessage(content="hello")], config)
    assert output == "you said: hello"
    output = with_history.invoke([HumanMessage(content="good bye")], config)
    assert output == "you said: hello\ngood bye"
    output = [*with_history.stream([HumanMessage(content="hi again")], config)]
    assert output == ["you said: hello\ngood bye\nhi again"]
    assert store == {
        "1": InMemoryChatMessageHistory(
            messages=[
                HumanMessage(content="hello"),
                AIMessage(content="you said: hello"),
                HumanMessage(content="good bye"),
                AIMessage(content="you said: hello\ngood bye"),
                HumanMessage(content="hi again"),
                AIMessage(content="you said: hello\ngood bye\nhi again"),
            ]
        )
    }

Domain

Subdomains

Frequently Asked Questions

What does test_input_messages() do?
test_input_messages() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_history.py.
Where is test_input_messages() defined?
test_input_messages() is defined in libs/core/tests/unit_tests/runnables/test_history.py at line 54.
What does test_input_messages() call?
test_input_messages() calls 1 function(s): _get_get_session_history.

Analyze Your Own Codebase

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

Try Supermodel Free