Connection
Base URL, credentials and a reachable server.
Visit every coordinate of a rectangular grid in a clockwise spiral starting at the top left.
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.
def spiral(rows, columns):
if any(type(v) is not int or not 0 <= v <= 100
for v in (rows, columns)):
raise ValueError("dimension.range")
top, bottom, left, right = 0, rows - 1, 0, columns - 1
result = []
while top <= bottom and left <= right:
result.extend((top, c) for c in range(left, right + 1))
top += 1
result.extend((r, right) for r in range(top, bottom + 1))
right -= 1
if top <= bottom:
result.extend((bottom, c) for c in range(right, left - 1, -1))
bottom -= 1
if left <= right:
result.extend((r, left) for r in range(bottom, top - 1, -1))
left += 1
return result