branch: externals/minuet commit 74c3ab10c33a44bfc7f35c6d8496bb0fccfdb326 Author: Milan Glacier <d...@milanglacier.com> Commit: Milan Glacier <d...@milanglacier.com>
feat: `minuet-configure-provider` can configure api-key as a function. Allow functions as API key providers and preserve existing API key when empty input is given. Support both string and function values for the API key configuration. --- minuet.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/minuet.el b/minuet.el index 64af3494b6..bcaa99dea3 100644 --- a/minuet.el +++ b/minuet.el @@ -1225,12 +1225,16 @@ their endpoint and API key." (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 - "")))) + (api-key (read-string "API Key Environment Variable or Function: " + (cond ((stringp current-api-key) current-api-key) + ((symbolp current-api-key) (symbol-name current-api-key)) + (t "")))) + ;; If the user enters nothing via `read-string`, retain the current API key. + (final-api-key (cond ((equal "" api-key) current-api-key) + ((functionp (intern api-key)) (intern api-key)) + (t api-key)))) (plist-put options :end-point endpoint) - (plist-put options :api-key api-key))) + (plist-put options :api-key final-api-key))) (setq minuet-provider provider) (message "Minuet provider configured to %s with model %s" provider-name model)))