BaseCompressor (compressors.py)

claw-compactor · ai

compressors.py — Four compression strategies for the Engram Benchmark. Strategies: 1. EngramCompressor — LLM Observer + Reflector (Layer 6 Engram) 2. RuleCompressor — claw-compactor Layers 1-5 (deterministic, no LLM) 3. RandomDropCompressor — Random token drop (LLMLingua-2 baseli

# Source: https://github.com/open-compress/claw-compactor | License: MIT | Copyright 2026 OpenClaw Contributors
# Provided via justclaw.it.com; keep this notice with the code.
"""compressors.py — Four compression strategies for the Engram Benchmark.

Strategies:
1. EngramCompressor   — LLM Observer + Reflector (Layer 6 Engram)
2. RuleCompressor     — claw-compactor Layers 1-5 (deterministic, no LLM)
3. RandomDropCompressor — Random token drop (LLMLingua-2 baseline proxy)
4. NoCompressor       — Raw text, no compression (baseline)

Python 3.9+ / no external deps beyond stdlib.
EngramCompressor uses the proxy at http://localhost:8403.
"""

from __future__ import annotations

import json
import logging
import os
import random
import re
import sys
import time
import urllib.error
import urllib.

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key