Metadata-Version: 2.5
Name: wittgenstein-rag
Version: 0.2.0
Summary: A self-aware review layer for RAG pipelines: flags the retrieved text and answer sentences most likely to hide an LLM misreading, with a local interface.
Project-URL: Homepage, https://github.com/jonahablack/Wittgenstein
Project-URL: Source, https://github.com/jonahablack/Wittgenstein/tree/Cosmos/engine
Author: Wittgenstein RAG Reliability contributors
License: Apache-2.0
License-File: LICENSE
Keywords: hallucination,langchain,llamaindex,llm,rag,retrieval-augmented generation,verification
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: alembic>=1.14
Requires-Dist: fastapi>=0.115
Requires-Dist: huggingface-hub>=0.30
Requires-Dist: llama-index-core>=0.12
Requires-Dist: model2vec>=0.10
Requires-Dist: numpy>=2.0
Requires-Dist: onnxruntime>=1.20
Requires-Dist: pydantic-settings>=2.6
Requires-Dist: pydantic>=2.9
Requires-Dist: pypdf>=6.0
Requires-Dist: python-multipart>=0.0.20
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.9
Requires-Dist: spacy<3.9,>=3.8
Requires-Dist: sqlalchemy>=2.0
Requires-Dist: sqlmodel>=0.0.22
Requires-Dist: sse-starlette>=3.0
Requires-Dist: tokenizers>=0.20
Requires-Dist: typer>=0.13
Requires-Dist: uvicorn[standard]>=0.32
Provides-Extra: anthropic
Requires-Dist: anthropic>=2.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: mypy>=1.13; extra == 'dev'
Requires-Dist: pytest-cov>=6.0; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3; extra == 'langchain'
Provides-Extra: openai
Requires-Dist: openai>=2.0; extra == 'openai'
Provides-Extra: quality
Requires-Dist: fastembed>=0.9; extra == 'quality'
Description-Content-Type: text/markdown

# Wittgenstein

A review layer for retrieval-augmented generation (RAG). It runs beside the pipeline you
already have, checks every answer against the passages it came from, and points a
person to the few sentences worth a look: a dose that isn't in the source, a patient
group or condition that was dropped, a citation to the wrong passage, an answer that
says nothing at all.

It also knows the pipeline it is watching: how the documents were split, what the
search returned, and what never reached the model. So a flag can say whether the model
misread a passage or was never given the right one.

## Install and run

```bash
pip install wittgenstein-rag
wittgenstein serve          # opens the local interface at http://127.0.0.1:8100
```

Add `--demo` to see a few example answers first. Everything runs on your machine; the
first run downloads a small English language model (about 12 MB).

## Connect your pipeline

Add two lines where your app starts:

```python
import wittgenstein.monitor as wm
wm.instrument()
```

LangChain and LlamaIndex pipelines are detected and hooked automatically, with no other
code changes. Every answer then appears in the local interface with what was retrieved,
what went into the prompt, and what needs checking. For any other pipeline, report each
answer yourself:

```python
wm.record(question, retrieved_chunks, answer, prompt=prompt_text)
```

Reporting happens in the background and never slows or breaks your pipeline.

## Or call the API

```bash
curl -X POST http://127.0.0.1:8100/v1/check -H "content-type: application/json" -d '{
  "query": "What is the starting dose of metformin extended-release?",
  "candidates": [{"id": "c1", "text": "The recommended starting dosage is 500 mg once daily with the evening meal."}],
  "answer": "Start at 850 mg once daily. [1]"
}'
```

`summary.needs_review` in the response says whether a person should look, and each
flagged sentence says why. Full documentation is in the running app under **API**.

## Limits

Flags mean "a person should look", not "this is wrong". The checks are tuned on drug
labels; citation, empty-answer, document and context checks work in any domain. See the
[repository](https://github.com/jonahablack/Wittgenstein) for the evaluation behind it.

Supported by a grant from the [Cosmos Institute](https://www.cosmos-institute.org/).
