def test_parse_response_output():
    """Test parsing response output into ChatResponse."""
    # Create mock output items
    output = [
        ResponseOutputMessage(
            type="message",
            content=[{"type": "output_text", "text": "Hello world", "annotations": []}],
            role="assistant",
            id="123",
            status="completed",
        )
    ]

    with (
        patch("llama_index.llms.openai.responses.SyncOpenAI"),
        patch("llama_index.llms.openai.responses.AsyncOpenAI"),
    ):
        llm = OpenAIResponses(model="gpt-4o-mini")
        chat_response = llm._parse_response_output(output)

    assert chat_response.message.role == MessageRole.ASSISTANT
    assert len(chat_response.message.blocks) == 1
    assert isinstance(chat_response.message.blocks[0], TextBlock)
    assert chat_response.message.blocks[0].text == "Hello world"
Test parsing response output into ChatResponse.
llama-index-integrations/llms/llama-index-llms-openai/tests/test_openai_responses.py