diff --git a/emacs/.emacs.d/config/init-ai.el b/emacs/.emacs.d/config/init-ai.el index 79e148d..ce19bd3 100644 --- a/emacs/.emacs.d/config/init-ai.el +++ b/emacs/.emacs.d/config/init-ai.el @@ -6,10 +6,25 @@ gptel-request) :config (setq gptel-model "llama3:latest" - gptel-backend (gptel-make-ollama "Ollama" - :stream t - :models '("llama3:latest" - "mistral:latest"))) + gptel-backends `((ollama . ((backend . ,(gptel-make-ollama "Ollama" + :stream t + :models '("llama3:latest" + "mistral:latest"))) + (model . "llama3:latest"))) + (openai . ((backend . ,(gptel-make-openai "OpenAI" + :key #'gptel-api-key-from-auth-source + :stream t + :models '("gpt-4o"))) + (model . "gpt-4o")))) + gptel-default-backend 'openai) + (defun gptel-select-backend (backend) + (interactive + (list (intern (completing-read "gptel backend: " + (mapcar #'car gptel-backends))))) + (let ((backend (alist-get backend gptel-backends))) + (setq gptel-backend (alist-get 'backend backend) + gptel-model (alist-get 'model backend)))) + (gptel-select-backend gptel-default-backend) :general ("C-c RET" #'gptel-send "C-c C-" #'gptel-menu))