From 4dbea886a472f1e829a56279f8f7ff8aa42df329 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Tue, 3 Sep 2024 00:24:22 -0400 Subject: [PATCH] Fix LLMs not expanding inlines, broken in commit #172 (#180) Also add a check to the test to keep this problem from re-occurring. --- doc/ekg.org | 1 + doc/ekg.texi | 2 ++ ekg-llm-test.el | 40 +++++++++++++++++++++++----------------- ekg-llm.el | 2 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/doc/ekg.org b/doc/ekg.org index 18eea4a..2f8ea9c 100644 --- a/doc/ekg.org +++ b/doc/ekg.org @@ -76,6 +76,7 @@ triples library is already installed. ** Version 0.6.4 - Fix display of extended structured data in notes. - Add contrib directory and =ekg-email= as a contribution to import emails to notes in a structured way. +- Fix inlines not expanding in the contextual notes in =ekg-llm=. ** Version 0.6.3 - Fix issue in trying to get a single-valued item to show up in the metadata line. - Remove the never-used named, email, and person schema. diff --git a/doc/ekg.texi b/doc/ekg.texi index 7b89bee..af8ef03 100644 --- a/doc/ekg.texi +++ b/doc/ekg.texi @@ -231,6 +231,8 @@ triples library is already installed. Fix display of extended structured data in notes. @item Add contrib directory and @samp{ekg-email} as a contribution to import emails to notes in a structured way. +@item +Fix inlines not expanding in the contextual notes in @samp{ekg-llm}. @end itemize @node Version 063 diff --git a/ekg-llm-test.el b/ekg-llm-test.el index c9a65da..3368679 100644 --- a/ekg-llm-test.el +++ b/ekg-llm-test.el @@ -48,23 +48,29 @@ (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"))))))) + (cl-letf (((symbol-function 'ekg-inline-command-const-inline) + (lambda (&rest _) "inline"))) + (should (equal + (json-encode + (sort + `(("tags" . ["tag1" "tag2"]) + ("created" . ,time-str) + ("modified" . ,time-str) + ("title" . ["Title"]) + ("text" . "Contentinline\n") + ("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") + :inlines + (list (make-ekg-inline :pos 7 + :command '(const-inline) + :type 'command))))))))) (provide 'ekg-llm-test) diff --git a/ekg-llm.el b/ekg-llm.el index 2f81817..7bd0955 100644 --- a/ekg-llm.el +++ b/ekg-llm.el @@ -243,7 +243,7 @@ structs." (created . ,(ekg-llm-format-time (ekg-note-creation-time note))) (modified . ,(ekg-llm-format-time (ekg-note-modified-time note))) (text . ,(substring-no-properties (substring-no-properties - (ekg-note-text note)))))) + (ekg-display-note-text note)))))) (json-encoding-pretty-print t)) (when (ekg-should-show-id-p note) (push (cons "id" (ekg-note-id note)) result))