Use cl-pushnew to fix byte-compile errors with using add-to-list

This commit is contained in:
Debanjum Singh Solanky 2023-05-02 21:26:30 +08:00
parent f046523b33
commit 731ef5688f

View file

@ -386,25 +386,26 @@ CONFIG is json obtained from Khoj config API."
((not current-config)
(message "khoj.el: Server not configured yet.")
(setq config (delq (assoc 'content-type config) config))
(add-to-list 'config
`(content-type . ((org . ((input-files . ,khoj-org-files)
(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)))))))
(index-heading-entries . ,json-false)))))
'config))
;; Else if khoj config has no org content config
((not (alist-get 'org (alist-get 'content-type config)))
(message "khoj.el: Org-mode content on server not configured yet.")
(let ((new-content-type (alist-get 'content-type config)))
(setq new-content-type (delq (assoc 'org new-content-type) new-content-type))
(add-to-list 'new-content-type `(org . ((input-files . ,khoj-org-files)
(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))))
(index-heading-entries . ,json-false)))
'new-content-type)
(setq config (delq (assoc 'content-type config) config))
(add-to-list 'config `(content-type . ,new-content-type))))
(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)
@ -413,13 +414,14 @@ CONFIG is json obtained from Khoj config API."
(let* ((index-directory (khoj--get-directory-from-config config '(content-type org embeddings-file)))
(new-content-type (alist-get 'content-type config)))
(setq new-content-type (delq (assoc 'org new-content-type) new-content-type))
(add-to-list 'new-content-type `(org . ((input-files . ,khoj-org-files)
(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))))
(index-heading-entries . ,json-false)))
'new-content-type)
(setq config (delq (assoc 'content-type config) config))
(add-to-list 'config `(content-type . ,new-content-type)))))
(cl-pushnew `(content-type . ,new-content-type) 'config))))
;; Configure processors
(cond
@ -429,20 +431,21 @@ CONFIG is json obtained from Khoj config API."
((not current-config)
(message "khoj.el: Chat not configured yet.")
(setq config (delq (assoc 'processor config) config))
(add-to-list 'config
`(processor . ((conversation . ((conversation-logfile . ,(format "%s/conversation.json" default-chat-dir))
(cl-pushnew `(processor . ((conversation . ((conversation-logfile . ,(format "%s/conversation.json" default-chat-dir))
(model . ,default-model)
(openai-api-key . ,khoj-openai-api-key)))))))
(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))
(add-to-list 'new-processor-type `(conversation . ((conversation-logfile . ,(format "%s/conversation.json" default-chat-dir))
(cl-pushnew `(conversation . ((conversation-logfile . ,(format "%s/conversation.json" default-chat-dir))
(model . ,default-model)
(openai-api-key . ,khoj-openai-api-key))))
(openai-api-key . ,khoj-openai-api-key)))
'new-processor-type)
(setq config (delq (assoc 'processor config) config))
(add-to-list 'config `(processor . ,new-processor-type))))
(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))
@ -451,11 +454,12 @@ CONFIG is json obtained from Khoj config API."
(model-name (khoj--get-directory-from-config config '(processor conversation model)))
(new-processor-type (alist-get 'processor config)))
(setq new-processor-type (delq (assoc 'conversation new-processor-type) new-processor-type))
(add-to-list 'new-processor-type `(conversation . ((conversation-logfile . ,(format "%s/conversation.json" chat-directory))
(cl-pushnew `(conversation . ((conversation-logfile . ,(format "%s/conversation.json" chat-directory))
(model . ,model-name)
(openai-api-key . ,khoj-openai-api-key))))
(openai-api-key . ,khoj-openai-api-key)))
'new-processor-type)
(setq config (delq (assoc 'processor config) config))
(add-to-list 'config `(processor . ,new-processor-type)))))
(cl-pushnew `(processor . ,new-processor-type) 'config))))
;; Update server with latest configuration, if required
(cond ((not current-config)