Connection
Base URL, credentials and a reachable server.
Inspect size-line parsing separately from payload copying, with the accepted subset visible beside the proposed decoder changes.
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 chunk_body(wire):
if type(wire) is not bytes or len(wire) > 65536:
raise ValueError("bounded bytes")
pos, body = 0, bytearray()
while True:
end = wire.find(b"\r\n", pos)
token = wire[pos:end] if end >= 0 else b""
if not 1 <= len(token) <= 8 or any(
c not in b"0123456789abcdefABCDEF" for c in token):
raise ValueError("plain hexadecimal size")
size, pos = int(token, 16), end + 2
if size == 0:
if wire[pos:] != b"\r\n":
raise ValueError("no trailers or extra bytes")
return bytes(body)
if len(body) + size > 4096:
raise ValueError("body limit")
if pos + size + 2 > len(wire):
raise ValueError("truncated chunk")
if wire[pos + size:pos + size + 2] != b"\r\n":
raise ValueError("chunk delimiter")
body.extend(wire[pos:pos + size])
pos += size + 2