Home / Function/ test_chat_tmpl_serdes() — langchain Function Reference

test_chat_tmpl_serdes() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_chat.py lines 1209–1259

def test_chat_tmpl_serdes(snapshot: SnapshotAssertion) -> None:
    """Test chat prompt template ser/des."""
    template = ChatPromptTemplate(
        [
            ("system", "You are an AI assistant named {name}."),
            ("system", [{"text": "You are an AI assistant named {name}."}]),
            SystemMessagePromptTemplate.from_template("you are {foo}"),
            (
                "human",
                [
                    "hello",
                    {"text": "What's in this image?"},
                    {"type": "text", "text": "What's in this image?"},
                    {
                        "type": "text",
                        "text": "What's in this image?",
                        "cache_control": {"type": "{foo}"},
                    },
                    {
                        "type": "image_url",
                        "image_url": "data:image/jpeg;base64,{my_image}",
                    },
                    {
                        "type": "image_url",
                        "image_url": {"url": "data:image/jpeg;base64,{my_image}"},
                    },
                    {"type": "image_url", "image_url": "{my_other_image}"},
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "{my_other_image}",
                            "detail": "medium",
                        },
                    },
                    {
                        "type": "image_url",
                        "image_url": {"url": "https://www.langchain.com/image.png"},
                    },
                    {
                        "type": "image_url",
                        "image_url": {"url": "data:image/jpeg;base64,foobar"},
                    },
                    {"image_url": {"url": "data:image/jpeg;base64,foobar"}},
                ],
            ),
            ("placeholder", "{chat_history}"),
            MessagesPlaceholder("more_history", optional=False),
        ]
    )
    assert dumpd(template) == snapshot()
    assert load(dumpd(template)) == template

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free