Skip to main content
CyborgDB provides a seamless integration with LangChain, enabling developers to leverage encrypted vector search for large language models (LLMs) and RAG pipelines. This integration is implemented via the CyborgVectorStore class, which conforms to the VectorStore interface from langchain-core.

Installation

Install cyborgdb-core with the langchain extra (Python 3.10 or newer; the python3 that ships with macOS is 3.9):
To learn more about the differences between cyborgdb and cyborgdb-core, refer to the Deployment Models Guide.

Import

Key Features

  • Full VectorStore API compatibility (add_texts, similarity_search, etc.)
  • Async operations support
  • Configurable distance metrics (cosine, euclidean, squared_euclidean)
  • Document ID tracking and management
  • Max marginal relevance search
  • Factory methods (from_texts, from_documents) for quick setup

Key Classes

CyborgVectorStore

Implements the LangChain-compatible vector store interface. Supports:
  • .add_texts() / .add_documents()
  • .similarity_search() / .similarity_search_with_score()
  • .max_marginal_relevance_search()
  • .get() / .list_ids() / .delete()
  • .as_retriever() for use in LangChain chains
  • Async variants (.aadd_texts(), .asimilarity_search(), etc.)
  • Reversible document ID tracking
  • Configurable distance metric (cosine, euclidean, squared_euclidean)

StorageConfig (Embedded only)

Configuration object for defining where index data is stored, built with StorageConfig.disk(path) or StorageConfig.s3(bucket, ...). Used only with the Embedded library (cyborgdb-core).

Quick Start

To keep the index between runs, store index_key and construct CyborgVectorStore(index_name="langchain_index", index_key=index_key, api_key="", embedding="all-MiniLM-L6-v2", storage_config=...) directly: it reopens an existing index instead of creating one.To embed with OpenAI instead of the built-in model, install langchain-openai (it is not part of the langchain extra), set OPENAI_API_KEY, and pass embedding=OpenAIEmbeddings():
Store index_key before you upsert any data. CyborgDB has no key-recovery path — losing the key means losing the data. For anything past evaluation, keep the key in AWS Secrets Manager, Vault, or your KMS. See Managing Keys.
generate_key(save=True) exists in the Python SDK only. The embedded library’s generate_key() returns the bytes and nothing else, so persist the key yourself as shown above.