branch: elpa/gptel
commit 2022d52cb82d3d76aa807d03c0cc4350bddae9ff
Author: Vincent Ambo <m...@tazj.in>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel: Ensure zero-arg tools have valid parameters struct
    
    Some implementations of the OpenAI API (notably, when talking to
    OpenAI's o3 and up) require tools that have no parameters to still
    supply a valid object describing them instead of just `null`.
    
    OpenAI's own older implementations (e.g. when talking to 4.1) handle
    `null` fine, and so do basically all other OpenAI-like endpoints I've
    tested. All implementations seem to work with the empty but valid
    object.
    
    * gptel.el (gptel--parse-tools): Use an empty parameters object
    instead of :null when parsing zero-arg tools for the
    OpenAI-compatible format.
---
 gptel.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gptel.el b/gptel.el
index 4f70524e09..fc8dbf5951 100644
--- a/gptel.el
+++ b/gptel.el
@@ -1867,7 +1867,7 @@ implementation, used by OpenAI-compatible APIs and 
Ollama."
                                               (plist-get arg :name)))
                                 (gptel-tool-args tool))))
                     :additionalProperties :json-false))
-          (list :parameters :null)))))
+          (list :parameters (list :type "object" :properties nil))))))
     (ensure-list tools))))
 
 (cl-defgeneric gptel--parse-tool-results (backend results)

Reply via email to