Skip to content

Commit

Permalink
Merge branch 'develop' into schema-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyatt committed Sep 1, 2024
2 parents cdee1b5 + 354d937 commit be74817
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/ekg.org
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ triples library is already installed.
- Remove the never-used named, email, and person schema.
- Fix issue with tag completions triggering incorrectly if they contained spaces.
- Fix error when displaying unknown schema.
- Improve JSONification of notes when sending context to LLMs.
** Version 0.6.2
- Add export to [[https://github.com/protesilaos/denote][denote]] (by [[https://github.com/jayrajput][Jay Rajput]])
** Version 0.6.1
Expand Down
2 changes: 2 additions & 0 deletions doc/ekg.texi
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ Remove the never-used named, email, and person schema.
Fix issue with tag completions triggering incorrectly if they contained spaces.
@item
Fix error when displaying unknown schema.
@item
Improve JSONification of notes when sending context to LLMs.
@end itemize

@node Version 062
Expand Down
22 changes: 22 additions & 0 deletions ekg-llm-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@
(should (equal "BEGIN\nvery different text\nEND\n"
(substring-no-properties (buffer-string)))))))

(ert-deftest ekg-llm-test-note-to-text ()
(let* ((time (current-time))
(time-str (format-time-string "%Y-%m-%dT%H:%M:%S" time))
(json-encoding-pretty-print t))
(should (equal
(json-encode
(sort
`(("tags" . ["tag1" "tag2"])
("created" . ,time-str)
("modified" . ,time-str)
("title" . ["Title"])
("text" . "Content")
("id" . "http://example.com/1"))
(lambda (a b) (string< (car a) (car b)))))
(ekg-llm-note-to-text
(make-ekg-note :id "http://example.com/1"
:properties '(:titled/title ("Title"))
:text "Content"
:creation-time time
:modified-time time
:tags '("tag1" "tag2")))))))

(provide 'ekg-llm-test)

;;; ekg-llm-test.el ends here
15 changes: 12 additions & 3 deletions ekg-llm.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
(require 'llm)
(require 'llm-prompt)
(require 'json)
(require 'map)
(require 'org nil t)

;;; Code:
Expand Down Expand Up @@ -241,10 +242,18 @@ structs."
(let ((result `((tags . ,(ekg-note-tags note))
(created . ,(ekg-llm-format-time (ekg-note-creation-time note)))
(modified . ,(ekg-llm-format-time (ekg-note-modified-time note)))
(text . ,(substring-no-properties (ekg-display-note-text note)))))
(titles (plist-get (ekg-note-properties note) :titled/title))
(text . ,(substring-no-properties (substring-no-properties
(ekg-note-text note))))))
(json-encoding-pretty-print t))
(when titles (push (cons 'titles titles) result))
(when (ekg-should-show-id-p note)
(push (cons "id" (ekg-note-id note)) result))
(map-do
(lambda (prop value)
(when-let ((label (assoc-default prop ekg-metadata-labels)))
(push (cons (downcase label) value) result)))
(ekg-note-properties note))
;; Sort the result so JSON is deterministic and we can test it.
(sort result (lambda (a b) (string< (car a) (car b))))
(json-encode result)))

(defun ekg-llm-make-any-tag-generator (tags)
Expand Down

0 comments on commit be74817

Please sign in to comment.