Connection
Base URL, credentials and a reachable server.
PhraseNacre supports inspection of LZ78 dictionary references and the final incomplete phrase, with byte fixtures kept alongside the proposed encoder.
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 lz78_tokens(data):
if type(data) is not bytes or len(data) > 4096:
raise ValueError("lz78.input")
dictionary, phrase, output = {b"": 0}, b"", []
for byte in data:
extended = phrase + bytes([byte])
if extended in dictionary:
phrase = extended
else:
output.append((dictionary[phrase], byte))
dictionary[extended] = len(dictionary)
phrase = b""
if phrase:
output.append((dictionary[phrase], None))
return output