mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 16:14:21 +00:00
Fix loading chat history, references in khoj.el chat buffer
This commit is contained in:
parent
6afbd8032e
commit
cd4baa3fa5
1 changed files with 6 additions and 4 deletions
|
@ -702,7 +702,8 @@ Render results in BUFFER-NAME using QUERY, CONTENT-TYPE."
|
||||||
|
|
||||||
(defun khoj--load-chat-history (buffer-name)
|
(defun khoj--load-chat-history (buffer-name)
|
||||||
"Load Khoj Chat conversation history into BUFFER-NAME."
|
"Load Khoj Chat conversation history into BUFFER-NAME."
|
||||||
(let ((json-response (cdr (assoc 'response (khoj--get-chat-history-api)))))
|
(setq khoj--reference-count 0)
|
||||||
|
(let ((json-response (cdr (elt (cdr (assoc 'response (khoj--get-chat-history-api))) 0))))
|
||||||
(with-current-buffer (get-buffer-create buffer-name)
|
(with-current-buffer (get-buffer-create buffer-name)
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert "* Khoj Chat\n")
|
(insert "* Khoj Chat\n")
|
||||||
|
@ -829,16 +830,17 @@ RECEIVE-DATE is the message receive date."
|
||||||
(defun khoj--generate-reference (reference)
|
(defun khoj--generate-reference (reference)
|
||||||
"Create `org-mode' footnotes with REFERENCE."
|
"Create `org-mode' footnotes with REFERENCE."
|
||||||
(setq khoj--reference-count (1+ khoj--reference-count))
|
(setq khoj--reference-count (1+ khoj--reference-count))
|
||||||
|
(let ((compiled-reference (cdr (assoc 'compiled reference))))
|
||||||
(cons
|
(cons
|
||||||
(propertize (format "^{ [fn:%x]}" khoj--reference-count) 'help-echo reference)
|
(propertize (format "^{ [fn:%x]}" khoj--reference-count) 'help-echo compiled-reference)
|
||||||
(thread-last
|
(thread-last
|
||||||
reference
|
compiled-reference
|
||||||
;; remove filename top heading line from reference
|
;; remove filename top heading line from reference
|
||||||
;; prevents actual reference heading in next line jumping out of references footnote section
|
;; prevents actual reference heading in next line jumping out of references footnote section
|
||||||
(replace-regexp-in-string "^\* .*\n" "")
|
(replace-regexp-in-string "^\* .*\n" "")
|
||||||
;; remove multiple, consecutive empty lines from reference
|
;; remove multiple, consecutive empty lines from reference
|
||||||
(replace-regexp-in-string "\n\n" "\n")
|
(replace-regexp-in-string "\n\n" "\n")
|
||||||
(format "\n[fn:%x] %s" khoj--reference-count))))
|
(format "\n[fn:%x] %s" khoj--reference-count)))))
|
||||||
|
|
||||||
(defun khoj--render-chat-response (json-response)
|
(defun khoj--render-chat-response (json-response)
|
||||||
"Render chat message using JSON-RESPONSE from Khoj Chat API."
|
"Render chat message using JSON-RESPONSE from Khoj Chat API."
|
||||||
|
|
Loading…
Add table
Reference in a new issue