{"record":{"id":"1415e00fbec80420","repo":"RyanCodrai/turbovec","slug":"haystack-ai-is-required-to-use-turbovec-haystack","errorCode":null,"errorMessage":"haystack-ai is required to use turbovec.haystack. Install with: pip install turbovec[haystack]","messagePattern":"haystack-ai is required to use turbovec\\.haystack\\. Install with: pip install turbovec\\[haystack\\]","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/haystack.py","lineNumber":42,"sourceCode":"from numbers import Real\nfrom pathlib import Path\nfrom typing import Any, Dict, Iterable, List, Literal, Optional, Tuple\n\nimport numpy as np\n\nfrom ._persist import atomic_save, check_persisted_handles, check_schema_version\nfrom ._similarity import l2_normalize_rows, validate_similarity\nfrom ._turbovec import IdMapIndex\n\ntry:\n    from haystack import Document\n    from haystack.dataclasses import ByteStream\n    from haystack.dataclasses.sparse_embedding import SparseEmbedding\n    from haystack.document_stores.errors import DuplicateDocumentError\n    from haystack.document_stores.types import DuplicatePolicy\n    from haystack.utils.filters import document_matches_filter\nexcept ImportError as exc:\n    raise ImportError(\n        \"haystack-ai is required to use turbovec.haystack. \"\n        \"Install with: pip install turbovec[haystack]\"\n    ) from exc\n\n\nclass TurboQuantDocumentStore:\n    \"\"\"Haystack DocumentStore backed by a :class:`~turbovec.IdMapIndex`.\n\n    Vectors are quantized to 2–4 bits per dimension. Full-precision\n    embeddings are dropped after quantization — callers requesting\n    ``return_embedding=True`` on retrieval will see ``None`` on the\n    returned documents' ``embedding`` field regardless of the flag.\n\n    **Similarity modes.** ``embedding_similarity_function=\"cosine\"``\n    (default) L2-normalizes document embeddings at write time and query\n    embeddings at retrieval time, so raw scores are cosine similarity in\n    ``[-1, 1]``, ranking matches ``InMemoryDocumentStore``'s cosine\n    branch for embeddings of any magnitude, and ``scale_score=True``","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/haystack.py#L24-L60","documentation":"Module-level ImportError raised when turbovec.haystack is imported without haystack-ai installed. The try/except around the haystack imports converts the raw ModuleNotFoundError into a named error with the correct extra-install command, so users learn at import time which optional dependency is missing.","triggerScenarios":"Thrown at turbovec-python/python/turbovec/haystack.py:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install the extra: pip install turbovec[haystack].","Or install haystack-ai directly into the environment.","Avoid importing turbovec.haystack in environments that do not need Haystack integration."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}