From f7614d70b438ac568600d062d923a9d70b62b81c Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sat, 30 Mar 2024 08:30:57 +0100 Subject: [PATCH] Add anthropic backend --- bundle/bundle--package.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bundle/bundle--package.el b/bundle/bundle--package.el index e4e7960a..eb625062 100644 --- a/bundle/bundle--package.el +++ b/bundle/bundle--package.el @@ -343,6 +343,22 @@ ;; :defer t ;; :after json-mode) +(defun get-anthropic-key () + "Retrieve the Anthropics API key using 'auth-source'." + (require 'auth-source) + (let* ((auth-source-creation-prompts + '((secret . "API key for %u@%h: "))) + (found (nth 0 (auth-source-search + :max 1 + :host "api.anthropic.com" + :user "apikey" + :require '(:secret) + :create t))) + (secret (plist-get found :secret))) + (if (functionp secret) + (funcall secret) + secret))) + (use-package gptel :bind (("C-c G m" . gptel-menu) ("C-c G n" . gptel) @@ -361,7 +377,10 @@ (elisp . "Consider yourself an experienced Emacs Lisp developer with a deep understanding of Emacs's extensibility and customization capabilities. You're well-versed in creating and modifying Emacs modes, optimizing workflows, and integrating Emacs with other tools and services."))) :config (when (eq system-type 'windows-nt) - (setq gptel-use-curl t))) + (setq gptel-use-curl t)) + (gptel-make-anthropic "Claude" + :stream t + :key #'get-anthropic-key)) (use-package gnuplot :defer t)