From 3386cc92b5600ef42fec9fc9dbae70e278f658be Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 3 May 2023 15:01:58 +0800 Subject: [PATCH] Fix khoj server config update in khoj.el by unquoting list to cl-push to - cl-push expects a generatlized variable. Else throws (setf quote) undefined warning - This results in the config call failing on calling khoj entrypoint --- src/interface/emacs/khoj.el | 56 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index 0ddc6c45..8857b9e6 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -387,11 +387,11 @@ CONFIG is json obtained from Khoj config API." (message "khoj.el: Server not configured yet.") (setq config (delq (assoc 'content-type config) config)) (cl-pushnew `(content-type . ((org . ((input-files . ,khoj-org-files) - (input-filter . ,org-directory-regexes) - (compressed-jsonl . ,(format "%s/org.jsonl.gz" default-index-dir)) - (embeddings-file . ,(format "%s/org.pt" default-index-dir)) - (index-heading-entries . ,json-false))))) - 'config)) + (input-filter . ,org-directory-regexes) + (compressed-jsonl . ,(format "%s/org.jsonl.gz" default-index-dir)) + (embeddings-file . ,(format "%s/org.pt" default-index-dir)) + (index-heading-entries . ,json-false))))) + config)) ;; Else if khoj config has no org content config ((not (alist-get 'org (alist-get 'content-type config))) @@ -399,13 +399,13 @@ CONFIG is json obtained from Khoj config API." (let ((new-content-type (alist-get 'content-type config))) (setq new-content-type (delq (assoc 'org new-content-type) new-content-type)) (cl-pushnew `(org . ((input-files . ,khoj-org-files) - (input-filter . ,org-directory-regexes) - (compressed-jsonl . ,(format "%s/org.jsonl.gz" default-index-dir)) - (embeddings-file . ,(format "%s/org.pt" default-index-dir)) - (index-heading-entries . ,json-false))) - 'new-content-type) + (input-filter . ,org-directory-regexes) + (compressed-jsonl . ,(format "%s/org.jsonl.gz" default-index-dir)) + (embeddings-file . ,(format "%s/org.pt" default-index-dir)) + (index-heading-entries . ,json-false))) + new-content-type) (setq config (delq (assoc 'content-type config) config)) - (cl-pushnew `(content-type . ,new-content-type) 'config))) + (cl-pushnew `(content-type . ,new-content-type) config))) ;; Else if khoj is not configured to index specified org files ((not (and (equal (alist-get 'input-files (alist-get 'org (alist-get 'content-type config))) khoj-org-files) @@ -415,13 +415,13 @@ CONFIG is json obtained from Khoj config API." (new-content-type (alist-get 'content-type config))) (setq new-content-type (delq (assoc 'org new-content-type) new-content-type)) (cl-pushnew `(org . ((input-files . ,khoj-org-files) - (input-filter . ,org-directory-regexes) - (compressed-jsonl . ,(format "%s/org.jsonl.gz" index-directory)) - (embeddings-file . ,(format "%s/org.pt" index-directory)) - (index-heading-entries . ,json-false))) - 'new-content-type) + (input-filter . ,org-directory-regexes) + (compressed-jsonl . ,(format "%s/org.jsonl.gz" index-directory)) + (embeddings-file . ,(format "%s/org.pt" index-directory)) + (index-heading-entries . ,json-false))) + new-content-type) (setq config (delq (assoc 'content-type config) config)) - (cl-pushnew `(content-type . ,new-content-type) 'config)))) + (cl-pushnew `(content-type . ,new-content-type) config)))) ;; Configure processors (cond @@ -432,20 +432,20 @@ CONFIG is json obtained from Khoj config API." (message "khoj.el: Chat not configured yet.") (setq config (delq (assoc 'processor config) config)) (cl-pushnew `(processor . ((conversation . ((conversation-logfile . ,(format "%s/conversation.json" default-chat-dir)) - (model . ,default-model) - (openai-api-key . ,khoj-openai-api-key))))) - 'config)) + (model . ,default-model) + (openai-api-key . ,khoj-openai-api-key))))) + config)) ((not (alist-get 'conversation (alist-get 'processor config))) (message "khoj.el: Chat not configured yet.") (let ((new-processor-type (alist-get 'processor config))) (setq new-processor-type (delq (assoc 'conversation new-processor-type) new-processor-type)) (cl-pushnew `(conversation . ((conversation-logfile . ,(format "%s/conversation.json" default-chat-dir)) - (model . ,default-model) - (openai-api-key . ,khoj-openai-api-key))) - 'new-processor-type) + (model . ,default-model) + (openai-api-key . ,khoj-openai-api-key))) + new-processor-type) (setq config (delq (assoc 'processor config) config)) - (cl-pushnew `(processor . ,new-processor-type) 'config))) + (cl-pushnew `(processor . ,new-processor-type) config))) ;; Else if khoj is not configured with specified openai api key ((not (equal (alist-get 'openai-api-key (alist-get 'conversation (alist-get 'processor config))) khoj-openai-api-key)) @@ -455,11 +455,11 @@ CONFIG is json obtained from Khoj config API." (new-processor-type (alist-get 'processor config))) (setq new-processor-type (delq (assoc 'conversation new-processor-type) new-processor-type)) (cl-pushnew `(conversation . ((conversation-logfile . ,(format "%s/conversation.json" chat-directory)) - (model . ,model-name) - (openai-api-key . ,khoj-openai-api-key))) - 'new-processor-type) + (model . ,model-name) + (openai-api-key . ,khoj-openai-api-key))) + new-processor-type) (setq config (delq (assoc 'processor config) config)) - (cl-pushnew `(processor . ,new-processor-type) 'config)))) + (cl-pushnew `(processor . ,new-processor-type) config)))) ;; Update server with latest configuration, if required (cond ((not current-config)