Home / Function/ test_extras_with_multiple_fields() — langchain Function Reference

test_extras_with_multiple_fields() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 2251–2283

def test_extras_with_multiple_fields() -> None:
    """Test that multiple extra fields can be specified together."""
    from langchain_core.tools import tool

    @tool(
        extras={
            "defer_loading": True,
            "cache_control": {"type": "ephemeral"},
            "input_examples": [{"query": "python files"}],
        }
    )
    def search_code(query: str) -> str:
        """Search code."""
        return f"Code for {query}"

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

    payload = model_with_tools._get_request_payload(  # type: ignore[attr-defined]
        "test",
        **model_with_tools.kwargs,  # type: ignore[attr-defined]
    )

    tool_def = None
    for t in payload["tools"]:
        if isinstance(t, dict) and t.get("name") == "search_code":
            tool_def = t
            break

    assert tool_def is not None
    assert tool_def.get("defer_loading") is True
    assert tool_def.get("cache_control") == {"type": "ephemeral"}
    assert "input_examples" in tool_def

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free