Skip to main content

langchain-raglineage

Use RAGLineage as a LangChain BaseRetriever, preserving source references, lineage IDs, stored content hashes, dataset versions, transform chains and scores. Works with Runnable pipelines and LangGraph. LangSmith instrumentation is explicit and off by default. Apache-2.0; independently maintained, not a LangChain endorsement.

Status: release candidate 0.1.0; not published yet. Python 3.11+.

Install from this checkout

python -m pip install .
# Optional instrumentation and graph examples:
python -m pip install '.[langsmith,langgraph]'

After maintainer-approved publication, the corresponding commands will be:

pip install langchain-raglineage
pip install 'langchain-raglineage[langsmith,langgraph]'

Quickstart

from pathlib import Path
from tempfile import TemporaryDirectory
from raglineage import RagLineage
from langchain_raglineage import RAGLineageRetriever

with TemporaryDirectory() as directory:
    Path(directory, "policy.txt").write_text("Refunds are available for thirty days.")
    engine = RagLineage(source=directory, embed_backend="hash", store_backend="numpy")
    engine.build(version="v1")
    retriever = RAGLineageRetriever(engine=engine, top_k=5)
    documents = retriever.invoke("What is the refund policy?")
    print(documents[0].page_content)
    print(documents[0].metadata)

For async applications: documents = await retriever.ainvoke(question). Async uses a worker thread because the engine has no native async retrieval API.

Configuration

from langchain_raglineage import RetrievalFilters

retriever = RAGLineageRetriever(
    engine=engine,
    top_k=5,
    dataset_version="v1",  # asserts the currently indexed version
    filters=RetrievalFilters(source_type="pdf", min_score=0.2),
)
# Temporary per-call limit; does not change the retriever:
documents = retriever.invoke("financial risks", top_k=3)

Exact source URI, source type and minimum score are supported. Arbitrary metadata filters are not. The engine filters a limited candidate set, so fewer than top_k matches can be returned. Historical dataset retrieval is not supported by RAGLineage 0.2.x; the adapter raises an explicit error for an older manifest.

Separation of responsibilities

  • RAGLineage: persistent data provenance, retrieval, file-version manifests, and audit heuristics. This adapter does not rebuild or mutate datasets.
  • LangChain / LangGraph: prompts, models, application state and orchestration.
  • LangSmith: execution traces; not a replacement for the persistent lineage graph.

The default hash embeddings support offline lexical search. They are not semantic model embeddings. See core RAGLineage options for local or API embedding backends.

Examples (offline by default)

python examples/basic_retrieval.py
python examples/langchain_rag.py
python examples/langgraph_workflow.py
python examples/langsmith_tracing.py

The chain and graph examples use FakeListChatModel, not a live LLM. Replace it with a model you configure in your application. They retain provenance separately from answer text. No general answer-reproducibility claim is made.

Documentation

Checks

python -m pip install -e '.[test,dev,langsmith,langgraph]'
pytest
ruff check .
ruff format --check .
mypy
python -m build
python -m twine check dist/*

Tests prohibit external sockets and use actual offline indexes and SDK context handling with mocked trace transport. They include the official langchain-tests retriever contract. No credentials are needed.

Metadata

Release files for langchain-raglineage 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-raglineage 0.1.0
File Size Uploaded Provenance Actions
langchain_raglineage-0.1.0.tar.gz 36.0 kB With provenance Details for langchain_raglineage-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-raglineage 0.1.0
File Interpreter ABI Platform Actions
langchain_raglineage-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_raglineage-0.1.0-py3-none-any.whl

Total release size: 50.7 kB

Release files / langchain_raglineage-0.1.0.tar.gz

Download URL langchain_raglineage-0.1.0.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eb9fd96a2615c664612badcd53b1ac23d9e10898af97a6309debc52ebefeef9e
BLAKE2b-256 checksum
How to use checksums
7935c8054100cbf0682ba38f81a72333d7d759e2ad057ad7c72528546203e8e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 29, 2026.

Transparency log

Release files / langchain_raglineage-0.1.0-py3-none-any.whl

Download URL langchain_raglineage-0.1.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbd5c720699a982223abfd2ab06164acc87545a0d6a25b8998cde9ca9cade99e
BLAKE2b-256 checksum
How to use checksums
db680a2ae43188512f5c4e745fe49f7d6fcf9d62452cc54beb8608d8fb129b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 29, 2026.

Transparency log

Security for langchain-raglineage 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_raglineage-0.1.0.tar.gz

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 Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page