Improve online chat reference extraction in Khoj.el Emacs package

- Handle online references with no title
- Improve handling references which are arrays instead of lists
This commit is contained in:
Debanjum Singh Solanky 2024-06-23 08:12:13 +05:30
parent 9d33d8c0fa
commit c7c32a7467

View file

@ -993,13 +993,15 @@ RECEIVE-DATE is the message receive date."
(lambda (search-result) (lambda (search-result)
(-map (-map
(lambda (entry) (lambda (entry)
(let ((link (cdr (or (assoc 'link entry) (assoc 'descriptionLink entry)))) (let* ((link (cdr (or (assoc 'link entry) (assoc 'descriptionLink entry))))
(title (cdr (or (assoc 'title entry) '(title . ,link)))) (title (cdr (or (assoc 'title entry) `(title . ,link))))
(description (cdr (or (assoc 'snippet entry) (assoc 'description entry))))) (description (cdr (or (assoc 'snippet entry) (assoc 'description entry)))))
(setq result (append result `(((title . ,title) (link . ,link) (description . ,description) (search . ,search-q))))))) (setq result (append result `(((title . ,title) (link . ,link) (description . ,description) (search . ,search-q)))))))
;; wrap search results in a list if it is not already a list ;; wrap search results in a list if it is not already a list
(if (or (equal 'knowledgeGraph (car search-result)) (equal 'webpages (car search-result))) (if (or (equal 'knowledgeGraph (car search-result)) (equal 'webpages (car search-result)))
(list (cdr search-result)) (if (arrayp (cdr search-result))
(list (elt (cdr search-result) 0))
(list (cdr search-result)))
(cdr search-result)))) (cdr search-result))))
search-results))) search-results)))
query-result-pairs) query-result-pairs)