Home / Function/ test_responses_stream_with_image_generation_multiple_calls() — langchain Function Reference

test_responses_stream_with_image_generation_multiple_calls() — langchain Function Reference

Architecture documentation for the test_responses_stream_with_image_generation_multiple_calls() function in test_responses_stream.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8d074ca7_821c_191d_8dc6_33e4a4042ba9["test_responses_stream_with_image_generation_multiple_calls()"]
  b7a76314_9619_4110_6766_cbbf07c950ca["test_responses_stream.py"]
  8d074ca7_821c_191d_8dc6_33e4a4042ba9 -->|defined in| b7a76314_9619_4110_6766_cbbf07c950ca
  style 8d074ca7_821c_191d_8dc6_33e4a4042ba9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_responses_stream.py lines 761–793

def test_responses_stream_with_image_generation_multiple_calls() -> None:
    """Test that streaming with image_generation tool works across multiple calls.

    Regression test: image_generation tool should not be mutated between calls,
    which would cause NotImplementedError on subsequent invocations.
    """
    tools: list[dict[str, Any]] = [
        {"type": "image_generation"},
        {"type": "function", "name": "my_tool", "parameters": {}},
    ]
    llm = ChatOpenAI(
        model="gpt-4o",
        use_responses_api=True,
        streaming=True,
    )
    llm_with_tools = llm.bind_tools(tools)

    mock_client = MagicMock()

    def mock_create(*args: Any, **kwargs: Any) -> MockSyncContextManager:
        return MockSyncContextManager(responses_stream)

    mock_client.responses.create = mock_create

    # First call should work
    with patch.object(llm, "root_client", mock_client):
        chunks = list(llm_with_tools.stream("test"))
        assert len(chunks) > 0

    # Second call should also work (would fail before fix due to tool mutation)
    with patch.object(llm, "root_client", mock_client):
        chunks = list(llm_with_tools.stream("test again"))
        assert len(chunks) > 0

Domain

Subdomains

Frequently Asked Questions

What does test_responses_stream_with_image_generation_multiple_calls() do?
test_responses_stream_with_image_generation_multiple_calls() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_responses_stream.py.
Where is test_responses_stream_with_image_generation_multiple_calls() defined?
test_responses_stream_with_image_generation_multiple_calls() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_responses_stream.py at line 761.

Analyze Your Own Codebase

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

Try Supermodel Free