CLI tool for RAG over local documents
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rag_cli_tool-0.1.0.tar.gz.
File metadata
- Download URL: rag_cli_tool-0.1.0.tar.gz
- Upload date:
- Size: 122.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa5252819ec7f4e2097e165f21a360554ae784f71842b4b2e8761c1ea11bc00b
|
|
| MD5 |
5d1b700ddca184b918523c1fcbad9559
|
|
| BLAKE2b-256 |
0ca2b625875f83a85e05b2602c7ac9e8157bc43982cc9e27da3a2b588981f76b
|
File details
Details for the file rag_cli_tool-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rag_cli_tool-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d4ac8ba4796aad1187166b9141fe9b73bc3495c767c69b529dedefc10c64b65
|
|
| MD5 |
042c02cc3cc79bd81cf3a74ea1070be1
|
|
| BLAKE2b-256 |
295b3a8dc52e7458a4b849657f38980afe8475fb61d4ac0ae3069b9adb927b2e
|