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

    Add tools option to ellama-request
    
    Added :tools parameter to ellama-request function to allow specifying tools 
per
    request or session. Updated internal logic to use session tools when 
available,
    otherwise fall back to args or global ellama-tools-enabled.
---
 ellama.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ellama.el b/ellama.el
index ba26fd6d35..3733206d40 100644
--- a/ellama.el
+++ b/ellama.el
@@ -1513,6 +1513,8 @@ in.  Default value is (current-buffer).
 
 :point POINT -- POINT is the point in buffer to insert ellama reply at.
 
+:tools LIST -- LIST of enabled in the current session tools.
+
 :filter FILTER -- FILTER is a function that's applied to (partial) response
 strings before they're inserted into the BUFFER.
 
@@ -1559,6 +1561,12 @@ failure (with BUFFER current).
         (prompt-with-ctx (ellama-context-prompt-with-context prompt))
         (system (or (plist-get args :system)
                     (ellama-get-system-message)))
+        (session-tools (and session
+                             (ellama-session-extra session)
+                             (plist-get (ellama-session-extra session) 
:tools)))
+        (tools (or session-tools
+                   (plist-get args :tools)
+                   ellama-tools-enabled))
         (llm-prompt (if session
                         (if (llm-chat-prompt-p (ellama-session-prompt session))
                             (progn
@@ -1566,7 +1574,7 @@ failure (with BUFFER current).
                                (ellama-session-prompt session)
                                prompt-with-ctx)
                               (setf (llm-chat-prompt-tools 
(ellama-session-prompt session))
-                                    ellama-tools-enabled)
+                                    tools)
                               (when system
                                 (llm-chat-prompt-append-response
                                  (ellama-session-prompt session)
@@ -1574,9 +1582,9 @@ failure (with BUFFER current).
                               (ellama-session-prompt session))
                           (setf (ellama-session-prompt session)
                                 (llm-make-chat-prompt prompt-with-ctx :context 
system
-                                                      :tools 
ellama-tools-enabled)))
+                                                      :tools tools)))
                       (llm-make-chat-prompt prompt-with-ctx :context system
-                                            :tools ellama-tools-enabled))))
+                                            :tools tools))))
     (with-current-buffer reasoning-buffer
       (org-mode))
     (with-current-buffer buffer

Reply via email to