1
0
Fork 0

Remove debug variables

This commit is contained in:
Bram Schoenmakers 2023-12-25 07:54:42 +01:00
parent 1778140aaf
commit dd5b9c90c8
Signed by: bram
GPG key ID: 0CCD19DFDC63258F

40
kagi.el
View file

@ -69,14 +69,6 @@ https://kagi.com/settings?p=api"
:type '(choice string function) :type '(choice string function)
:group 'kagi) :group 'kagi)
(defvar kagi--canned-response "{\"meta\":{\"id\":\"2c6ea22b-16ea-4529-87c0-612474125724\",\"node\":\"europe-west4\",\"ms\":3099,\"api_balance\":4.805},\"data\":{\"output\":\"Based on the context provided:\\n\\nKagi search is a premium search engine created by Kagi to be faster than other search engines like Google. Some context mentions using Kagi search instead of Google [1][2]. Emacs allows customization and extension through editing Lisp code. Kagi search could potentially be integrated into Emacs to provide search capabilities without leaving the editor, allowing users to seamlessly search from within Emacs. [3]\",\"tokens\":1036,\"references\":[{\"title\":\"View topic - can dnsmasq suppress AAAA/IPv6 queries? - DD-WRT\",\"snippet\":\"<b>Well</b>, that was <b>a</b> google nightmare! (Actually I use <b>kagi</b>.com now instead of google/startpage, fwiw.) I found nothing except the dnsmasq man ...\",\"url\":\"https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=335561&sid=ca1d16c9ffe0db1a7ddd02ecc57f5a3e\"},{\"title\":\"View topic - [SOLVED: no] can dnsmasq suppress AAAA ... - DD-WRT\",\"snippet\":\"<b>Well</b>, that was <b>a</b> google nightmare! (Actually I use <b>kagi</b>.com now instead of google/startpage, fwiw.) I found nothing except the dnsmasq man ...\",\"url\":\"https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1294379&sid=cdc0b6cb7e86d7f3a66211f7f81d060f\"},{\"title\":\"Orion is a web browser based on Safari that supports both Chrome ...\",\"snippet\":\" It's from <b>Kagi</b> who are creating <b>a</b> \\\"Premium <b>search</b> engine\\\" currently ... Maybe I will <b>give</b> it <b>a go</b> in the future. Upvote 2. Downvote Reply reply\",\"url\":\"https://www.reddit.com/r/macapps/comments/sat03p/orion_is_a_web_browser_based_on_safari_that/\"}]}}"
"A test response for debugging purposes.")
(defcustom kagi-debug nil
"Enable debugging statements."
:type 'boolean
:group 'kagi)
(defcustom kagi-api-summarizer-url "https://kagi.com/api/v0/summarize" (defcustom kagi-api-summarizer-url "https://kagi.com/api/v0/summarize"
"The Kagi Summarizer API entry point." "The Kagi Summarizer API entry point."
:type '(choice string function) :type '(choice string function)
@ -148,26 +140,18 @@ https://kagi.com/settings?p=api"
Returns the JSON response as a string. See Returns the JSON response as a string. See
https://help.kagi.com/kagi/api/fastgpt.html for the https://help.kagi.com/kagi/api/fastgpt.html for the
interpretation. interpretation."
(with-temp-buffer
If `kagi-debug' is non-nil, it will return the value of (insert (json-encode `((query . ,prompt))))
`kagi--canned-response', no remote call will be made. This is useful (let* ((call-process-flags '(nil nil "curl" t t nil))
for development purposes as API calls require a charge your API (curl-flags (kagi--curl-flags))
credit at Kagi." (all-flags (append call-process-flags
(if kagi-debug curl-flags
kagi--canned-response (list kagi-api-fastgpt-url)))
(return (apply #'call-process-region all-flags)))
(with-temp-buffer (if (eql return 0)
(insert (json-encode `((query . ,prompt)))) (buffer-string)
(let* ((call-process-flags '(nil nil "curl" t t nil)) (error "Call to FastGPT API returned with status %s" return)))))
(curl-flags (kagi--curl-flags))
(all-flags (append call-process-flags
curl-flags
(list kagi-api-fastgpt-url)))
(return (apply #'call-process-region all-flags)))
(if (eql return 0)
(buffer-string)
(error "Call to FastGPT API returned with status %s" return))))))
(defun kagi--call-summarizer (obj) (defun kagi--call-summarizer (obj)
"Submit the given TEXT to the Summarizer API. "Submit the given TEXT to the Summarizer API.