branch: externals/minuet
commit 9df64dd5af157142d01110d69f953136f1263682
Author: Milan Glacier <d...@milanglacier.com>
Commit: Milan Glacier <d...@milanglacier.com>

    refactor: optimize system template evaluation.
---
 minuet.el | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/minuet.el b/minuet.el
index 610f622dc1..05d79c7a26 100644
--- a/minuet.el
+++ b/minuet.el
@@ -817,24 +817,14 @@ If using ollama you can just set it to 'TERM'." api-key)
                                    "")))
     (setq tmpl (replace-regexp-in-string "{{{:n-completions-template}}}"
                                          n-completions-template
-                                         tmpl))
-    (map-do
-     (lambda (k v)
-       (setq v (minuet--eval-value v))
-       (when (and (not (equal k :template))
-                  (not (equal k :n-completions-template))
-                  (stringp v))
-         (setq tmpl
-               (replace-regexp-in-string
-                (concat "{{{" (symbol-name k) "}}}")
-                v
-                tmpl))))
-     template)
-    ;; replace placeholders that are not replaced
-    (setq tmpl (replace-regexp-in-string "{{{.*}}}"
-                                         ""
-                                         tmpl))
-    tmpl))
+                                         tmpl)
+          tmpl (replace-regexp-in-string
+                "{{{\\([^{}]+\\)}}}"
+                (lambda (str)
+                  (minuet--eval-value (plist-get template (intern 
(match-string 1 str)))))
+                tmpl)
+          ;; replace placeholders that are not replaced
+          tmpl (replace-regexp-in-string "{{{.*}}}" "" tmpl))))
 
 (defun minuet--openai-fim-complete-base (options get-text-fn context callback)
   "The base function to complete code with openai fim API.

Reply via email to