Use khoj-incremental as the main khoj func. Rename khoj to khoj-simple

- Update khoj-simple to work cross-encoder re-ranked results like before
- Increment major version as incremental search considered a breaking
  change and a major update to search capability
This commit is contained in:
Debanjum Singh Solanky
2022-07-27 18:18:17 +04:00
parent 09727ac3be
commit 9302b45fe0

View File

@@ -1,9 +1,9 @@
;;; khoj.el --- Natural Search via Emacs ;;; khoj.el --- Natural, Incremental Search via Emacs
;; 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>
;; Version: 1.0 ;; Version: 2.0
;; Keywords: search, org-mode, outlines, markdown, image ;; Keywords: search, org-mode, outlines, markdown, image
;; URL: http://github.com/debanjum/khoj/interface/emacs ;; URL: http://github.com/debanjum/khoj/interface/emacs
@@ -26,10 +26,10 @@
;;; Commentary: ;;; Commentary:
;; This package provides natural language search on org-mode notes, ;; This package provides a natural, incremental search interface to your
;; markdown files, beancount transactions and images. ;; org-mode notes, markdown files, beancount transactions and images.
;; It is a wrapper that interfaces with transformer based ML models. ;; It is a wrapper that interfaces with transformer based ML models.
;; The models search capabilities are exposed via the Khoj HTTP API ;; The models search capabilities are exposed via the Khoj HTTP API.
;;; Code: ;;; Code:
@@ -184,7 +184,7 @@
(remove-hook 'minibuffer-exit-hook #'khoj--remove-incremental-query)) (remove-hook 'minibuffer-exit-hook #'khoj--remove-incremental-query))
;;;###autoload ;;;###autoload
(defun khoj-incremental () (defun khoj ()
"Natural, Incremental Search for your personal notes, transactions and music using Khoj" "Natural, Incremental Search for your personal notes, transactions and music using Khoj"
(interactive) (interactive)
(let* ((default-type (khoj--buffer-name-to-search-type (buffer-name))) (let* ((default-type (khoj--buffer-name-to-search-type (buffer-name)))
@@ -200,12 +200,13 @@
(read-string khoj--query-prompt)))) (read-string khoj--query-prompt))))
;;;###autoload ;;;###autoload
(defun khoj (query) (defun khoj-simple (query)
"Search your content naturally using the Khoj API" "Natural Search for your personal notes, transactions, music and images using Khoj"
(interactive "sQuery: ") (interactive "sQuery: ")
(let* ((default-type (khoj--buffer-name-to-search-type (buffer-name))) (let* ((rerank "true")
(default-type (khoj--buffer-name-to-search-type (buffer-name)))
(search-type (completing-read "Type: " '("org" "markdown" "ledger" "music" "image") nil t default-type)) (search-type (completing-read "Type: " '("org" "markdown" "ledger" "music" "image") nil t default-type))
(query-url (khoj--construct-api-query query search-type)) (query-url (khoj--construct-api-query query search-type rerank))
(buffer-name (get-buffer-create (format "*Khoj (q:%s t:%s)*" query search-type)))) (buffer-name (get-buffer-create (format "*Khoj (q:%s t:%s)*" query search-type))))
(khoj--query-api-and-render-results (khoj--query-api-and-render-results
query query