def test_process_response_event():
    """Test the static process_response_event method for streaming responses."""
    # Initial state
    tool_calls = []
    built_in_tool_calls = []
    additional_kwargs = {}
    current_tool_call = None

    # Test text delta event
    event = ResponseTextDeltaEvent(
        content_index=0,
        item_id="123",
        output_index=0,
        delta="Hello",
        type="response.output_text.delta",
        sequence_number=1,
    )

    result = OpenAIResponses.process_response_event(
        event=event,
        tool_calls=tool_calls,
        built_in_tool_calls=built_in_tool_calls,
        additional_kwargs=additional_kwargs,
        current_tool_call=current_tool_call,
        track_previous_responses=False,
    )

    updated_blocks, updated_tool_calls, _, _, _, _, delta = result
    assert updated_blocks == [TextBlock(text="Hello")]
    assert delta == "Hello"
    assert updated_tool_calls == []

    # Test function call arguments delta
    current_tool_call = ResponseFunctionToolCall(
        id="call_123",
        call_id="123",
        type="function_call",
        name="test_function",
        arguments="",
        status="in_progress",
    )

    event = ResponseFunctionCallArgumentsDeltaEvent(
        content_index=0,
        item_id="123",
        output_index=0,
        type="response.function_call_arguments.delta",
        delta='{"arg": "value"',
        sequence_number=1,
    )

    result = OpenAIResponses.process_response_event(
        event=event,
        tool_calls=updated_tool_calls,
        built_in_tool_calls=built_in_tool_calls,
        additional_kwargs=additional_kwargs,
        current_tool_call=current_tool_call,
        track_previous_responses=False,
    )

    _, _, _, _, updated_call, _, _ = result
    assert updated_call.arguments == '{"arg": "value"'

    # Test function call arguments done
    event = ResponseFunctionCallArgumentsDoneEvent(
        item_id="123",
        output_index=0,
        type="response.function_call_arguments.done",
        arguments='{"arg": "value"}',
        sequence_number=1,
    )

    result = OpenAIResponses.process_response_event(
        event=event,
        tool_calls=updated_tool_calls,
        built_in_tool_calls=built_in_tool_calls,
        additional_kwargs=additional_kwargs,
        current_tool_call=updated_call,
        track_previous_responses=False,
    )

    _, completed_tool_calls, _, _, final_current_call, _, _ = result
    assert len(completed_tool_calls) == 1
    assert completed_tool_calls[0].arguments == '{"arg": "value"}'
    assert completed_tool_calls[0].status == "completed"
    assert final_current_call is None
Test the static process_response_event method for streaming responses.
llama-index-integrations/llms/llama-index-llms-openai/tests/test_openai_responses.py