Skip to main content

zk-rag is a command-line chat tool for your zettelkasten

Project description

Query your Zettelkasten

This is a simple implementation of Retrieval Augmented Generation (RAG) for your Zettelkasten. It breaks your markdown documents into chunks, and uses a cosine-distance query to place relevant text chunks from your Zettelkasten into an LLM chat context in order to answer your questions.

It uses chromadb for a vector database (indexing the chunks, and doing distance queries for chunk selection) and ollama in order to generate the responses.

This project has many limitations, it is simply a starting point upon which I am building a larger system. Treat it like an example project, and build your own work on top of it.

Limitations

  • chat history grows but no safeguards exist to prevent it from growing beyond the LLM's context window
  • requires tweaking python code to run on your system
  • command-line only

That said, it includes all of the critical elements for doing RAG queries across a document base.

Requirements

You must have ollama installed and functional.

You must have a local knowledgebase / zettelkasten with content in markdown format. I use Obsidian, because I favour working locally, and I favour using the markdown format for notes - because everything's local, and in plain text, I can simply point this tool at a Vault folder.

Workstation setup

I recommend you setting up a local virtual Python environment, to keep it clean.

python3 -mvenv .venv
source .venv/bin/activate
pip install -r requirements.txt

Adjust settings.py to point to your Zettelkasten directory, and the model you want to use in your ollama installation. Use ollama list to check which ones you have set up.

Run python zk_reindex.py to re-index the contents of your zettelkasten.

Run python zk_query.py to query your Zettelkasten. Note that this is not a true chat, it will not take into account the history of your queries, every query is answered as a stand-alone question. Press enter (blank line) to exit the query loop.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zk_rag-1.0.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zk_rag-1.0.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file zk_rag-1.0.2.tar.gz.

File metadata

  • Download URL: zk_rag-1.0.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for zk_rag-1.0.2.tar.gz
Algorithm Hash digest
SHA256 170a77defb6ebcd1b134fc808f36c4e5be585b335615541d70db2c84ca7b7372
MD5 4a2ac168491d478f7eee002474c19d87
BLAKE2b-256 adc86e624a9e1868faf4a805e3578edd563c06f3276b9499f14a383b5b7738f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for zk_rag-1.0.2.tar.gz:

Publisher: python-publish.yml on svetzal/zk-rag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zk_rag-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: zk_rag-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for zk_rag-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a7b925e063ff739df587828bf1c5b2d48c914209cd5d7a43038867f1a5c9e5ff
MD5 a0123c4d99fa880def82c2d1ff53afd3
BLAKE2b-256 55d66efa41a3b88feb1a54cf629111d0e1ddd66f1b5d873a10b245c022f2b92c

See more details on using hashes here.

Provenance

The following attestation bundles were made for zk_rag-1.0.2-py3-none-any.whl:

Publisher: python-publish.yml on svetzal/zk-rag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page