branch: elpa/gptel
commit 2dd3e317bf4af82cddfa1d1b127c04c17589c878
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel: Linting and minor documentation tweaks
    
    * gptel.el (gptel--display-tool-calls, gptel-request,
    gptel-response-separator): Minor documentation and linting
    changes.
    
    * gptel-openai-extras.el (gptel-make-perplexity,
    gptel--parse-response, gptel-curl--parse-stream): Linting changes.
    
    * gptel-curl.el (gptel-curl-get-response,
    ptel-curl--parse-response): Linting changes.  Remove unused
    let-bindings.
---
 gptel-curl.el          |  4 +---
 gptel-openai-extras.el | 52 +++++++++++++++++++++++++-------------------------
 gptel.el               |  8 +++++---
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/gptel-curl.el b/gptel-curl.el
index 03e748b464..b3ba128c82 100644
--- a/gptel-curl.el
+++ b/gptel-curl.el
@@ -118,7 +118,6 @@ the response is inserted into the current buffer after 
point."
          (info (gptel-fsm-info fsm))
          (args (gptel-curl--get-args info token))
          (stream (plist-get info :stream))
-         (backend (plist-get info :backend))
          (process (apply #'start-process "gptel-curl"
                          (generate-new-buffer "*gptel-curl*") "curl" args)))
     (when (memq system-type '(windows-nt ms-dos))
@@ -337,8 +336,7 @@ PROCESS and _STATUS are process parameters."
   "Parse the buffer BUF with curl's response.
 
 PROC-INFO is a plist with contextual information."
-  (let ((token (plist-get proc-info :token))
-        (parser (plist-get proc-info :parser)))
+  (let ((token (plist-get proc-info :token)))
     (goto-char (point-max))
     (search-backward token)
     (backward-char)
diff --git a/gptel-openai-extras.el b/gptel-openai-extras.el
index c335e8f807..f9ef2cad6d 100644
--- a/gptel-openai-extras.el
+++ b/gptel-openai-extras.el
@@ -179,15 +179,23 @@ for."
                                (:copier nil)
                                (:include gptel-openai)))
 
-(cl-defmethod gptel--parse-response ((_backend gptel-perplexity) response info)
-  "Parse Perplexity response RESPONSE with INFO."
+(defsubst gptel--perplexity-parse-citations (citations)
+  (let ((counter 0))
+    (concat "\n\nCitations:\n"
+            (mapconcat (lambda (url)
+                         (setq counter (1+ counter))
+                         (format "[%d] %s" counter url))
+                       citations "\n"))))
+
+(cl-defmethod gptel--parse-response ((_backend gptel-perplexity) response 
_info)
+  "Parse Perplexity response RESPONSE."
   (let ((response-string (map-nested-elt response '(:choices 0 :message 
:content)))
         (citations-string (when-let ((citations (map-elt response :citations)))
                            (gptel--perplexity-parse-citations citations))))
     (concat response-string citations-string)))
 
-(cl-defmethod gptel-curl--parse-stream ((backend gptel-perplexity) info)
-  "Parse a Perplexity API data stream for BACKEND with INFO.
+(cl-defmethod gptel-curl--parse-stream ((_backend gptel-perplexity) info)
+  "Parse a Perplexity API data stream with INFO.
 
 If available, collect citations at the end and include them with
 the response."
@@ -208,20 +216,12 @@ the response."
                                          citations)))))))))
     resp))
 
-(defsubst gptel--perplexity-parse-citations (citations)
-  (let ((counter 0))
-    (concat "\n\nCitations:\n"
-            (mapconcat (lambda (url)
-                         (setq counter (1+ counter))
-                         (format "[%d] %s" counter url))
-                       citations "\n"))))
-
 ;;;###autoload
 (cl-defun gptel-make-perplexity
     (name &key curl-args stream key
           (header 
            (lambda () (when-let (key (gptel--get-api-key))
-                       `(("Authorization" . ,(concat "Bearer " key))))))
+                   `(("Authorization" . ,(concat "Bearer " key))))))
           (host "api.perplexity.ai")
           (protocol "https")
           (models '(sonar sonar-pro))
@@ -254,19 +254,19 @@ REQUEST-PARAMS (optional) is a plist of additional HTTP 
request
 parameters."
   (declare (indent 1))
   (let ((backend (gptel--make-perplexity
-                 :curl-args curl-args
-                 :name name
-                 :host host
-                 :header header
-                 :key key
-                 :models models
-                 :protocol protocol
-                 :endpoint endpoint
-                 :stream stream
-                 :request-params request-params
-                 :url (if protocol
-                         (concat protocol "://" host endpoint)
-                       (concat host endpoint)))))
+                  :curl-args curl-args
+                  :name name
+                  :host host
+                  :header header
+                  :key key
+                  :models models
+                  :protocol protocol
+                  :endpoint endpoint
+                  :stream stream
+                  :request-params request-params
+                  :url (if protocol
+                           (concat protocol "://" host endpoint)
+                         (concat host endpoint)))))
     (prog1 backend
       (setf (alist-get name gptel--known-backends
                        nil nil #'equal)
diff --git a/gptel.el b/gptel.el
index a4c136a453..7ce9b9042d 100644
--- a/gptel.el
+++ b/gptel.el
@@ -48,6 +48,7 @@
 ;;   wherever)
 ;; - LLM responses are in Markdown or Org markup.
 ;; - Supports conversations and multiple independent sessions.
+;; - Supports tool-use to equip LLMs with agentic capabilities.
 ;; - Supports multi-modal models (send images, documents).
 ;; - Save chats as regular Markdown/Org/Text files and resume them later.
 ;; - You can go back and edit your previous prompts or LLM responses when
@@ -373,7 +374,8 @@ is only inserted in dedicated gptel buffers before the AI's 
response."
   :type '(alist :key-type symbol :value-type string))
 
 (defcustom gptel-response-separator "\n\n"
-  "String inserted before responses.")
+  "String inserted before responses."
+  :type 'string)
 
 (defcustom gptel-use-header-line t
   "Whether `gptel-mode' should use header-line for status information.
@@ -2016,7 +2018,7 @@ If PROMPT is
 Keyword arguments:
 
 CALLBACK, if supplied, is a function of two arguments, called
-with the RESPONSE (a string) and INFO (a plist):
+with the RESPONSE (usually a string) and INFO (a plist):
 
  (funcall CALLBACK RESPONSE INFO)
 
@@ -2787,7 +2789,7 @@ for tool call results.  INFO contains the state of the 
request."
                                  (when (search-forward-regexp "^:tool-use" nil 
t)
                                    (forward-line 0)
                                    (hl-line-highlight)))))))))
-      ;; finished tool call results look like ((name . result) ...)
+      ;; finished tool call results look like ((name args result) ...)
       ;; Insert tool results
       (when gptel-include-tool-results
         (with-current-buffer (marker-buffer start-marker)

Reply via email to