Docs / Add it to your code

LangChain

examples/langchain_adapter/pipeline.py — the same nine stages as the plain-Python reference, wired onto real LangChain constructs wherever one exists for the job:

Stage LangChain construct
document in Plain Python file enumeration — LangChain's own document loaders already return parsed text, so there's no LangChain construct that reads "raw bytes, not yet parsed."
converted langchain_community.document_loaders: TextLoader (.txt/.md), BSHTMLLoader (.html), PyPDFLoader (.pdf).
cleaned Plain Python NFKC/whitespace normalization — LangChain has no first-class cleaning primitive between loading and splitting.
split langchain_text_splitters.RecursiveCharacterTextSplitter.
embedded langchain_community.embeddings.DeterministicFakeEmbedding — no network, no real model, deterministic.
indexed / retrieved LangChain's own in-memory vector store and retriever interface.
answer A substituted, deterministic extraction step behind LangChain's own LLM extension point — no real model, no network.

Where no LangChain construct exists at all (document in, cleaned), plain Python is used instead and named as a substitution in the run, never silently folded into "this is what LangChain does."

A worked example, not an integration. This page is a hand-written nine-stage pipeline that calls LangChain classes inside onetrace stages, so a comparison with the plain-Python run is like for like. It is not an adapter you plug an existing LangChain app into: decorated code gets one receipt per decorated function, so a chain or graph called inside one stage is one receipt. Each framework needs its own virtual environment (their pins conflict; examples/PIN_DISCIPLINE.md).

LangChain messages carry a per-run id. An AIMessage returned from a stage is recorded through its pydantic fields, including id (lc_run--…), which is different on every run: two identical runs then compare as different at that stage. Register an encoder before the run that leaves it out:

from langchain_core.messages import BaseMessage
ot.encoder(BaseMessage, lambda m: {"type": m.type, "content": m.content,
                                   "tool_calls": getattr(m, "tool_calls", [])})

onetrace doctor names a stage whose recorded output holds such an id.

The decorated version passes data outside the record. pipeline_decorated.py moves texts, chunks, vectors and the vector store through a module-level WORK dict, so its receipts match the hand-written run digest for digest. It is a comparison fixture; don't copy that pattern into a pipeline of your own: return the working data from each stage instead, so each step's receipt records what it handed on.

Get this code

The example's files are not part of the installed onetrace package. They come in its source package on PyPI, a .tar.gz file you download and unpack. In a terminal, in an empty folder, with your virtual environment active, run:

pip download onetrace==0.9.1 --no-binary :all: --no-deps
tar -xzf onetrace-0.9.1.tar.gz
cd onetrace-0.9.1

The first line downloads the source package without installing it, the second unpacks it into a folder named onetrace-0.9.1, and the third moves into that folder. Run the commands below from there. tar comes with current Windows, macOS and Linux; on Windows, use PowerShell.

Running it

Needs the exact pins in examples/langchain_adapter/requirements.txt (LangChain and LlamaIndex pin conflicting numpy versions — install one adapter's requirements at a time, or use a dedicated virtual environment per adapter; see examples/PIN_DISCIPLINE.md).

pip install -r examples/langchain_adapter/requirements.txt
python examples/langchain_adapter/pipeline.py OUT_DIR RUN_ID

OUT_DIR is a new folder for the run's record, for example runs/first: a folder that already holds a run is refused. RUN_ID is a name you choose for the run, for example first.

Keeping chunk text: keep_text

python examples/langchain_adapter/pipeline.py TEXT_OUT_DIR RUN_ID --keep-text

TEXT_OUT_DIR is another new folder: each run needs a folder of its own.

or main(out_dir, run_id, keep_text=True) from Python. It is off by default.

What a run folder stores either way: each stage's outputs, which include documents' converted and cleaned text, prompts and answers. Inputs are only fingerprinted. Treat run folders like logs that may contain sensitive data. keep_text adds the chunk text to that.