branch: externals/ellama
commit fd0116c429e3a30b97b2db247457055c9baef5b3
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>

    Simplify function execution in ellama-tools
    
    Removed redundant checks for function arguments and streamlined the 
execution
    logic in ellama-tools.el. The changes eliminate unnecessary conditional 
logic
    when calling functions, making the code more concise and maintainable. The 
apply
    function is now used directly in all cases, removing the need for separate
    handling of functions with and without arguments. Thanks to Stefan Monnier.
---
 ellama-tools.el | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/ellama-tools.el b/ellama-tools.el
index 4c7dab6e6b..e5f8e223c8 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -65,9 +65,7 @@ otherwise."
      ;; If user has approved all calls, just execute the function
      ((when (or confirmation ellama-tools-allow-all
                 (cl-find function ellama-tools-allowed))
-        (let ((result (if args
-                          (apply function args)
-                        (funcall function))))
+        (let ((result (apply function args)))
           (if (stringp result)
               result
             (json-encode result)))))
@@ -79,15 +77,11 @@ otherwise."
              (result (cond
                       ;; Yes - execute function once
                       ((eq answer ?y)
-                       (if args
-                           (apply function args)
-                         (funcall function)))
+                       (apply function args))
                       ;; Always - remember approval and execute function
                       ((eq answer ?a)
                        (puthash function t ellama-tools-confirm-allowed)
-                       (if args
-                           (apply function args)
-                         (funcall function)))
+                       (apply function args))
                       ;; No - return nil
                       ((eq answer ?n)
                        "Forbidden by the user"))))

Reply via email to