From 59ffd1dc949d702b55503efcefd8fa2581611f2f Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 28 Aug 2023 10:43:17 -0700 Subject: [PATCH] Document slash command and query filter in docs for chat and search --- docs/advanced.md | 21 +++++++++++++++++++++ docs/chat.md | 14 ++++++++++++-- docs/search.md | 31 +++++-------------------------- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index 9b47a373..a567783f 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -58,3 +58,24 @@ Note: *Only search can currently run in fully offline mode, not chat.* - Without Internet 1. Copy each of the search models into their respective folders, `asymmetric`, `symmetric` and `image` under the `~/.khoj/search/` directory on the air-gapped machine 2. Copy the khoj virtual environment directory onto the air-gapped machine, activate the environment and start and khoj as normal. E.g `source .venv/bin/activate && khoj` + +### Query Filters + +Use structured query syntax to filter entries from your knowledge based used by search results or chat responses. + +- **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?"* diff --git a/docs/chat.md b/docs/chat.md index fa632b2a..eb3a2f0f 100644 --- a/docs/chat.md +++ b/docs/chat.md @@ -27,11 +27,21 @@ Online chat requires internet to use ChatGPT but is faster, higher quality and l ### Use -1. Open [/chat](http://localhost:42110/chat) -2. Type your queries and see Khoj respond using your notes as reference +1. Open Khoj Chat + - **On Web**: Open [/chat](http://localhost:42110/chat) in your web browser + - **On Obsidian**: Search for *Khoj: Chat* in the [Command Palette](https://help.obsidian.md/Plugins/Command+palette) + - **On Emacs**: Run `M-x khoj ` +2. Enter your queries to chat with Khoj. Use [slash commands](#commands) and [query filters](./advanced.md#query-filters) to change what Khoj uses to respond ![](./assets/khoj_chat_on_web.png ':size=400px') #### Details 1. Your query is used to retrieve the most relevant notes, if any, using Khoj search 2. These notes, the last few messages and associated metadata is passed to the enabled chat model along with your query to generate a response + +#### Commands +Slash commands allows you to change what Khoj uses to respond to your query +- **/notes**: Limit chat to only respond using your notes, not just Khoj's general world knowledge as reference +- **/general**: Limit chat to only respond using Khoj's general world knowledge, not using your notes as reference +- **/default**: Allow chat to respond using your notes or it's general knowledge as reference. It's the default behavior when no slash command is used +- **/help**: Use /help to get all available commands and general information about Khoj diff --git a/docs/search.md b/docs/search.md index 1132cfdb..579034ec 100644 --- a/docs/search.md +++ b/docs/search.md @@ -1,31 +1,10 @@ ## Khoj Search ### Use -- **From Web** - - Open in your web browser -- **From Obsidian** - - Click the *Khoj search* icon 🔎 on the [Ribbon](https://help.obsidian.md/User+interface/Workspace/Ribbon) or Search for *Khoj: Search* in the [Command Palette](https://help.obsidian.md/Plugins/Command+palette) -- **From Emacs** - - Run `M-x khoj ` +1. Open Khoj Search + - **On Web**: Open in your web browser + - **On Obsidian**: Click the *Khoj search* icon 🔎 on the [Ribbon](https://help.obsidian.md/User+interface/Workspace/Ribbon) or Search for *Khoj: Search* in the [Command Palette](https://help.obsidian.md/Plugins/Command+palette) + - **On Emacs**: Run `M-x khoj ` +2. Query using natural language to find relevant entries from your knowledge base. Use [query filters](./advanced.md#query-filters) to limit entries to search ### Demo ![](./assets/khoj_search_on_web.png ':size=400px') - -### Query Filters - -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?"*