Connection
Base URL, credentials and a reachable server.
Infer a shared tensor shape by comparing trailing dimensions and expanding unit axes.
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 itertools import zip_longest
def broadcast_shape(a, b):
a, b = tuple(a), tuple(b)
if any(type(d) is not int or d < 0 for d in a + b):
raise ValueError("dimension.invalid")
result = []
for left, right in zip_longest(reversed(a), reversed(b), fillvalue=1):
if left == right or right == 1:
result.append(left)
elif left == 1:
result.append(right)
else:
raise ValueError("shape.incompatible")
return tuple(reversed(result))