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

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

[elpa] externals/ellama 1d5c5ecdb1 13/37: Add function to run chat with


From: ELPA Syncer
Subject: [elpa] externals/ellama 1d5c5ecdb1 13/37: Add function to run chat with llm using blueprint
Date: Sat, 8 Mar 2025 06:58:35 -0500 (EST)

branch: externals/ellama
commit 1d5c5ecdb1315237cb6960a327e00d21159507c7
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>

    Add function to run chat with llm using blueprint
    
    Added `ellama-blueprint-run` function which allows running a chat with an 
LLM
    starting with a specified blueprint and optional pre-filled variables. The
    function uses a temporary buffer to insert the content of the selected
    blueprint, replaces placeholders with provided arguments, and then sends the
    buffer to a new chat session.
---
 ellama.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/ellama.el b/ellama.el
index 331124a4d5..3faf5acc0d 100644
--- a/ellama.el
+++ b/ellama.el
@@ -1307,6 +1307,31 @@ Then kill current buffer."
 (defvar ellama-blueprint-buffer "*ellama-blueprint-buffer*"
   "Buffer for prompt blueprint.")
 
+;;;###autoload
+(defun ellama-blueprint-run (blueprint &optional args)
+  "Run chat with llm starting with BLUEPRINT with prefilled variables.
+
+ARGS contains plist with variables to prefill."
+  (let* ((collection (seq-union
+                     ellama-blueprints
+                     (ellama-community-prompts-ensure)
+                     (lambda (blueprint1 blueprint2)
+                       (string=
+                        (plist-get blueprint1 :act)
+                        (plist-get blueprint2 :act)))))
+        (prompt (cl-find-if (lambda (el)
+                              (string= blueprint (plist-get el :act)))
+                            collection))
+        (content (plist-get prompt :prompt)))
+    (with-temp-buffer
+      (insert content)
+      (when args
+       (dolist (var (ellama-blueprint-get-variable-list))
+         (ellama-blueprint-set-variable
+          var
+          (plist-get args (intern (concat ":" var))))))
+      (ellama-send-buffer-to-new-chat))))
+
 ;;;###autoload
 (defun ellama-blueprint-select (&optional args)
   "Select a prompt from the prompt collection.



reply via email to

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