Home / Function/ test_chat_prompt_template() — langchain Function Reference

test_chat_prompt_template() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6f2fa1c7_d791_3eb1_fbb7_4ef575c16a62["test_chat_prompt_template()"]
  00c8bbe0_a31c_1ac8_487a_bfd5a9d6b117["test_chat.py"]
  6f2fa1c7_d791_3eb1_fbb7_4ef575c16a62 -->|defined in| 00c8bbe0_a31c_1ac8_487a_bfd5a9d6b117
  style 6f2fa1c7_d791_3eb1_fbb7_4ef575c16a62 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_chat.py lines 192–222

async def test_chat_prompt_template(chat_prompt_template: ChatPromptTemplate) -> None:
    """Test chat prompt template."""
    prompt = chat_prompt_template.format_prompt(foo="foo", bar="bar", context="context")
    assert isinstance(prompt, ChatPromptValue)
    messages = prompt.to_messages()
    assert len(messages) == 4
    assert messages[0].content == "Here's some context: context"
    assert messages[1].content == "Hello foo, I'm bar. Thanks for the context"
    assert messages[2].content == "I'm an AI. I'm foo. I'm bar."
    assert messages[3].content == "I'm a generic message. I'm foo. I'm bar."

    async_prompt = await chat_prompt_template.aformat_prompt(
        foo="foo", bar="bar", context="context"
    )

    assert async_prompt.to_messages() == messages

    string = prompt.to_string()
    expected = (
        "System: Here's some context: context\n"
        "Human: Hello foo, I'm bar. Thanks for the context\n"
        "AI: I'm an AI. I'm foo. I'm bar.\n"
        "test: I'm a generic message. I'm foo. I'm bar."
    )
    assert string == expected

    string = chat_prompt_template.format(foo="foo", bar="bar", context="context")
    assert string == expected

    string = await chat_prompt_template.aformat(foo="foo", bar="bar", context="context")
    assert string == expected

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free