Home / Function/ test_anthropic_async_streaming_callback() — langchain Function Reference

test_anthropic_async_streaming_callback() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 381–396

async def test_anthropic_async_streaming_callback() -> None:
    """Test that streaming correctly invokes on_llm_new_token callback."""
    callback_handler = FakeCallbackHandler()
    callback_manager = CallbackManager([callback_handler])
    chat = ChatAnthropic(
        model=MODEL_NAME,  # type: ignore[call-arg]
        callbacks=callback_manager,
        verbose=True,
    )
    chat_messages: list[BaseMessage] = [
        HumanMessage(content="How many toes do dogs have?"),
    ]
    async for token in chat.astream(chat_messages):
        assert isinstance(token, AIMessageChunk)
        assert isinstance(token.content, str)
    assert callback_handler.llm_streams > 1

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free