mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Fix loading an empty chat session in Emacs
This commit is contained in:
parent
e21c0648ae
commit
c33954cd93
1 changed files with 11 additions and 8 deletions
|
@ -755,16 +755,17 @@ Render results in BUFFER-NAME using search results, CONTENT-TYPE and (optional)
|
|||
"Load Khoj Chat conversation history into BUFFER-NAME."
|
||||
(setq khoj--reference-count 0)
|
||||
(let ((inhibit-read-only t)
|
||||
(json-response (cdr (elt (cdr (assoc 'response (khoj--get-chat-session session-id))) 0))))
|
||||
(json-response (cdr (assoc 'chat (cdr (assoc 'response (khoj--get-chat-session session-id)))))))
|
||||
(with-current-buffer (get-buffer-create buffer-name)
|
||||
(erase-buffer)
|
||||
(insert "* Khoj Chat\n")
|
||||
(thread-last
|
||||
json-response
|
||||
;; generate chat messages from Khoj Chat API response
|
||||
(mapcar #'khoj--format-chat-response)
|
||||
;; insert chat messages into Khoj Chat Buffer
|
||||
(mapc #'insert))
|
||||
(when json-response
|
||||
(thread-last
|
||||
json-response
|
||||
;; generate chat messages from Khoj Chat API response
|
||||
(mapcar #'khoj--format-chat-response)
|
||||
;; insert chat messages into Khoj Chat Buffer
|
||||
(mapc #'insert)))
|
||||
(progn
|
||||
(org-mode)
|
||||
(khoj--add-hover-text-to-footnote-refs (point-min))
|
||||
|
@ -846,7 +847,9 @@ CBARGS are optional additional arguments to pass to CALLBACK."
|
|||
"Menu to select Khoj conversation session to open."
|
||||
(let* ((sessions (khoj--get-chat-sessions))
|
||||
(session-alist (-map (lambda (session)
|
||||
(cons (cdr (assoc 'slug session))
|
||||
(cons (if (not (equal :null (cdr (assoc 'slug session))))
|
||||
(cdr (assoc 'slug session))
|
||||
(format "New Conversation (%s)" (cdr (assoc 'conversation_id session))))
|
||||
(cdr (assoc 'conversation_id session))))
|
||||
sessions))
|
||||
(selected-session-slug (completing-read "Open Conversation: " session-alist nil t))
|
||||
|
|
Loading…
Add table
Reference in a new issue