rag-cli-tool
CLI tool for RAG over local documents. Index a folder, ask questions.
Prerequisites
- Python 3.12+
- uv (recommended) or pip
Installation
git clone <repo-url>
cd rag-cli-tool
uv venv && uv pip install -e .
All commands below use uv run rag-cli to run within the virtual environment.
Quick Start
Option A: Local with Ollama (no API keys)
- Install Ollama and pull models:
ollama pull llama3.2
ollama pull nomic-embed-text
- Create a
.envfile:
RAG_CLI_MODEL=ollama:llama3.2
RAG_CLI_EMBEDDING_MODEL=ollama:nomic-embed-text
- Index and ask:
uv run rag-cli index ./my-docs/
uv run rag-cli ask "What is the refund policy?"
Option B: Cloud providers (Anthropic + OpenAI)
- Create a
.envfile:
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
- Index and ask:
uv run rag-cli index ./my-docs/
uv run rag-cli ask "What is the refund policy?"
Mix-and-match
You can combine local and cloud providers — for example, local generation with cloud embeddings:
OPENAI_API_KEY=sk-...
RAG_CLI_MODEL=ollama:llama3.2
Commands
rag-cli index <path>
Index documents from a folder into the local vector store.
uv run rag-cli index ./documents/
uv run rag-cli index ./documents/ --chunk-size 500 --chunk-overlap 50
uv run rag-cli index ./documents/ --fresh # Wipe and rebuild index
Supported formats: .pdf, .md, .txt, .docx
Indexing is incremental by default — only new documents are embedded. Use --fresh to wipe the existing index and rebuild from scratch.
rag-cli ask "<question>"
Ask a question about your indexed documents.
uv run rag-cli ask "What are the payment terms?"
uv run rag-cli ask "What are the payment terms?" --top-k 5
The answer is generated using only the retrieved document context (strict RAG — no external knowledge).
Configuration
All settings can be set via environment variables or a .env file in the project root.
| Variable | Default | Description |
|---|---|---|
ANTHROPIC_API_KEY |
Anthropic API key (required for cloud generation) | |
OPENAI_API_KEY |
OpenAI API key (required for cloud embeddings) | |
RAG_CLI_MODEL |
claude-3-5-sonnet-latest |
LLM model for generation |
RAG_CLI_EMBEDDING_MODEL |
text-embedding-3-small |
Embedding model |
RAG_CLI_OLLAMA_HOST |
http://localhost:11434 |
Ollama server URL |
RAG_CLI_CHUNK_SIZE |
1000 |
Max characters per chunk |
RAG_CLI_CHUNK_OVERLAP |
200 |
Overlap between chunks |
RAG_CLI_TOP_K |
3 |
Number of chunks to retrieve |
Model string format
Use the ollama: prefix to route to a local Ollama model. No prefix uses the default cloud provider.
| Variable | Value | Provider |
|---|---|---|
RAG_CLI_MODEL |
claude-3-5-sonnet-latest |
Anthropic API |
RAG_CLI_MODEL |
ollama:llama3.2 |
Ollama (local) |
RAG_CLI_EMBEDDING_MODEL |
text-embedding-3-small |
OpenAI API |
RAG_CLI_EMBEDDING_MODEL |
ollama:nomic-embed-text |
Ollama (local) |
Project Structure
src/
├── rag_cli/ # CLI interface (Typer + Rich)
├── llm_core/ # LLM abstraction layer (providers, config, retry)
└── rag_core/ # RAG pipeline (loaders, chunking, embeddings, retrieval)
llm_core and rag_core are designed as independent, reusable packages.
License
MIT
Metadata
Release files for rag-cli-tool 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rag_cli_tool-0.1.0.tar.gz | 122.2 kB | Without provenance | Details for rag_cli_tool-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rag_cli_tool-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for rag_cli_tool-0.1.0-py3-none-any.whl |
Total release size: 142.5 kB
Release files / rag_cli_tool-0.1.0.tar.gz
| Download URL | rag_cli_tool-0.1.0.tar.gz |
|---|---|
| Size | 122.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa5252819ec7f4e2097e165f21a360554ae784f71842b4b2e8761c1ea11bc00b
|
|
BLAKE2b-256 checksum How to use checksums |
0ca2b625875f83a85e05b2602c7ac9e8157bc43982cc9e27da3a2b588981f76b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.4
|
Release files / rag_cli_tool-0.1.0-py3-none-any.whl
| Download URL | rag_cli_tool-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d4ac8ba4796aad1187166b9141fe9b73bc3495c767c69b529dedefc10c64b65
|
|
BLAKE2b-256 checksum How to use checksums |
295b3a8dc52e7458a4b849657f38980afe8475fb61d4ac0ae3069b9adb927b2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.4
|
Security for rag-cli-tool 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.