emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/llm 14dbbde595 2/2: Fix issue with empty function call


From: ELPA Syncer
Subject: [elpa] externals/llm 14dbbde595 2/2: Fix issue with empty function call args for Open AI (#99)
Date: Tue, 5 Nov 2024 03:58:55 -0500 (EST)

branch: externals/llm
commit 14dbbde595adbcb621e0bb0429f4982c9a9bc2cc
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: GitHub <noreply@github.com>

    Fix issue with empty function call args for Open AI (#99)
    
    This may just affect some Open AI compatibile providers.
    
    See discussion in https://github.com/ahyatt/llm/discussions/97, the
    issues there should be fixed by this.
---
 NEWS.org      | 1 +
 llm-openai.el | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index 8c291e6aea..9d16635ad3 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -7,6 +7,7 @@
 - Centralize model list so things like Vertex and Open AI compatible libraries 
can have more accurate context lengths and capabilities.
 - Update default Gemini chat model to Gemini 1.5 Pro.
 - Update default Claude chat model to latest Sonnet version.
+- Fix issue in some Open AI compatible providers with empty function call 
arguments
 * Version 0.17.4
 - Fix problem with Open AI's =llm-chat-token-limit=.
 - Fix Open AI and Gemini's parallel function calling.
diff --git a/llm-openai.el b/llm-openai.el
index 11d6ba6f7e..b2fc5c0cd4 100644
--- a/llm-openai.el
+++ b/llm-openai.el
@@ -198,7 +198,9 @@ STREAMING if non-nil, turn on response streaming."
               (make-llm-provider-utils-function-call
                :id (assoc-default 'id call)
                :name (assoc-default 'name function)
-               :args (json-read-from-string (assoc-default 'arguments 
function)))))
+               :args (json-read-from-string
+                      (let ((args (assoc-default 'arguments function)))
+                        (if (= (length args) 0) "{}" args))))))
           (assoc-default 'tool_calls
                          (assoc-default 'message
                                         (aref (assoc-default 'choices 
response) 0)))))
@@ -211,7 +213,8 @@ FCS is a list of `make-llm-provider-utils-function-call'"
                 `(("id" . ,(llm-provider-utils-function-call-id fc))
                   ("type" . "function")
                   ("function" .
-                   (("arguments" . ,(json-encode 
(llm-provider-utils-function-call-args fc)))
+                   (("arguments" . ,(json-encode
+                                     (llm-provider-utils-function-call-args 
fc)))
                     ("name" . ,(llm-provider-utils-function-call-name fc))))))
               fcs))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]