Connection
Base URL, credentials and a reachable server.
Test negative scroll, overscroll and a zero-height viewport, clipping indices to the item count and rejecting an invalid row height.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
from math import isfinite, ceil
def row_window(count, row_height, offset, viewport, overscan=1):
if type(count) is not int or count < 0 or type(overscan) is not int or overscan < 0:
raise ValueError("rows.count")
if not all(type(x) in (int, float) and isfinite(x) for x in (row_height, offset, viewport)) or row_height <= 0 or viewport < 0:
raise ValueError("rows.geometry")
start_units = max(0, offset) / row_height
first = count if start_units >= count else int(start_units)
if first == count or viewport == 0:
return first, first
span = viewport / row_height
end = count if span >= count - start_units else min(count, ceil(start_units + span) + overscan)
return max(0, first - overscan), end