Local Directory RAG
A simple tool for Retrieval-Augmented Generation (RAG) using documents from your local filesystem.
Overview
Local Directory RAG allows you to:
- Create vector embeddings from your local documents (PDF, TXT)
- Query these documents using natural language, leveraging OpenAI's language models
Requirements
- Python 3.13 or higher
- OpenAI API key (set in your .env file)
Installation
# Clone the repository
git clone https://github.com/sualeh/local-dir-rag.git
cd local-dir-rag
# Install dependencies
pip install -e .
Configuration
Create a .env file in the project root with your OpenAI API key:
OPENAI_API_KEY=your-api-key-here
You can also create a .env.params file to set default directories:
DOCS_DIRECTORY=path/to/your/documents
VECTOR_DB_PATH=path/to/save/vector/database
Run Locally
Run locally with the following command, with the approproate arguments:
poetry run python -m local_dir_rag.main
Usage
Create Vector Database
# Using command line arguments
python -m local_dir_rag.main embed --docs-directory /path/to/docs --vector-db-path /path/to/vector_db
# Or if installed as a package
local-dir-rag embed --docs-directory /path/to/docs --vector-db-path /path/to/vector_db
Query Documents
# Using command line arguments
python -m local_dir_rag.main query --vector-db-path /path/to/vector_db
# Or if installed as a package
local-dir-rag query --vector-db-path /path/to/vector_db
Docker Usage
You can run Local RAG using Docker:
# Pull the Docker image
docker pull sualeh/local-dir-rag:latest
# Embed documents
docker run -v /path/to/your/docs:/data/docs -v /path/to/vector_db:/data/vector_db \
-e OPENAI_API_KEY=your-api-key-here \
sualeh/local-dir-rag embed
# Query your documents
docker run -v /path/to/vector_db:/data/vector_db \
-e OPENAI_API_KEY=your-api-key-here \
sualeh/local-dir-rag query
You can also pass command line arguments directly:
docker run -v /path/to/your/docs:/data/docs -v /path/to/output:/data/vector_db \
-e OPENAI_API_KEY=your-api-key-here \
sualeh/local-dir-rag embed --docs-directory /data/docs --vector-db-path /data/vector_db
Docker Compose Usage
You can also use Docker Compose for easier management of the Local RAG container:
- Create a
docker-compose.ymlfile:
version: '3'
services:
local-dir-rag:
image: sualeh/local-dir-rag:latest
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
volumes:
- ./docs:/data/docs
- ./vector_db:/data/vector_db
- Run the application:
# For embedding documents
docker-compose run local-dir-rag embed
# For querying documents
docker-compose run local-dir-rag query
You can also pass additional arguments:
docker-compose run local-dir-rag embed --docs-directory /data/docs --vector-db-path /data/vector_db
This approach simplifies volume mounting and environment variable management, especially when working with the tool regularly.
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 local_dir_rag-0.1.0.tar.gz.
File metadata
- Download URL: local_dir_rag-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a28fb65161b2b897b000bd2e0efe106b42531ad70741a82b09aa05d63a7e293f
|
|
| MD5 |
ea162b72b2215b47e9bf4b59366ba205
|
|
| BLAKE2b-256 |
eb6b241c8de51832b35da370aa9d60e10c837bc014a224fa0bbc2da2c37529cc
|
Provenance
The following attestation bundles were made for local_dir_rag-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on sualeh/local-dir-rag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
local_dir_rag-0.1.0.tar.gz -
Subject digest:
a28fb65161b2b897b000bd2e0efe106b42531ad70741a82b09aa05d63a7e293f - Sigstore transparency entry: 194220209
- Sigstore integration time:
-
Permalink:
sualeh/local-dir-rag@3b647c30d09192af3bbd3b1e16e130afaf031be5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sualeh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3b647c30d09192af3bbd3b1e16e130afaf031be5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file local_dir_rag-0.1.0-py3-none-any.whl.
File metadata
- Download URL: local_dir_rag-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a1ca8556d999517f15ed79c814b76613f515e042c10b09c46d280c83c16676c
|
|
| MD5 |
9c54e6b7fb3f18017047e58c4f8e095e
|
|
| BLAKE2b-256 |
7b19e18b6fd2e34b29204057cf9230e6492437f6ebe8c268897775adfb0ffd68
|
Provenance
The following attestation bundles were made for local_dir_rag-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on sualeh/local-dir-rag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
local_dir_rag-0.1.0-py3-none-any.whl -
Subject digest:
0a1ca8556d999517f15ed79c814b76613f515e042c10b09c46d280c83c16676c - Sigstore transparency entry: 194220212
- Sigstore integration time:
-
Permalink:
sualeh/local-dir-rag@3b647c30d09192af3bbd3b1e16e130afaf031be5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sualeh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3b647c30d09192af3bbd3b1e16e130afaf031be5 -
Trigger Event:
push
-
Statement type: