Add anthropic backend

This commit is contained in:
Marcus Kammer 2024-03-30 08:30:57 +01:00
parent ec0296421e
commit f7614d70b4

View file

@ -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)