branch: elpa/gptel
commit 02fa8250a3274c52d8dab91b525d193328b156e1
Author: longlene <longl...@gmail.com>
Commit: GitHub <nore...@github.com>

    gptel-openai: Send tool parameters when args is nil (#818)
    
    gptel.el (gptel--parse-tools): Send `;parameters' with a `:null` value
    when a tool takes no arguments.  Previously OpenAI failed to handle
    this, but now it looks like the JSON schema is being adhered to
    more closely.
---
 gptel.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gptel.el b/gptel.el
index 1ed232f068..919d2a5620 100644
--- a/gptel.el
+++ b/gptel.el
@@ -1743,7 +1743,7 @@ implementation, used by OpenAI-compatible APIs and 
Ollama."
         (list
          :name (gptel-tool-name tool)
          :description (gptel-tool-description tool))
-        (and (gptel-tool-args tool)     ;no parameters if args is nil
+        (if (gptel-tool-args tool)
              (list
               :parameters
               (list :type "object"
@@ -1774,7 +1774,8 @@ implementation, used by OpenAI-compatible APIs and 
Ollama."
                                 (lambda (arg) (and (not (plist-get arg 
:optional))
                                               (plist-get arg :name)))
                                 (gptel-tool-args tool))))
-                    :additionalProperties :json-false))))))
+                    :additionalProperties :json-false))
+          (list :parameters :null)))))
     (ensure-list tools))))
 
 (cl-defgeneric gptel--parse-tool-results (backend results)

Reply via email to