{"record":{"id":"adbe2b019395a890","repo":"mem0ai/mem0","slug":"zeroentropy-package-is-required-for-zeroentropyrer","errorCode":null,"errorMessage":"zeroentropy package is required for ZeroEntropyReranker. Install with: pip install zeroentropy","messagePattern":"zeroentropy package is required for ZeroEntropyReranker\\. Install with: pip install zeroentropy","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/reranker/zero_entropy_reranker.py","lineNumber":27,"sourceCode":"    ZERO_ENTROPY_AVAILABLE = True\nexcept ImportError:\n    ZERO_ENTROPY_AVAILABLE = False\n\nlogger = logging.getLogger(__name__)\n\n\nclass ZeroEntropyReranker(BaseReranker):\n    \"\"\"Zero Entropy-based reranker implementation.\"\"\"\n    \n    def __init__(self, config):\n        \"\"\"\n        Initialize Zero Entropy reranker.\n        \n        Args:\n            config: ZeroEntropyRerankerConfig object with configuration parameters\n        \"\"\"\n        if not ZERO_ENTROPY_AVAILABLE:\n            raise ImportError(\"zeroentropy package is required for ZeroEntropyReranker. Install with: pip install zeroentropy\")\n        \n        self.config = config\n        self.api_key = config.api_key or os.getenv(\"ZERO_ENTROPY_API_KEY\")\n        if not self.api_key:\n            raise ValueError(\"Zero Entropy API key is required. Set ZERO_ENTROPY_API_KEY environment variable or pass api_key in config.\")\n            \n        self.model = config.model or \"zerank-1\"\n        \n        # Initialize Zero Entropy client\n        if self.api_key:\n            self.client = ZeroEntropy(api_key=self.api_key)\n        else:\n            self.client = ZeroEntropy()  # Will use ZERO_ENTROPY_API_KEY from environment\n        \n    def rerank(self, query: str, documents: List[Dict[str, Any]], top_k: int = None) -> List[Dict[str, Any]]:\n        \"\"\"\n        Rerank documents using Zero Entropy's rerank API.\n        ","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/reranker/zero_entropy_reranker.py#L9-L45","documentation":"ZeroEntropyReranker raises ImportError when the zeroentropy SDK is absent (guarded by ZERO_ENTROPY_AVAILABLE). ZeroEntropy is a commercial reranking service ('zerank-1'), and its client is an optional dependency not installed with core mem0. The failure occurs at construction, before any API key check or network call.","triggerScenarios":"Configuring reranker={'provider':'zeroentropy', ...} without `pip install zeroentropy`; copying a config from ZeroEntropy's docs into an env that lacks their SDK; adding the provider typo-free but forgetting the install step.","commonSituations":"Evaluating commercial rerankers for quality; deploying configs authored on another machine; CI environments built from minimal requirements files that never listed zeroentropy.","solutions":["pip install zeroentropy in the mem0 runtime environment","Add it to your requirements/pyproject alongside mem0 so installs stay reproducible","If unneeded, remove the reranker block or switch to a provider whose deps you already carry"],"exampleFix":"# before\nconfig = {\"reranker\": {\"provider\": \"zeroentropy\", \"config\": {\"model\": \"zerank-1\"}}}\n# ImportError\n\n# after\n# pip install zeroentropy\nconfig = {\"reranker\": {\"provider\": \"zeroentropy\", \"config\": {\"model\": \"zerank-1\", \"api_key\": os.environ[\"ZERO_ENTROPY_API_KEY\"]}}}","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"zeroentropy\") is None:\n    raise RuntimeError(\"install zeroentropy SDK before enabling the zeroentropy reranker\")","typeGuard":null,"tryCatchPattern":"try:\n    reranker = ZeroEntropyReranker(cfg)\nexcept ImportError:\n    reranker = None  # or fall back to another provider","preventionTips":["List every optional provider SDK your config references in requirements","Run a dependency manifest check in CI against your mem0 config","Remove reranker configs you do not use"],"tags":["reranker","zeroentropy","dependency","import-error"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}