Update khoj.el docs and Emacs Readme for chat, simplified setup

This commit is contained in:
Debanjum Singh Solanky 2023-03-27 20:47:08 +07:00
parent 87090531da
commit fc218508f9
2 changed files with 84 additions and 44 deletions

View file

@ -1,16 +1,19 @@
* Khoj Emacs 🦅 * Khoj Emacs 🦅
[[https://stable.melpa.org/#/khoj][file:https://stable.melpa.org/packages/khoj-badge.svg]] [[https://melpa.org/#/khoj][file:https://melpa.org/packages/khoj-badge.svg]] [[https://github.com/debanjum/khoj/actions/workflows/build_khoj_el.yml][https://github.com/debanjum/khoj/actions/workflows/build_khoj_el.yml/badge.svg?]] [[https://github.com/debanjum/khoj/actions/workflows/test_khoj_el.yml][https://github.com/debanjum/khoj/actions/workflows/test_khoj_el.yml/badge.svg?]] [[https://stable.melpa.org/#/khoj][file:https://stable.melpa.org/packages/khoj-badge.svg]] [[https://melpa.org/#/khoj][file:https://melpa.org/packages/khoj-badge.svg]] [[https://github.com/debanjum/khoj/actions/workflows/build_khoj_el.yml][https://github.com/debanjum/khoj/actions/workflows/build_khoj_el.yml/badge.svg?]] [[https://github.com/debanjum/khoj/actions/workflows/test_khoj_el.yml][https://github.com/debanjum/khoj/actions/workflows/test_khoj_el.yml/badge.svg?]]
/Natural, Incremental Search for your Second Brain/ /A search assistant for your second brain/
** Table of Contents ** Table of Contents
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#features][Features]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#features][Features]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Interface][Interface]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Interface][Interface]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Setup][Setup]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Setup][Setup]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#1-Setup-Backend][Setup Backend]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Direct-Install][Direct Install]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#2-Install-Khojel][Install Khoj.el]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Minimal-Install][Minimal Install]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Standard-Install][Standard Install]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#With-Straight.el][With Straight.el]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Use][Use]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Use][Use]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Search][Search]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Search][Search]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Chat][Chat]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Find-similar-entries][Find Similar Entries]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Find-similar-entries][Find Similar Entries]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Advanced-usage][Advanced Usage]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Advanced-usage][Advanced Usage]]
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Khoj-menu][Khoj Menu]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Khoj-menu][Khoj Menu]]
@ -19,49 +22,74 @@
- [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Upgrade-Khojel][Upgrade Khoj.el]] - [[https://github.com/debanjum/khoj/tree/master/src/interface/emacs#Upgrade-Khojel][Upgrade Khoj.el]]
** Features ** Features
- *Natural*: Advanced natural language understanding using Transformer based ML Models - *Search*
- *Local*: Your personal data stays local. All search, indexing is done on your machine* - *Natural*: Advanced natural language understanding using Transformer based ML Models
- *Incremental*: Incremental search for a fast, search-as-you-type experience - *Local*: Your personal data stays local. All search, indexing is done on your machine*
- *Incremental*: Incremental search for a fast, search-as-you-type experience
- *Chat*
- *Faster answers*: Find answers faster than search
- *Iterative discovery*: Iteratively explore and (re-)discover your notes
- *Assisted creativity*: Smoothly weave across answer retrieval and content generation
** Interface ** Interface
[[/docs/khoj_on_emacs.png]] [[/docs/khoj_on_emacs.png]]
** Setup ** Setup
/Make sure [[https://realpython.com/installing-python/][python]] (version 3.10 or lower) and [[https://pip.pypa.io/en/stable/installation/][pip]] are installed on your machine/ - /Make sure [[https://realpython.com/installing-python/][python]] (version 3.10 or lower) and [[https://pip.pypa.io/en/stable/installation/][pip]] are installed on your machine/
*** 1. Setup Backend - /khoj.el attempts to automatically install, start and configure the khoj server./
#+begin_src shell If this fails, follow [[https://github.com/debanjum/khoj/tree/master/#Setup][these instructions]] to manually setup the khoj server.
pip install khoj-assistant && khoj
#+end_src
*** 2. Install Khoj.el *** Direct Install
**** Using MELPA #+begin_src elisp
#+begin_src elisp
M-x package-install khoj M-x package-install khoj
#+end_src elisp #+end_src
Add below snippet to your Emacs config file *** Minimal Install
#+begin_src elisp Add below snippet to your Emacs config file.
;; Install Khoj Package from MELPA Stable Indexes your org-agenda files, by default.
(use-package khoj
:ensure t
:pin melpa-stable
:bind ("C-c s" . 'khoj))
#+end_src
Note: Install ~khoj.el~ from MELPA (instead of MELPA Stable) if you installed the pre-release version of khoj #+begin_src elisp
- That is, use ~:pin melpa~ to install khoj.el in above snippet if khoj was installed with ~pip install --pre khoj-assistant~ ;; Install Khoj Package from MELPA Stable
- Else use ~:pin melpa-stable~ to install khoj.el in above snippet if khoj was installed with ~pip install khoj-assistant~ (use-package khoj
- This ensures both khoj.el and khoj app are from the same version (tagged or latest) :ensure t
:pin melpa-stable
:bind ("C-c s" . 'khoj)
#+end_src
- Note: Install ~khoj.el~ from MELPA (instead of MELPA Stable) if you installed the pre-release version of khoj
- That is, use ~:pin melpa~ to install khoj.el in above snippet if khoj server was installed with ~--pre~ flag, i.e ~pip install --pre khoj-assistant~
- Else use ~:pin melpa-stable~ to install khoj.el in above snippet if khoj was installed with ~pip install khoj-assistant~
- This ensures both khoj.el and khoj app are from the same version (git tagged or latest)
*** Standard Install
Add below snippet to your Emacs config file.
Indexes the specified org files, directories. Sets up OpenAI API key for Khoj Chat
#+begin_src elisp
;; Install Khoj Package from MELPA Stable
(use-package khoj
:ensure t
:pin melpa-stable
:bind ("C-c s" . 'khoj)
:config (setq khoj-org-directories '("~/docs/org-roam" "~/docs/notes")
khoj-org-files '("~/docs/todo.org" "~/docs/work.org")
khoj-openai-api-key "YOUR_OPENAI_API_KEY")) ; required to enable chat
#+end_src
*** With [[https://github.com/raxod502/straight.el][Straight.el]]
Add below snippet to your Emacs config file.
Indexes the specified org files, directories. Sets up OpenAI API key for Khoj Chat
**** Using [[https://github.com/raxod502/straight.el][Straight.el]]
Add below snippet to your Emacs config file
#+begin_src elisp #+begin_src elisp
;; Install Khoj Package using Straight.el ;; Install Khoj Package using Straight.el
(use-package khoj (use-package khoj
:after org :after org
:straight (khoj :type git :host github :repo "debanjum/khoj" :files (:defaults "src/interface/emacs/khoj.el")) :straight (khoj :type git :host github :repo "debanjum/khoj" :files (:defaults "src/interface/emacs/khoj.el"))
:bind ("C-c s" . 'khoj)) :bind ("C-c s" . 'khoj)
:config (setq khoj-org-directories '("~/docs/org-roam" "~/docs/notes")
khoj-org-files '("~/docs/todo.org" "~/docs/work.org")
khoj-openai-api-key "YOUR_OPENAI_API_KEY" ; required to enable chat)
#+end_src #+end_src
** Use ** Use
@ -72,6 +100,15 @@
e.g "What is the meaning of life?", "My life goals for 2023" e.g "What is the meaning of life?", "My life goals for 2023"
*** Chat
1. Hit ~C-c s c~ (or ~M-x khoj RET c~) to open khoj chat
2. Ask questions in a natural, conversational style
E.g "When did I file my taxes last year?"
See [[https://github.com/debanjum/khoj/tree/master/#Khoj-Chat][Khoj Chat]] for more details
*** Find Similar Entries *** Find Similar Entries
This feature finds entries similar to the one you are currently on. This feature finds entries similar to the one you are currently on.
1. Move cursor to the org-mode entry, markdown section or text paragraph you want to find similar entries for 1. Move cursor to the org-mode entry, markdown section or text paragraph you want to find similar entries for

View file

@ -1,10 +1,10 @@
;;; khoj.el --- Natural, Incremental Search for your Second Brain -*- lexical-binding: t -*- ;;; khoj.el --- A search assistant for your second brain -*- lexical-binding: t -*-
;; Copyright (C) 2021-2022 Debanjum Singh Solanky ;; Copyright (C) 2021-2022 Debanjum Singh Solanky
;; Author: Debanjum Singh Solanky <debanjum@gmail.com> ;; Author: Debanjum Singh Solanky <debanjum@gmail.com>
;; Description: Natural, Incremental Search for your Second Brain ;; Description: A search assistant for your second brain
;; Keywords: search, org-mode, outlines, markdown, beancount, ledger, image ;; Keywords: search, chat, org-mode, outlines, markdown, beancount, image
;; Version: 0.4.1 ;; Version: 0.4.1
;; Package-Requires: ((emacs "27.1") (transient "0.3.0") (dash "2.19.1")) ;; Package-Requires: ((emacs "27.1") (transient "0.3.0") (dash "2.19.1"))
;; URL: https://github.com/debanjum/khoj/tree/master/src/interface/emacs ;; URL: https://github.com/debanjum/khoj/tree/master/src/interface/emacs
@ -28,21 +28,24 @@
;;; Commentary: ;;; Commentary:
;; This package provides a natural, incremental search interface to your ;; Create a search assistant for your `org-mode', `markdown' notes,
;; `org-mode' notes, `markdown' files, `beancount' transactions and images. ;; `beancount' transactions and images. This package exposes two
;; It is a wrapper that interfaces with the Khoj server. ;; assistance modes, search and chat:
;; The server exposes an API for advanced search using transformer ML models. ;;
;; The Khoj server needs to be running to use this package. ;; Chat provides faster answers, iterative discovery and assisted
;; See the repository docs for detailed setup of the Khoj server. ;; creativity. It requires your OpenAI API key to access GPT models
;;
;; Search allows natural language, incremental and local search.
;; It relies on AI models that run locally on your machine.
;; ;;
;; Quickstart ;; Quickstart
;; ------------- ;; -------------
;; 1. Install Khoj Server ;; 1. Install khoj.el from MELPA Stable
;; pip install khoj-assistant
;; 2. Start, Configure Khoj Server
;; khoj
;; 3. Install khoj.el from MELPA Stable
;; (use-package khoj :pin melpa-stable :bind ("C-c s" . 'khoj)) ;; (use-package khoj :pin melpa-stable :bind ("C-c s" . 'khoj))
;; 2. Start khoj from Emacs
;; C-c s or M-x khoj
;;
;; See the repository docs for detailed setup and configuration steps.
;;; Code: ;;; Code: