Skip to main content

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

Project description

💬 Chat With Your Zettelkasten

This is a simple tool that lets you chat with a local "AI" that has access to the documents in your Zettelkasten. It will index your markdown documents, and in your chat session it may choose to query your content, retrieve excerpts, read entire documents, and generate responses based on the content in your Zettelkasten.

For "AI" it communicates with a local running instance of Ollama. Ollama must be installed and running for zkchat to function.

✨ Features

  • Command-line interface for quick access
  • Graphical user interface for a more user-friendly experience
  • RAG queries across your document base
  • Interactive chat with context from your Zettelkasten
  • Configurable LLM model selection
  • Easy Zettelkasten folder configuration

🛠️ Tools

The chat interface provides access to several tools that enhance its capabilities:

  • Document Search Tools

    • Find Documents: Locates relevant documents in your Zettelkasten based on your query
    • Find Excerpts: Retrieves specific passages from your documents that match your search criteria
    • Read Document: Accesses the full content of a specific document in your Zettelkasten
    • Write Document: Creates or updates documents in your Zettelkasten (requires --unsafe flag)
  • Smart Memory Tools

    • Store Information: Saves important facts and context from conversations for future reference
    • Retrieve Information: Recalls previously stored information to provide more personalized responses
  • Git Integration Tools

    • View Uncommitted Changes: Shows pending changes in your Zettelkasten vault
    • Commit Changes: Commits changes with AI-generated commit messages
  • Available Tool Plugins

    • zk-rag-wikipedia: A plugin for looking up information on Wikipedia and creating documents from the results

🔧 Requirements

You must have ollama installed and running.

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

Right now, while this tool should run on Windows, we've only written instructions for Mac.

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

Setting up a local environment, and activating it (recommended):

cd $HOME
python3 -mvenv .venv
source .venv/bin/activate

Installing the zk-rag module from PyPi:

pip install zk-rag

Optionally install tool plugins from PyPi:

pip install zk-rag-wikipedia

Alternative: Using pipx (recommended for end-users)

pipx is a tool that allows you to install and run Python applications in isolated environments. It's ideal for end-user applications like zk-rag, as it keeps the application and its dependencies isolated from your system Python and other applications.

Installing pipx:

# On macOS
brew install pipx
pipx ensurepath

# On Linux
python3 -m pip install --user pipx
python3 -m pipx ensurepath

Installing zk-rag with pipx:

pipx install zk-rag

Installing plugins with pipx inject:

# Install the Wikipedia plugin
pipx inject zk-rag zk-rag-wikipedia

The benefit of using pipx is that it creates isolated environments for each application, avoiding dependency conflicts while still making the commands globally available.

Setting up Ollama and installing a local model:

brew install ollama
ollama pull qwen2.5:14b

🚀 Usage

📟 Command-line Interface

Run zkchat --vault /path/to/vault to start the command-line interface.

Command-line options:

  • --vault PATH: Specify the path to your Zettelkasten vault (required if no bookmarks are set)
  • --bookmark NAME: Use a bookmarked vault path instead of specifying the path directly
  • --add-bookmark NAME PATH: Add a new bookmark for a vault path
  • --remove-bookmark NAME: Remove a bookmarked vault path
  • --list-bookmarks: List all bookmarked vault paths
  • --model [model_name]: Change the LLM model to use for chat
    • With model name: zkchat --vault /path/to/vault --model llama2 - configure to use specified model
    • Without model name: zkchat --vault /path/to/vault --model - interactively select from available models
  • --reindex: Reindex the Zettelkasten vault, will attempt to do so incrementally
  • --full: Force full reindex (only used with --reindex)
  • --unsafe: Enable operations that can write to your Zettelkasten. This flag is required for using tools that modify your Zettelkasten content, such as the Write Document tool. Use with caution as it allows the AI to make changes to your files.
  • --reset-memory: Clear the smart memory storage
  • --git: Enable Git integration for version control of your Zettelkasten vault

🧠 Smart Memory

The tool includes a Smart Memory mechanism that allows the AI to store and retrieve information during conversations. This memory:

  • Persists between chat sessions
  • Uses vector embeddings for semantic similarity search
  • Enables the AI to recall previous context and information
  • Can be cleared using the --reset-memory CLI option

🖥️ Graphical Interface (Experimental)

The GUI is experimental and may not work as expected. It is provided as a preview feature only.

Note: The GUI has not yet been updated to use the new command-line vault path configuration. It still uses the old method of storing the configuration file in the user's home directory.

Run zkchat-gui to start the graphical interface. The GUI provides:

  • A multi-line chat input for composing messages
  • A scrollable chat history showing the entire conversation
  • A resizable divider between chat history and input areas
  • Settings menu (accessible via Settings -> Configure...) for:
    • Selecting the LLM model from available Ollama models
    • Configuring the Zettelkasten folder location
  • Asynchronous chat responses that keep the interface responsive

When first run, both zkchat and zkchat-gui will need initial configuration:

For the command-line interface:

  • You must provide the path to your Zettelkasten vault using the --vault argument
  • You'll be prompted to select an LLM model from your Ollama installation (or you can specify it with --model)

For the GUI:

  • You can configure these settings through the Settings menu

After initial configuration, the tool will start a full index build of your Zettelkasten.

📁 Storage Location

The tool stores its configuration and database in your Zettelkasten vault:

  • .zk_chat - Configuration file stored in the vault root
  • .zk_chat_db/ - Chroma vector database folder stored in the vault root

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-2.2.0.tar.gz (35.8 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-2.2.0-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for zk_rag-2.2.0.tar.gz
Algorithm Hash digest
SHA256 5b9dc35579685832e982d52ecce42ded28c699755ec1a2973b5280ad3a3dfd13
MD5 695eb079708c62e20c838fc90a596744
BLAKE2b-256 3935933f52728fafbbc816f151d69a754e6ce01fb1656da6d430d82f0db23e3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for zk_rag-2.2.0.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-2.2.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for zk_rag-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75567a3d71a0d8519a2e36417c13ba2262b9309a93190e5a34582c7fca096aea
MD5 5166e32fbbb0e008a2854c30eb3a2e55
BLAKE2b-256 6b97a779d30669500def25d28eb2335d0216297ce1d70d265dd2dc8296535646

See more details on using hashes here.

Provenance

The following attestation bundles were made for zk_rag-2.2.0-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