Home / Function/ test_anthropic_inputs() — langchain Function Reference

test_anthropic_inputs() — langchain Function Reference

Architecture documentation for the test_anthropic_inputs() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fb65367d_63b7_01ba_5219_e2c2dd0fdc93["test_anthropic_inputs()"]
  971e928f_9c9b_ce7a_b93d_e762f2f5aa54["ChatModelIntegrationTests"]
  fb65367d_63b7_01ba_5219_e2c2dd0fdc93 -->|defined in| 971e928f_9c9b_ce7a_b93d_e762f2f5aa54
  style fb65367d_63b7_01ba_5219_e2c2dd0fdc93 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 3027–3206

    def test_anthropic_inputs(self, model: BaseChatModel) -> None:
        """Test that model can process Anthropic-style message histories.

        These message histories will include `AIMessage` objects with `tool_use`
        content blocks, e.g.,

        ```python
        AIMessage(
            [
                {"type": "text", "text": "Hmm let me think about that"},
                {
                    "type": "tool_use",
                    "input": {"fav_color": "green"},
                    "id": "foo",
                    "name": "color_picker",
                },
            ]
        )
        ```

        ...as well as `HumanMessage` objects containing `tool_result` content blocks:

        ```python
        HumanMessage(
            [
                {
                    "type": "tool_result",
                    "tool_use_id": "foo",
                    "content": [
                        {
                            "type": "text",
                            "text": "green is a great pick! "
                            "that's my sister's favorite color",
                        }
                    ],
                    "is_error": False,
                },
                {"type": "text", "text": "what's my sister's favorite color"},
            ]
        )
        ```

        This test should be skipped if the model does not support messages of this
        form (or doesn't support tool calling generally). See Configuration below.

        ??? note "Configuration"

            To disable this test, set `supports_anthropic_inputs` to `False` in your
            test class:

            ```python
            class TestMyChatModelIntegration(ChatModelIntegrationTests):
                @property
                def supports_anthropic_inputs(self) -> bool:
                    return False
            ```

        ??? question "Troubleshooting"

            If this test fails, check that:

            1. The model can correctly handle message histories that include message
                objects with list content.
            2. The `tool_calls` attribute on AIMessage objects is correctly handled
                and passed to the model in an appropriate format.
            3. `HumanMessage`s with "tool_result" content blocks are correctly
                handled.

            Otherwise, if Anthropic tool call and result formats are not supported,
            set the `supports_anthropic_inputs` property to `False`.

        """
        if not self.supports_anthropic_inputs:
            pytest.skip("Model does not explicitly support Anthropic inputs.")

        # Anthropic-format tool
        color_picker = {
            "name": "color_picker",
            "input_schema": {
                "type": "object",
                "properties": {

Domain

Subdomains

Frequently Asked Questions

What does test_anthropic_inputs() do?
test_anthropic_inputs() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py.
Where is test_anthropic_inputs() defined?
test_anthropic_inputs() is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 3027.

Analyze Your Own Codebase

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

Try Supermodel Free