aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorAdrian Kummerlaender2023-12-23 16:38:35 +0100
committerAdrian Kummerlaender2023-12-23 16:38:35 +0100
commit2cc136a95dc34aafdba4ba9354d85023d3719f36 (patch)
tree942bec7a6bdafcaca6cadadf3a0e6b359a0f85f9 /gui
parent4e3cd6fad1e3fe2ed82cb8bb355fc1ea65bc1ac1 (diff)
downloadnixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.tar
nixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.tar.gz
nixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.tar.bz2
nixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.tar.lz
nixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.tar.xz
nixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.tar.zst
nixos_home-2cc136a95dc34aafdba4ba9354d85023d3719f36.zip
Emacs: Setup up basic gptel bindings
Diffstat (limited to 'gui')
-rw-r--r--gui/conf/init.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/gui/conf/init.el b/gui/conf/init.el
index 9ef5e47..c94b4f0 100644
--- a/gui/conf/init.el
+++ b/gui/conf/init.el
@@ -567,6 +567,39 @@
ad-do-it
(message "org-tangle took %f sec" (float-time (time-subtract (current-time) time)))))
+(use-package gptel
+ :ensure t
+ :config
+ (defvar gptel--atlas
+ (gptel-make-openai "atlas"
+ :stream t
+ :protocol "http"
+ :host "10.100.0.3:8081")
+ "GPTel remote backend on atlas")
+ (setq-default gptel-backend gptel--atlas)
+ (setq-default gptel-max-tokens 4096)
+ (defvar gptel-quick--history nil)
+ (defun gptel-quick (&optional prompt)
+ (interactive)
+ (unless prompt
+ (if (use-region-p)
+ (setq prompt (buffer-substring-no-properties (region-beginning) (region-end)))
+ (setq prompt (read-string "AI: "))))
+ (when (string= prompt "") (user-error "Text selection or prompt is required."))
+ (gptel-request
+ prompt
+ :callback
+ (lambda (response info)
+ (if (not response)
+ (message "gptel-quick failed with message: %s" (plist-get info :status))
+ (with-current-buffer (get-buffer-create "*gptel-quick*")
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (insert response))
+ (special-mode)
+ (switch-to-buffer "*gptel-quick*"))))))
+ (evil-leader/set-key "g" 'gptel-quick))
+
(let ((mu4e-config "~/.emacs.d/email.el"))
(when (file-exists-p mu4e-config)
(load-file mu4e-config)))