Home / Function/ test_structured_prompt_dict() — langchain Function Reference

test_structured_prompt_dict() — langchain Function Reference

Architecture documentation for the test_structured_prompt_dict() function in test_structured.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a17b4b36_af70_67cc_b02a_3abad58571df["test_structured_prompt_dict()"]
  3513030b_4904_ecfd_7a0d_cc92be4dda69["test_structured.py"]
  a17b4b36_af70_67cc_b02a_3abad58571df -->|defined in| 3513030b_4904_ecfd_7a0d_cc92be4dda69
  style a17b4b36_af70_67cc_b02a_3abad58571df fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_structured.py lines 60–84

def test_structured_prompt_dict() -> None:
    prompt = StructuredPrompt(
        [
            ("human", "I'm very structured, how about you?"),
        ],
        {
            "name": "yo",
            "description": "a structured output",
            "parameters": {
                "name": {"type": "string"},
                "value": {"type": "integer"},
            },
        },
    )

    model = FakeStructuredChatModel(responses=[])

    chain = prompt | model

    assert chain.invoke({"hello": "there"}) == {"name": 1, "value": 42}  # type: ignore[comparison-overlap]

    assert loads(dumps(prompt)).model_dump() == prompt.model_dump()

    chain = loads(dumps(prompt)) | model
    assert chain.invoke({"hello": "there"}) == {"name": 1, "value": 42}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free