Home / File/ test_dict.py — langchain Source File

test_dict.py — langchain Source File

Architecture documentation for test_dict.py, a python file in the langchain codebase. 2 imports, 0 dependents.

File python CoreAbstractions MessageSchema 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  0fed4acb_9f2e_b15c_0e09_781e9442823f["test_dict.py"]
  36cce5da_d805_04c3_7e86_e1b4dd49b497["langchain_core.load"]
  0fed4acb_9f2e_b15c_0e09_781e9442823f --> 36cce5da_d805_04c3_7e86_e1b4dd49b497
  de8c88fa_966e_67e6_53fe_64406853c45a["langchain_core.prompts.dict"]
  0fed4acb_9f2e_b15c_0e09_781e9442823f --> de8c88fa_966e_67e6_53fe_64406853c45a
  style 0fed4acb_9f2e_b15c_0e09_781e9442823f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from langchain_core.load import load
from langchain_core.prompts.dict import DictPromptTemplate


def test__dict_message_prompt_template_fstring() -> None:
    template = {
        "type": "text",
        "text": "{text1}",
        "cache_control": {"type": "{cache_type}"},
    }
    prompt = DictPromptTemplate(template=template, template_format="f-string")
    expected = {
        "type": "text",
        "text": "important message",
        "cache_control": {"type": "ephemeral"},
    }
    actual = prompt.format(text1="important message", cache_type="ephemeral")
    assert actual == expected


def test_deserialize_legacy() -> None:
    ser = {
        "type": "constructor",
        "lc": 1,
        "id": ["langchain_core", "prompts", "message", "_DictMessagePromptTemplate"],
        "kwargs": {
            "template_format": "f-string",
            "template": {"type": "audio", "audio": "{audio_data}"},
        },
    }
    expected = DictPromptTemplate(
        template={"type": "audio", "audio": "{audio_data}"}, template_format="f-string"
    )
    assert load(ser, allowed_objects=[DictPromptTemplate]) == expected

Subdomains

Dependencies

  • langchain_core.load
  • langchain_core.prompts.dict

Frequently Asked Questions

What does test_dict.py do?
test_dict.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_dict.py?
test_dict.py defines 2 function(s): test__dict_message_prompt_template_fstring, test_deserialize_legacy.
What does test_dict.py depend on?
test_dict.py imports 2 module(s): langchain_core.load, langchain_core.prompts.dict.
Where is test_dict.py in the architecture?
test_dict.py is located at libs/core/tests/unit_tests/prompts/test_dict.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/tests/unit_tests/prompts).

Analyze Your Own Codebase

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

Try Supermodel Free