Home / Function/ test_anthropic_with_empty_text_block() — langchain Function Reference

test_anthropic_with_empty_text_block() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  54e3c810_fcf7_d6c0_bb9a_715d2927b36e["test_anthropic_with_empty_text_block()"]
  f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"]
  54e3c810_fcf7_d6c0_bb9a_715d2927b36e -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f
  style 54e3c810_fcf7_d6c0_bb9a_715d2927b36e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 645–687

def test_anthropic_with_empty_text_block() -> None:
    """Anthropic SDK can return an empty text block."""

    @tool
    def type_letter(letter: str) -> str:
        """Type the given letter."""
        return "OK"

    model = ChatAnthropic(model=MODEL_NAME, temperature=0).bind_tools(  # type: ignore[call-arg]
        [type_letter],
    )

    messages = [
        SystemMessage(
            content="Repeat the given string using the provided tools. Do not write "
            "anything else or provide any explanations. For example, "
            "if the string is 'abc', you must print the "
            "letters 'a', 'b', and 'c' one at a time and in that order. ",
        ),
        HumanMessage(content="dog"),
        AIMessage(
            content=[
                {"text": "", "type": "text"},
                {
                    "id": "toolu_01V6d6W32QGGSmQm4BT98EKk",
                    "input": {"letter": "d"},
                    "name": "type_letter",
                    "type": "tool_use",
                },
            ],
            tool_calls=[
                {
                    "name": "type_letter",
                    "args": {"letter": "d"},
                    "id": "toolu_01V6d6W32QGGSmQm4BT98EKk",
                    "type": "tool_call",
                },
            ],
        ),
        ToolMessage(content="OK", tool_call_id="toolu_01V6d6W32QGGSmQm4BT98EKk"),
    ]

    model.invoke(messages)

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free