citadeldb-langchain
A LangChain VectorStore and
BaseChatMessageHistory backed by Citadel. Encrypted at rest,
embedded in your process, and deletes that destroy the key, not just the row.
pip install citadeldb-langchain
Vector store
from langchain_openai import OpenAIEmbeddings
from citadeldb_langchain import CitadelVectorStore
store = CitadelVectorStore(OpenAIEmbeddings(), "corpus.cdl", key="your-passphrase")
store.add_texts(["the deploy failed because the disk was full"], ids=["note-1"])
store.similarity_search("why did the release break?", k=1)
retriever = store.as_retriever(search_kwargs={"k": 4})
The width is read from your embedding model on construction, so nothing has to be
configured to match it. Pass dim= to skip that probe.
Models exposing model_id, model, or model_name record that identity automatically,
in that order. For a custom embedding without any of those attributes, pass a stable
model_id= explicitly; Citadel refuses to guess from the Python class name.
Adding an id that is already stored replaces it, so re-indexing a document does not duplicate it.
Deletes destroy the key
Every document is sealed under its own key. Deleting destroys that key and then removes the row, so any ciphertext surviving elsewhere stays unreadable.
store.delete(["note-1"]) # named ids
store.clear() # the whole corpus, deliberately
delete() with no ids is a no-op, matching InMemoryVectorStore. Emptying the store is
clear(), because erasure cannot be undone.
Filters
store.similarity_search("...", k=4, filter={"source": "handbook.pdf"})
The filter is evaluated inside the scan, so it narrows candidates before top-k rather than
trimming results after it, and k is k: a filter matching only distant documents still
returns them, however many others outrank them.
Chat history
import citadeldb
from citadeldb_langchain import CitadelChatMessageHistory
history = CitadelChatMessageHistory(
"user-123",
"chats.cdl",
key="your-passphrase",
# Required, and no default. This history reads by session id rather than by
# vector, so the mock is the honest choice unless you want semantic recall
# over turns; either way the region records which model wrote it.
embedder=citadeldb.MockEmbedder(dim=64),
)
history.add_user_message("remember my dog is called Mochi")
history.messages
Messages round-trip through LangChain's own serialization, so tool calls, block content
and additional_kwargs all survive. clear() destroys each message's key, so a cleared
conversation is unreadable.
Use it with RunnableWithMessageHistory the same way as any other history:
import citadeldb
from langchain_core.runnables.history import RunnableWithMessageHistory
chain = RunnableWithMessageHistory(
runnable, # your chain
lambda session_id: CitadelChatMessageHistory(
session_id,
"chats.cdl",
key="...",
embedder=citadeldb.MockEmbedder(dim=64),
),
input_messages_key="input",
history_messages_key="history",
)
Notes
Citadel is embedded and one process owns the file. A path already open on this thread, under the same passphrase, is shared, so the vector store and the chat history can sit on one encrypted database; construct them on the same thread.
License
Apache-2.0
Release files for citadeldb-langchain 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| citadeldb_langchain-2.1.0.tar.gz | 14.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| citadeldb_langchain-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / citadeldb_langchain-2.1.0.tar.gz
| Download URL | citadeldb_langchain-2.1.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c133fd9a317659a7793c26c1d2b12ca6f4221eef12151caaeece10033cf0969
|
|
BLAKE2b-256 checksum How to use checksums |
c8db2cde9d83bc3e7cecdaadf0dc10c3727338373a9ca20f22ce70b7dd073920
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency logRelease files / citadeldb_langchain-2.1.0-py3-none-any.whl
| Download URL | citadeldb_langchain-2.1.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceba5f0055410f5aeefe653970fd50e4a1e6a90f6adc89d5b7551c12346dbd68
|
|
BLAKE2b-256 checksum How to use checksums |
933a65fe66d8ca6dba131feeb5b4eb560b2e0f16501409900dc507fb69cb8e5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency log