Connection
Base URL, credentials and a reachable server.
Compare inserted keys with the bitmap while reviewing collisions, keeping a positive membership result separate from certainty.
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 hashlib import sha256
class Bloom:
def __init__(self, width):
if type(width) is not int or not 1 <= width <= 8192:
raise ValueError("width.range")
self.width, self.bits = width, 0
def positions(self, key):
if not isinstance(key, bytes) or len(key) > 1024:
raise ValueError("key.bytes")
digest = sha256(key).digest()
return [int.from_bytes(digest[i:i+4], "big") % self.width
for i in (0, 4, 8, 12)]
def add(self, key):
for position in self.positions(key):
self.bits |= 1 << position
def maybe_contains(self, key):
return all(self.bits & (1 << p) for p in self.positions(key))