# LangChain Envector Integration
Encrypted vector search for LangChain using Envector (ES2), powered by homomorphic encryption (CKKS). This repo ships a LangChain-compatible VectorStore and retriever utilities built on the high-level `es2` Python SDK.
## Features
- LangChain `VectorStore` interface with `similarity_search`, `from_texts`, etc.
- Optional `VectorStoreRetriever` helper for quick RAG integrations.
- Client-side encryption handled transparently by the SDK, including score thresholds and filtering.
## Installation
- Python 3.9–3.13 (recommend 3.11)
- Create and activate a virtualenv:
- `python3.11 -m venv .venv && source .venv/bin/activate`
- Install runtime dependencies:
- `pip install -U pip setuptools wheel`
- `pip install es2==1.1.0rc2 langchain sentence-transformers`
## Usage Overview
1. Configure Envector using `EnvectorConfig`, pointing to your ES2 endpoint and keys.
2. Initialize embeddings (or provide pre-computed vectors).
3. Instantiate `Envector(config=cfg, embeddings=emb)` and call `add_texts` or `as_retriever`.
4. Run `similarity_search` or plug the retriever into your LangChain pipeline.
> See `notebooks/` for end-to-end walkthroughs and the `libs/envector` package for implementation details.
## Configuration
Key dataclasses live in `libs/envector/config.py`:
- `ConnectionConfig`: address or host/port for ES2.
- `KeyConfig`: key path, key ID, optional preset/eval mode.
- `IndexSettings`: index name, dimension (16–4096), query encryption mode, optional output fields and fetch parameters.
- `EnvectorConfig`: wraps the above and enables auto-creation via `create_if_missing`.
## Data Model
- Each vector stores a single `metadata` string in ES2.
- To align with LangChain’s `Document`, inserts wrap data as JSON: `{"text": ..., "metadata": ...}`.
- Retrieval unwraps JSON, returning `Document(page_content=text, metadata={...})`.
- Client-side filtering requires the JSON envelope to include an object under `metadata`.
## Limitations
- Item-level delete/update is unsupported (drop the index to reset).
- Manual item IDs are not accepted; returned IDs from `add_texts` are ephemeral.
- Filtering happens client-side; ensure metadata is JSON for structured filters.
## Troubleshooting
- Connection issues: verify ES2 address and registered keys.
- Embeddings mismatch: ensure embedding dimension equals `index.dim` when supplying vectors.
- Unexpected raw strings: confirm inserts used the JSON envelope.
## Contributing
See [`CONTRIBUTE.md`](CONTRIBUTE.md) for development, testing, and PR guidelines.
Raw data
{
"_id": null,
"home_page": null,
"name": "langchain-envector",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.9",
"maintainer_email": null,
"keywords": "langchain, vectorstore, homomorphic-encryption, ckks, encrypted-search, envector, es2",
"author": "Envector Contributors",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# LangChain Envector Integration\n\nEncrypted vector search for LangChain using Envector (ES2), powered by homomorphic encryption (CKKS). This repo ships a LangChain-compatible VectorStore and retriever utilities built on the high-level `es2` Python SDK.\n\n## Features\n- LangChain `VectorStore` interface with `similarity_search`, `from_texts`, etc.\n- Optional `VectorStoreRetriever` helper for quick RAG integrations.\n- Client-side encryption handled transparently by the SDK, including score thresholds and filtering.\n\n## Installation\n- Python 3.9\u20133.13 (recommend 3.11)\n- Create and activate a virtualenv:\n - `python3.11 -m venv .venv && source .venv/bin/activate`\n- Install runtime dependencies:\n - `pip install -U pip setuptools wheel`\n - `pip install es2==1.1.0rc2 langchain sentence-transformers`\n\n## Usage Overview\n1. Configure Envector using `EnvectorConfig`, pointing to your ES2 endpoint and keys.\n2. Initialize embeddings (or provide pre-computed vectors).\n3. Instantiate `Envector(config=cfg, embeddings=emb)` and call `add_texts` or `as_retriever`.\n4. Run `similarity_search` or plug the retriever into your LangChain pipeline.\n\n> See `notebooks/` for end-to-end walkthroughs and the `libs/envector` package for implementation details.\n\n## Configuration\nKey dataclasses live in `libs/envector/config.py`:\n- `ConnectionConfig`: address or host/port for ES2.\n- `KeyConfig`: key path, key ID, optional preset/eval mode.\n- `IndexSettings`: index name, dimension (16\u20134096), query encryption mode, optional output fields and fetch parameters.\n- `EnvectorConfig`: wraps the above and enables auto-creation via `create_if_missing`.\n\n## Data Model\n- Each vector stores a single `metadata` string in ES2.\n- To align with LangChain\u2019s `Document`, inserts wrap data as JSON: `{\"text\": ..., \"metadata\": ...}`.\n- Retrieval unwraps JSON, returning `Document(page_content=text, metadata={...})`.\n- Client-side filtering requires the JSON envelope to include an object under `metadata`.\n\n## Limitations\n- Item-level delete/update is unsupported (drop the index to reset).\n- Manual item IDs are not accepted; returned IDs from `add_texts` are ephemeral.\n- Filtering happens client-side; ensure metadata is JSON for structured filters.\n\n## Troubleshooting\n- Connection issues: verify ES2 address and registered keys.\n- Embeddings mismatch: ensure embedding dimension equals `index.dim` when supplying vectors.\n- Unexpected raw strings: confirm inserts used the JSON envelope.\n\n## Contributing\nSee [`CONTRIBUTE.md`](CONTRIBUTE.md) for development, testing, and PR guidelines.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "LangChain VectorStore integration for Envector (ES2) encrypted vector search",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://example.com/",
"Repository": "https://example.com/repo"
},
"split_keywords": [
"langchain",
" vectorstore",
" homomorphic-encryption",
" ckks",
" encrypted-search",
" envector",
" es2"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "11c232d337c75315195233c96eb7dfb9b2026d8743f6b888d1360d559dbeb38a",
"md5": "bae253a6695fcc7e7c9988cc0b011e27",
"sha256": "bee041ec982b23a8bdc6a176d96e88226b4c8b2a9df31b6122015949b0ea75f8"
},
"downloads": -1,
"filename": "langchain_envector-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bae253a6695fcc7e7c9988cc0b011e27",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.9",
"size": 10117,
"upload_time": "2025-10-08T13:14:32",
"upload_time_iso_8601": "2025-10-08T13:14:32.351705Z",
"url": "https://files.pythonhosted.org/packages/11/c2/32d337c75315195233c96eb7dfb9b2026d8743f6b888d1360d559dbeb38a/langchain_envector-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-08 13:14:32",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "langchain-envector"
}