branch: externals/ellama
commit b6b50fa8743e6d7aa2c6d7c7d3619c69ad8fe9ca
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Add argument processing and type wrapping to tool definitions
The commit introduces handling of the `:args` property in
`ellama-tools-define-tool`. It extracts each argument, determines its
wrapped
type (converting symbols to their interned form), and creates a list of
wrapped
arguments. These wrapped arguments are stored in the tool definition
alongside
the wrapped function, enabling proper argument type handling during
invocation.
This change sets up the tool for more robust confirmation and execution
logic.
---
ellama-tools.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/ellama-tools.el b/ellama-tools.el
index 57b60130c3..47db0e700a 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -117,10 +117,22 @@ FUNCTION if approved, \"Forbidden by the user\"
otherwise."
TOOL-PLIST is a property list in the format expected by `llm-make-tool'.
Returns a new tool definition with the :function wrapped."
(let* ((func (plist-get tool-plist :function))
+ (args (plist-get tool-plist :args))
+ (wrapped-args
+ (mapcar
+ (lambda (arg)
+ (let*
+ ((type (plist-get tool-plist :type))
+ (wrapped-type (if (symbolp type)
+ type
+ (intern type))))
+ (plist-put arg :type wrapped-type)))
+ args))
(wrapped-func (lambda (&rest args)
(apply #'ellama-tools-confirm func args))))
;; Return a new plist with the wrapped function
- (plist-put tool-plist :function wrapped-func)))
+ (setq tool-plist (plist-put tool-plist :function wrapped-func))
+ (plist-put tool-plist :args wrapped-args)))
(defun ellama-tools-define-tool (tool-plist)
"Define a new ellama tool with automatic confirmation wrapping.