# Build RAG From Scratch in Python: Test Retrieval With LangChain: runnable files

6 local tests with LangChain Core 0.3.75 and Text Splitters 0.3.9; lexical retrieval and prompt construction only, no LLM generation or embedding API.

Download all files in this folder before running. The article is at https://oneruby.dev/building-rag-from-scratch-python-langchain-guide/.

## Reproduce

Tested with Python 3.11.5 on arm64 macOS. Use an isolated environment; requirements.txt pins direct dependencies and requirements.lock records the tested dependency closure for this platform.

```sh
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.lock
.venv/bin/python -B -m unittest -v test_example.py
.venv/bin/python -B example.py
```

## Files

- [requirements.lock](requirements.lock)

- [corpus.json](corpus.json)
- [example.py](example.py)
- [requirements.txt](requirements.txt)
- [test_example.py](test_example.py)

## Boundaries

- Tests stop at prompt construction; no LLM response or prompt-injection resistance verification.
- Lexical term-count retrieval is not semantic embedding retrieval; zero overlap does not prove that a document cannot answer.
- In-memory replacement of a tiny corpus; no persistent database, concurrency or remote integration.
- Allowed scopes must come from trusted application state; the toy scope argument is not authentication.
