Home / Function/ test_chat_prompt_message_placeholder_dict() — langchain Function Reference

test_chat_prompt_message_placeholder_dict() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_chat.py lines 1109–1125

def test_chat_prompt_message_placeholder_dict() -> None:
    prompt = ChatPromptTemplate([{"role": "placeholder", "content": "{convo}"}])
    assert prompt.format_messages(convo=[("user", "foo")]) == [
        HumanMessage(content="foo")
    ]

    assert prompt.format_messages() == []

    # Is optional = True
    optional_prompt = ChatPromptTemplate(
        [{"role": "placeholder", "content": ["{convo}", False]}]
    )
    assert optional_prompt.format_messages(convo=[("user", "foo")]) == [
        HumanMessage(content="foo")
    ]
    with pytest.raises(KeyError):
        assert optional_prompt.format_messages() == []

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free