Metadata-Version: 2.5
Name: langchain-raglineage
Version: 0.1.0
Summary: LangChain retriever for RAGLineage with preserved provenance and opt-in LangSmith tracing
Project-URL: Homepage, https://github.com/PranavMotarwar/langchain-raglineage
Project-URL: Repository, https://github.com/PranavMotarwar/langchain-raglineage
Project-URL: Documentation, https://github.com/PranavMotarwar/langchain-raglineage/blob/main/README.md
Project-URL: Issues, https://github.com/PranavMotarwar/langchain-raglineage/issues
Author: Pranav Motarwar
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: <4,>=3.11
Requires-Dist: langchain-core<2,>=1.8.5
Requires-Dist: pydantic<3,>=2.7
Requires-Dist: raglineage<0.3,>=0.2.12
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == 'dev'
Requires-Dist: mypy<3,>=1.15; extra == 'dev'
Requires-Dist: ruff<0.18,>=0.17; extra == 'dev'
Requires-Dist: twine<8,>=6; extra == 'dev'
Provides-Extra: langgraph
Requires-Dist: langgraph<2,>=1.2.24; extra == 'langgraph'
Provides-Extra: langsmith
Requires-Dist: langsmith<0.17,>=0.16.2; extra == 'langsmith'
Provides-Extra: test
Requires-Dist: langchain-tests==1.2.0; extra == 'test'
Requires-Dist: langgraph<2,>=1.2.24; extra == 'test'
Requires-Dist: langsmith<0.17,>=0.16.2; extra == 'test'
Requires-Dist: pypdf<8,>=6.1.1; extra == 'test'
Requires-Dist: pytest-asyncio<2,>=1; extra == 'test'
Requires-Dist: pytest-cov<8,>=6; extra == 'test'
Requires-Dist: pytest-socket<1,>=0.7; extra == 'test'
Requires-Dist: pytest<10,>=8; extra == 'test'
Description-Content-Type: text/markdown

# 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

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

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

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

## Quickstart

```python
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

```python
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)

```bash
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

- [Installation and compatibility](docs/installation.md)
- [Quickstart, chain and graph workflows](docs/quickstart.md)
- [Metadata, versioning and audit limitations](docs/provenance.md)
- [LangSmith and privacy](docs/langsmith.md)
- [API reference](docs/api.md)
- [Development, CI and release process](docs/development.md)
- [Repository assessment and implementation plan](docs/assessment.md)
- [Benchmark methodology and results](benchmarks/README.md)
- [Submission proposal](docs/integration-submission.md)

## Checks

```bash
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.
