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:
pip install cyborgdb-core[langchain]
To learn more about the differences between cyborgdb and cyborgdb-core, refer to the Deployment Models Guide.

Import

from cyborgdb_core.integrations.langchain import CyborgVectorStore

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)

DBConfig (Embedded only)

Configuration object for defining the location of index data (memory, redis, postgres, rocksdb, threadsafememory). Used only with the Embedded library (cyborgdb-core).

Quick Start

from cyborgdb_core.integrations.langchain import CyborgVectorStore
from cyborgdb_core import DBConfig
from langchain_openai import OpenAIEmbeddings

store = CyborgVectorStore.from_texts(
    texts=["hello world", "goodbye world"],
    embedding=OpenAIEmbeddings(),
    index_key=CyborgVectorStore.generate_key(save=True),
    api_key="your-api-key",
    index_location=DBConfig("memory"),
    config_location=DBConfig("memory"),
    index_type="ivfsq",
    metric="cosine"
)

docs = store.similarity_search("hello")