Connection
Base URL, credentials and a reachable server.
Trace selection boundaries from source characters to UTF-16 units before passing offsets to an editor API.
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 utf16_offsets(text):
if type(text) is not str or len(text) > 4096:
raise ValueError("bounded text")
offsets = [0]
for char in text:
value = ord(char)
if 0xD800 <= value <= 0xDFFF:
raise ValueError("unpaired surrogate")
offsets.append(offsets[-1] + (2 if value > 0xFFFF else 1))
return offsets