Home / Function/ test_extras_with_input_examples() — langchain Function Reference

test_extras_with_input_examples() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 2208–2248

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

    @tool(
        extras={
            "input_examples": [
                {"location": "San Francisco, CA", "unit": "fahrenheit"},
                {"location": "Tokyo, Japan", "unit": "celsius"},
            ]
        }
    )
    def get_weather(location: str, unit: str = "fahrenheit") -> 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])

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

    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 "input_examples" in weather_tool
    assert len(weather_tool["input_examples"]) == 2
    assert weather_tool["input_examples"][0] == {
        "location": "San Francisco, CA",
        "unit": "fahrenheit",
    }

    # Beta header is required
    assert "betas" in payload
    assert "advanced-tool-use-2025-11-20" in payload["betas"]

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free