Add no-cache parameter to kagi-summarize
This commit is contained in:
parent
e1f2f6fcc8
commit
5732de8bcd
16
kagi-test.el
16
kagi-test.el
|
@ -324,7 +324,21 @@ https://www.example.com"
|
|||
(it "uses the summary style when an invalid format is configured"
|
||||
(setq kagi-summarizer-default-summary-format 'invalid)
|
||||
(kagi-summarize just-enough-text-input)
|
||||
(kagi-test--expect-object #'kagi--call-summarizer "summary_type" :to-equal 'summary)))
|
||||
(kagi-test--expect-object #'kagi--call-summarizer "summary_type" :to-equal 'summary))
|
||||
(it "lets Kagi cache by default"
|
||||
(kagi-summarize just-enough-text-input)
|
||||
(kagi-test--expect-object #'kagi--call-summarizer "cache" :to-equal t))
|
||||
(it "does not let Kagi cache when no-cache is set"
|
||||
(kagi-summarize just-enough-text-input nil nil nil t)
|
||||
(kagi-test--expect-object #'kagi--call-summarizer "cache" :to-equal nil))
|
||||
(it "lets the no-cache argument override the configured value"
|
||||
(setq kagi-summarizer-cache t)
|
||||
(kagi-summarize just-enough-text-input nil nil nil t)
|
||||
(kagi-test--expect-object #'kagi--call-summarizer "cache" :to-equal nil))
|
||||
(it "does not let Kagi cache if configured"
|
||||
(setq kagi-summarizer-cache nil)
|
||||
(kagi-summarize just-enough-text-input)
|
||||
(kagi-test--expect-object #'kagi--call-summarizer "cache" :to-equal nil)))
|
||||
(describe "kagi-summarize-buffer"
|
||||
(before-each
|
||||
(spy-on #'read-buffer)
|
||||
|
|
16
kagi.el
16
kagi.el
|
@ -563,7 +563,7 @@ to `kagi-summarizer-default-language'."
|
|||
kagi-summarizer-default-summary-format)
|
||||
(t 'summary))))
|
||||
|
||||
(defun kagi-summarize (text-or-url &optional language engine format)
|
||||
(defun kagi-summarize (text-or-url &optional language engine format no-cache)
|
||||
"Return the summary of the given TEXT-OR-URL.
|
||||
|
||||
LANGUAGE is a supported two letter abbreviation of the language,
|
||||
|
@ -574,13 +574,20 @@ ENGINE is the name of a supported summarizer engine, as
|
|||
defined in `kagi--summarizer-engines'.
|
||||
|
||||
FORMAT is the summary format, where `summary' returns a paragraph
|
||||
of text and `takeaway' returns a bullet list."
|
||||
of text and `takeaway' returns a bullet list.
|
||||
|
||||
When NO-CACHE is t, inputs are not retained inside Kagi's
|
||||
infrastructure. When nil, the default value for
|
||||
`kagi-summarizer-cache' is used. Set to t for confidential
|
||||
content."
|
||||
(let ((kagi-summarizer-default-language
|
||||
(kagi--summarizer-determine-language language))
|
||||
(kagi-summarizer-engine
|
||||
(kagi--summarizer-engine engine))
|
||||
(kagi-summarizer-default-summary-format
|
||||
(kagi--summarizer-format format)))
|
||||
(kagi--summarizer-format format))
|
||||
;; TODO break out logic in separate function
|
||||
(kagi-summarizer-cache (if no-cache nil kagi-summarizer-cache)))
|
||||
(if-let* ((response (if (kagi--url-p text-or-url)
|
||||
(kagi--call-url-summarizer text-or-url)
|
||||
(kagi--call-text-summarizer text-or-url)))
|
||||
|
@ -634,6 +641,7 @@ this when PROMPT-INSERT-P is non-nil."
|
|||
nil
|
||||
#'string=))))))
|
||||
|
||||
;; TODO no-cache
|
||||
;;;###autoload
|
||||
(defun kagi-summarize-buffer (buffer &optional insert language engine format interactive-p)
|
||||
"Summarize the BUFFER's content and show it in a new window.
|
||||
|
@ -672,6 +680,7 @@ INTERACTIVE-P is t when called interactively."
|
|||
(interactive-p (kagi--display-summary summary summary-buffer-name))
|
||||
(t summary))))
|
||||
|
||||
;; TODO no-cache
|
||||
;;;###autoload
|
||||
(defun kagi-summarize-region (begin end &optional language engine format)
|
||||
"Summarize the region's content marked by BEGIN and END positions.
|
||||
|
@ -701,6 +710,7 @@ ENGINE to use and which summary FORMAT to use."
|
|||
format)
|
||||
(kagi--summary-buffer-name (buffer-name))))
|
||||
|
||||
;; TODO no-cache
|
||||
;;;###autoload
|
||||
(defun kagi-summarize-url (url &optional insert language engine format)
|
||||
"Show the summary of the content behind the given URL.
|
||||
|
|
Loading…
Reference in a new issue