Home / Function/ test_extras_with_defer_loading() — langchain Function Reference

test_extras_with_defer_loading() — langchain Function Reference

Architecture documentation for the test_extras_with_defer_loading() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fac1c717_ab43_a7f3_3013_9780b473b380["test_extras_with_defer_loading()"]
  18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"]
  fac1c717_ab43_a7f3_3013_9780b473b380 -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311
  style fac1c717_ab43_a7f3_3013_9780b473b380 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 2152–2178

def test_extras_with_defer_loading() -> None:
    """Test that extras with `defer_loading` are merged into tool definitions."""
    from langchain_core.tools import tool

    @tool(extras={"defer_loading": True})
    def get_weather(location: str) -> str:
        """Get weather for a location."""
        return f"Weather in {location}"

    model = ChatAnthropic(model=MODEL_NAME)  # type: ignore[call-arg]
    model_with_tools = model.bind_tools([get_weather])

    # Get the payload to check if defer_loading was merged
    payload = model_with_tools._get_request_payload(  # type: ignore[attr-defined]
        "test",
        **model_with_tools.kwargs,  # type: ignore[attr-defined]
    )

    # Find the get_weather tool in the payload
    weather_tool = None
    for tool_def in payload["tools"]:
        if isinstance(tool_def, dict) and tool_def.get("name") == "get_weather":
            weather_tool = tool_def
            break

    assert weather_tool is not None
    assert weather_tool.get("defer_loading") is True

Domain

Subdomains

Frequently Asked Questions

What does test_extras_with_defer_loading() do?
test_extras_with_defer_loading() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_extras_with_defer_loading() defined?
test_extras_with_defer_loading() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 2152.

Analyze Your Own Codebase

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

Try Supermodel Free