2023-01-04 19:50:51 +01:00
# Khoj Obsidian 🦅
> Natural language search for your Obsidian notes using [Khoj](https://github.com/debanjum/khoj)
## Table of Contents
- [Features ](#Features )
- [Demo ](#Demo )
2023-04-07 18:13:38 +02:00
- [Search Demo ](#Search-Demo )
- [Interfaces ](#Interfaces )
- [Search Modal ](#Search-Modal )
- [Chat Modal ](#Chat-Modal )
2023-01-04 19:50:51 +01:00
- [Setup ](#Setup )
- [Setup Backend ](#1-Setup-Backend )
- [Setup Plugin ](#2-Setup-Plugin )
- [Use ](#Use )
2023-01-18 04:03:13 +01:00
- [Search ](#search )
2023-03-29 19:32:24 +02:00
- [Chat ](#chat )
2023-01-18 04:03:13 +01:00
- [Find Similar Notes ](#find-similar-notes )
2023-01-04 19:50:51 +01:00
- [Upgrade ](#Upgrade )
- [Upgrade Backend ](#1-Upgrade-Backend )
- [Upgrade Plugin ](#2-Upgrade-Plugin )
- [Troubleshoot ](#Troubleshoot )
2023-01-15 17:51:35 +01:00
- [Visualize Codebase ](#Visualize-Codebase )
2023-01-04 19:50:51 +01:00
- [Implementation ](#Implementation )
## Features
2023-03-29 19:32:24 +02:00
- **Search**
- **Natural**: Advanced natural language understanding using Transformer based ML Models
- **Local**: Your personal data stays local. All search and indexing is done on your machine. *Unlike chat which requires access to GPT.*
- **Incremental**: Incremental search for a fast, search-as-you-type experience
- **Chat**
- **Faster answers**: Find answers faster and with less effort than search
- **Iterative discovery**: Iteratively explore and (re-)discover your notes
- **Assisted creativity**: Smoothly weave across answers retrieval and content generation
2023-01-04 19:50:51 +01:00
## Demo
2023-04-07 18:13:38 +02:00
### Search Demo
2023-01-04 19:50:51 +01:00
https://user-images.githubusercontent.com/6413477/210486007-36ee3407-e6aa-4185-8a26-b0bfc0a4344f.mp4
2023-01-12 04:12:04 +01:00
< details > < summary > Description< / summary >
2023-01-04 19:50:51 +01:00
1. Install Khoj via `pip` and start Khoj backend in non-gui mode
2. Install Khoj plugin via Community Plugins settings pane on Obsidian app
3. Check the new Khoj plugin settings
2023-01-12 04:12:04 +01:00
4. Wait for Khoj backend to index markdown files in the current Vault
2023-01-04 19:50:51 +01:00
5. Open Khoj plugin on Obsidian via Search button on Left Pane
6. Search \"*Announce plugin to folks*\" in the [Obsidian Plugin docs ](https://marcus.se.net/obsidian-plugin-docs/ )
7. Jump to the [search result ](https://marcus.se.net/obsidian-plugin-docs/publishing/submit-your-plugin )
2023-01-12 04:12:04 +01:00
< / details >
2023-04-07 18:13:38 +02:00
## Interfaces
### Search Modal
2023-01-17 17:58:06 +01:00
![](https://github.com/debanjum/khoj/blob/master/src/interface/obsidian/docs/khoj_on_obsidian_0.2.5.png?)
2023-01-04 19:50:51 +01:00
2023-04-07 18:13:38 +02:00
### Chat Modal
![](https://github.com/debanjum/khoj/blob/master/src/interface/obsidian/docs/khoj_chat_on_obsidian_0.6.0.png?)
2023-01-04 19:50:51 +01:00
## Setup
2023-03-20 22:18:19 +01:00
- *Make sure [python ](https://realpython.com/installing-python/ ) (version 3.10 or lower) and [pip ](https://pip.pypa.io/en/stable/installation/ ) are installed on your machine*
2023-02-12 14:29:14 +01:00
- *Ensure you follow the ordering of the setup steps. Install the plugin after starting the khoj backend. This allows the plugin to configure the khoj backend*
2023-01-04 19:50:51 +01:00
2023-02-06 23:38:20 +01:00
### 1. Setup Backend
2023-02-12 14:29:14 +01:00
Open terminal/cmd and run below command to install and start the khoj backend
2023-04-16 15:17:20 +02:00
- On Linux/MacOS
```shell
python -m pip install khoj-assistant & & khoj --no-gui
```
- On Windows
```shell
py -m pip install khoj-assistant & & khoj --no-gui
```
2023-01-12 05:17:52 +01:00
### 2. Setup Plugin
2023-01-28 00:01:31 +01:00
1. Open [Khoj ](https://obsidian.md/plugins?id=khoj ) from the *Community plugins* tab in Obsidian settings panel
2. Click *Install* , then *Enable* on the Khoj plugin page in Obsidian
2023-03-29 19:32:24 +02:00
3. [Optional] To enable Khoj Chat, set your [OpenAI API key ](https://platform.openai.com/account/api-keys ) in the Khoj plugin settings
2023-01-04 19:50:51 +01:00
2023-02-10 18:11:21 +01:00
See [official Obsidian plugin docs ](https://help.obsidian.md/Extending+Obsidian/Community+plugins ) for details
2023-01-04 19:50:51 +01:00
## Use
2023-03-29 19:32:24 +02:00
### Chat
2023-03-29 21:46:59 +02:00
Run *Khoj: Chat* from the [Command Palette ](https://help.obsidian.md/Plugins/Command+palette ) and ask questions in a natural, conversational style.< br />
2023-03-29 19:32:24 +02:00
E.g "When did I file my taxes last year?"
Notes:
- *Using Khoj Chat will result in query relevant notes being shared with OpenAI for ChatGPT to respond.*
- *To use Khoj Chat, ensure you've set your [OpenAI API key ](https://platform.openai.com/account/api-keys ) in the Khoj plugin settings.*
2023-03-29 21:46:59 +02:00
See [Khoj Chat ](https://github.com/debanjum/khoj/tree/master/#Khoj-Chat ) for more details
![](https://github.com/debanjum/khoj/blob/master/src/interface/obsidian/docs/khoj_chat_on_obsidian_0.6.0.png?)
2023-03-29 19:32:24 +02:00
2023-01-18 04:03:13 +01:00
### Search
Click the *Khoj search* icon 🔎 on the [Ribbon ](https://help.obsidian.md/User+interface/Workspace/Ribbon ) or run *Khoj: Search* from the [Command Palette ](https://help.obsidian.md/Plugins/Command+palette )
2023-01-04 19:50:51 +01:00
2023-02-06 23:38:20 +01:00
*Note: Ensure the khoj server is running in the background before searching. Execute `khoj --no-gui` in your terminal if it is not already running*
2023-02-14 17:43:50 +01:00
https://user-images.githubusercontent.com/6413477/218801155-cd67e8b4-a770-404a-8179-d6b61caa0f93.mp4
2023-01-12 04:12:04 +01:00
< details > < summary > Query Filters< / summary >
2023-01-04 19:50:51 +01:00
Use structured query syntax to filter the natural language search results
- **Word Filter**: Get entries that include/exclude a specified term
- Entries that contain term_to_include: `+"term_to_include"`
- Entries that contain term_to_exclude: `-"term_to_exclude"`
- **Date Filter**: Get entries containing dates in YYYY-MM-DD format from specified date (range)
- Entries from April 1st 1984: `dt:"1984-04-01"`
- Entries after March 31st 1984: `dt>="1984-04-01"`
- Entries before April 2nd 1984 : `dt<="1984-04-01"`
- **File Filter**: Get entries from a specified file
- Entries from incoming.org file: `file:"incoming.org"`
- Combined Example
- `what is the meaning of life? file:"1984.org" dt>="1984-01-01" dt<="1985-01-01" -"big" -"brother"`
- Adds all filters to the natural language query. It should return entries
- from the file *1984.org*
- containing dates from the year *1984*
- excluding words *"big"* and *"brother"*
- that best match the natural language query *"what is the meaning of life?"*
2023-01-12 04:12:04 +01:00
< / details >
2023-01-18 04:03:13 +01:00
### Find Similar Notes
To see other notes similar to the current one, run *Khoj: Find Similar Notes* from the [Command Palette ](https://help.obsidian.md/Plugins/Command+palette )
2023-01-04 19:50:51 +01:00
## Upgrade
### 1. Upgrade Backend
```shell
pip install --upgrade khoj-assistant
```
### 2. Upgrade Plugin
1. Open *Community plugins* tab in Obsidian settings
2. Click the *Check for updates* button
3. Click the *Update* button next to Khoj, if available
## Troubleshooting
2023-01-18 04:22:26 +01:00
- Open the Khoj plugin settings pane, to configure Khoj
- Toggle Enable/Disable Khoj, if setting changes have not applied
- Click *Update* button to force index to refresh, if results are failing or stale
2023-01-12 04:12:04 +01:00
## Current Limitations
2023-01-18 04:22:26 +01:00
- The plugin loads the index of only one vault at a time.< br />
So notes across multiple vaults **cannot** be searched at the same time
2023-01-04 19:50:51 +01:00
2023-01-15 17:51:35 +01:00
## Visualize Codebase
< img src = "https://github.com/debanjum/khoj/blob/master/src/interface/obsidian/docs/khoj_obsidian_codebase_visualization_0.2.1.png" width = "700" / >
2023-01-04 19:50:51 +01:00
## Implementation
The plugin implements the following functionality to search your notes with Khoj:
- [X] Open the Khoj search modal via left ribbon icon or the *Khoj: Search* command
- [X] Render results as Markdown preview to improve readability
- [X] Configure Khoj via the plugin setting tab on the settings page
- Set Obsidian Vault to Index with Khoj. Defaults to all markdown files in current Vault
- Set URL of Khoj backend
- Set Number of Search Results to show in Search Modal
2023-01-18 04:22:26 +01:00
- [X] Allow reranking of result to improve search quality
- [X] Allow Finding notes similar to current note being viewed