diff --git a/README.org b/README.org index 0098ec5..07c8915 100644 --- a/README.org +++ b/README.org @@ -268,6 +268,10 @@ The full changelog can be found in README.org. - Show a welcome message when starting the FastGPT shell (=kagi-fastgpt-shell=). This can be customized with =kagi-fastgpt-welcome-function=, a variable with a function that returns a welcome string. +*** Misc + +- Minor refactoring in the code calling the FastGPT API. + ** 0.5 *** Breaking changes diff --git a/kagi.el b/kagi.el index a16d835..5969777 100644 --- a/kagi.el +++ b/kagi.el @@ -301,14 +301,6 @@ The OBJECT will be JSON encoded and sent as HTTP POST data." (buffer-string) (error "Call to Kagi API returned with status %s" return))))) -(defun kagi--call-fastgpt (prompt) - "Submit the given PROMPT to the FastGPT API. - -Returns the JSON response as a string. See -https://help.kagi.com/kagi/api/fastgpt.html for the -interpretation." - (kagi--call-api (list (cons 'query prompt)) kagi-fastgpt-api-url)) - (defun kagi--call-summarizer (obj) "Submit a request to the Summarizer API. @@ -374,10 +366,10 @@ list of conses." (defun kagi--fastgpt (prompt) "Submit a PROMPT to FastGPT and return a formatted response string. -This is used by `kagi-fastgpt-shell' and `kagi-fastgpt-prompt' to -obtain a result from FastGPT. Use the latter function for -retrieving a result from Lisp code." - (let* ((response (kagi--call-fastgpt prompt)) +This is used by `kagi-fastgpt-prompt' to obtain a result from +FastGPT. Use that function instead for retrieving a result from +Lisp code." + (let* ((response (kagi--call-api (list (cons 'query prompt)) kagi-fastgpt-api-url)) (parsed-response (json-parse-string response)) (output (kagi--gethash parsed-response "data" "output")) (references (kagi--gethash parsed-response "data" "references"))) @@ -431,7 +423,7 @@ object (created with `make-shell-maker-config')." :execute-command (lambda (command _history callback error-callback) (condition-case err - (funcall callback (kagi--fastgpt command) nil) + (funcall callback (kagi-fastgpt-prompt command) nil) (json-parse-error (funcall error-callback (format "Could not parse the server response %s" (cdr err)))) (error (funcall error-callback (format "An error occurred during the request %s" (cdr err))))))) diff --git a/kagi.info b/kagi.info index ac23c00..7f9725f 100644 Binary files a/kagi.info and b/kagi.info differ