branch: externals/ellama
commit 644230178b40a9dd432fe67ef81229b1ff764274
Merge: 7bd7aa4654 141c17331c
Author: Sergey Kostyaev <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #361 from s-kostyaev/simplify-function-application
Simplify function execution in ellama-tools
---
NEWS.org | 4 ++++
ellama-tools.el | 12 +++---------
ellama.el | 2 +-
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index ee208291c6..1cafe341bf 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,7 @@
+* Version 1.10.3
+- Removed redundant checks for function arguments and streamlined the execution
+ logic in ellama-tools.el, making the code more concise and maintainable by
+ using the apply function directly in all cases.
* Version 1.10.2
- Added directory tracking to sessions, including a directory path in the extra
data field and setting the default directory when a session is initialized to
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"))))
diff --git a/ellama.el b/ellama.el
index d3931c7376..9486e1f891 100644
--- a/ellama.el
+++ b/ellama.el
@@ -6,7 +6,7 @@
;; URL: http://github.com/s-kostyaev/ellama
;; Keywords: help local tools
;; Package-Requires: ((emacs "28.1") (llm "0.24.0") (plz "0.8") (transient
"0.7") (compat "29.1"))
-;; Version: 1.10.2
+;; Version: 1.10.3
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 8th Oct 2023