Home / Function/ test_chat_message_partial() — langchain Function Reference

test_chat_message_partial() — langchain Function Reference

Architecture documentation for the test_chat_message_partial() function in test_chat.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  acc48637_660a_d7e1_12fc_efee74d10f58["test_chat_message_partial()"]
  bf3138ca_0068_68ea_f479_35376e264d13["test_chat.py"]
  acc48637_660a_d7e1_12fc_efee74d10f58 -->|defined in| bf3138ca_0068_68ea_f479_35376e264d13
  style acc48637_660a_d7e1_12fc_efee74d10f58 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_chat.py lines 814–835

def test_chat_message_partial() -> None:
    template = ChatPromptTemplate(
        [
            ("system", "You are an AI assistant named {name}."),
            ("human", "Hi I'm {user}"),
            ("ai", "Hi there, {user}, I'm {name}."),
            ("human", "{input}"),
        ]
    )
    template2 = template.partial(user="Lucy", name="R2D2")
    with pytest.raises(KeyError):
        template.format_messages(input="hello")

    res = template2.format_messages(input="hello")
    expected = [
        SystemMessage(content="You are an AI assistant named R2D2."),
        HumanMessage(content="Hi I'm Lucy"),
        AIMessage(content="Hi there, Lucy, I'm R2D2."),
        HumanMessage(content="hello"),
    ]
    assert res == expected
    assert template2.format(input="hello") == get_buffer_string(expected)

Subdomains

Frequently Asked Questions

What does test_chat_message_partial() do?
test_chat_message_partial() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_chat.py.
Where is test_chat_message_partial() defined?
test_chat_message_partial() is defined in libs/core/tests/unit_tests/prompts/test_chat.py at line 814.

Analyze Your Own Codebase

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

Try Supermodel Free