Home / Function/ test_chat_prompt_template_variable_names() — langchain Function Reference

test_chat_prompt_template_variable_names() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_chat.py lines 1345–1387

def test_chat_prompt_template_variable_names() -> None:
    """This test was written for an edge case that triggers a warning from Pydantic.

    Verify that no run time warnings are raised.
    """
    with warnings.catch_warnings(record=True) as record:
        warnings.simplefilter("always")  # Cause all warnings to always be triggered
        prompt = ChatPromptTemplate([("system", "{schema}")])
        prompt.get_input_schema()

    if record:
        error_msg = [
            f"Warning type: {warning.category.__name__}, "
            f"Warning message: {warning.message}, "
            f"Warning location: {warning.filename}:{warning.lineno}"
            for warning in record
        ]
        msg = "\n".join(error_msg)
    else:
        msg = ""

    assert list(record) == [], msg

    # Verify value errors raised from illegal names
    assert ChatPromptTemplate(
        [("system", "{_private}")]
    ).get_input_schema().model_json_schema() == {
        "properties": {"_private": {"title": "Private", "type": "string"}},
        "required": ["_private"],
        "title": "PromptInput",
        "type": "object",
    }

    assert ChatPromptTemplate(
        [("system", "{model_json_schema}")]
    ).get_input_schema().model_json_schema() == {
        "properties": {
            "model_json_schema": {"title": "Model Json Schema", "type": "string"}
        },
        "required": ["model_json_schema"],
        "title": "PromptInput",
        "type": "object",
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free