Home / Function/ test_chat_prompt_template_from_messages_using_message_classes() — langchain Function Reference

test_chat_prompt_template_from_messages_using_message_classes() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_chat.py lines 317–338

def test_chat_prompt_template_from_messages_using_message_classes() -> None:
    """Test creating a chat prompt template using message class tuples."""
    template = ChatPromptTemplate.from_messages(
        [
            (SystemMessage, "You are a helpful AI bot. Your name is {name}."),
            (HumanMessage, "Hello, how are you doing?"),
            (AIMessage, "I'm doing well, thanks!"),
            (HumanMessage, "{user_input}"),
        ]
    )

    expected = [
        SystemMessage(
            content="You are a helpful AI bot. Your name is Bob.", additional_kwargs={}
        ),
        HumanMessage(content="Hello, how are you doing?", additional_kwargs={}),
        AIMessage(content="I'm doing well, thanks!", additional_kwargs={}),
        HumanMessage(content="What is your name?", additional_kwargs={}),
    ]

    messages = template.format_messages(name="Bob", user_input="What is your name?")
    assert messages == expected

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free