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

    feat: add command `minuet-configure-provider`.
---
 README.md |  5 +++--
 minuet.el | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 20310cf3e9..4ffdc0e671 100644
--- a/README.md
+++ b/README.md
@@ -70,7 +70,7 @@ managers.
     :bind
     (("M-y" . #'minuet-complete-with-minibuffer) ;; use minibuffer for 
completion
      ("M-i" . #'minuet-show-suggestion) ;; use overlay for completion
-
+     ("C-c m" . #'minuet-configure-provider)
      :map minuet-active-mode-map
      ;; These keymaps activate only when a minuet suggestion is displayed in 
the current buffer
      ("M-p" . #'minuet-previous-suggestion) ;; invoke completion or cycle to 
next completion
@@ -87,6 +87,7 @@ managers.
     (add-hook 'prog-mode-hook #'minuet-auto-suggestion-mode)
 
     :config
+    ;; You can use M-x minuet-configure-provider to interactively configure 
provider and model
     (setq minuet-provider 'openai-fim-compatible)
 
     ;; Required when defining minuet-ative-mode-map in insert/normal states.
@@ -324,7 +325,7 @@ Below is the default value:
 
 ```lisp
 (defvar minuet-claude-options
-    `(:model "claude-3-5-sonnet-20241022"
+    `(:model "claude-3-5-haiku-20241022"
       :max_tokens 512
       :api-key "ANTHROPIC_API_KEY"
       :system
diff --git a/minuet.el b/minuet.el
index 65bef65609..a6d55cb3a2 100644
--- a/minuet.el
+++ b/minuet.el
@@ -1196,5 +1196,44 @@ When enabled, Minuet will automatically show suggestions 
while you type."
     :init-value nil
     :keymap minuet-active-mode-map)
 
+;;;###autoload
+(defun minuet-configure-provider ()
+    "Configure a minuet provider interactively.
+This command offers an interactive approach to configuring provider
+settings, as an alternative to manual configuration via `setq' and
+`plist-put'. When selecting either `openai-compatible' or
+`openai-fim-compatible' providers, users will be prompted to specify
+their endpoint and API key."
+    (interactive)
+    (let* ((providers '(("OpenAI" . openai)
+                        ("Claude" . claude)
+                        ("Codestral" . codestral)
+                        ("OpenAI Compatible" . openai-compatible)
+                        ("OpenAI FIM Compatible" . openai-fim-compatible)
+                        ("Gemini" . gemini)))
+           (provider-name (completing-read "Select provider: " providers nil 
t))
+           (provider (alist-get provider-name providers nil nil #'equal))
+           (options-sym (intern (format "minuet-%s-options" provider)))
+           (options (symbol-value options-sym))
+           (current-model (plist-get options :model))
+           (model (read-string "Model: " (or current-model ""))))
+
+        (setf (plist-get (symbol-value options-sym) :model) model)
+
+        ;; For OpenAI compatible providers, also configure endpoint and API key
+        (when (memq provider '(openai-compatible openai-fim-compatible))
+            (let* ((current-endpoint (plist-get options :end-point))
+                   (current-api-key (plist-get options :api-key))
+                   (endpoint (read-string "Endpoint URL: " (or 
current-endpoint "")))
+                   (api-key (read-string "API Key Environment Variable: "
+                                         (if (stringp current-api-key)
+                                                 current-api-key
+                                             ""))))
+                (setf (plist-get (symbol-value options-sym) :end-point) 
endpoint)
+                (setf (plist-get (symbol-value options-sym) :api-key) 
api-key)))
+
+        (setq minuet-provider provider)
+        (message "Minuet provider configured to %s with model %s" 
provider-name model)))
+
 (provide 'minuet)
 ;;; minuet.el ends here

Reply via email to