chore(emacs): add gptel and glm
15a898d4
2 file(s) · +48 −8
| 65 | 65 | "oT" '(ghostel-project :wk "project terminal") |
|
| 66 | 66 | "os" '(eshell :wk "eshell") |
|
| 67 | 67 | ||
| 68 | - | "m" '(:ignore t :wk "mail") |
|
| 69 | - | "mc" '(mu4e-compose-new :wk "compose") |
|
| 70 | - | "ms" '(mml-secure-message-sign-pgpmime :wk "sign") |
|
| 71 | - | "me" '(mml-secure-message-encrypt-pgpmime :wk "sign+encrypt") |
|
| 72 | - | "mE" '((lambda () (interactive) (mml-secure-message-encrypt-pgpmime t)) |
|
| 73 | - | :wk "encrypt only") |
|
| 74 | - | "md" '(my/mail-decrypt-bridge :wk "decrypt (bridge)") |
|
| 75 | - | "mn" '(mml-unsecure-message :wk "remove sign/encrypt") |
|
| 68 | + | "ll" '(gptel :wk "gptel") |
|
| 69 | + | "la" '(gptel-add :wk "add context") |
|
| 70 | + | "lr" '(gptel-context-remove-all :wk "remove context") |
|
| 71 | + | "lm" '(gptel-menu :wk "menu") |
|
| 72 | + | "ls" '(gptel-send :wk "send") |
|
| 76 | 73 | ||
| 77 | 74 | "u" '(:ignore t :wk "upload") |
|
| 78 | 75 | "uu" '(uguu-upload-file :wk "upload file") |
| 107 | 107 | (autoload 'uguu-upload-file "uguu" nil t) |
|
| 108 | 108 | (autoload 'uguu-upload-clipboard "uguu" nil t) |
|
| 109 | 109 | ||
| 110 | + | (defgroup openrouter nil |
|
| 111 | + | "OpenRouter backend for gptel." |
|
| 112 | + | :group 'gptel) |
|
| 113 | + | ||
| 114 | + | (defcustom openrouter-pass-entry "openrouter/openrouter-api-key" |
|
| 115 | + | "Name of the `pass' entry holding the API key." |
|
| 116 | + | :type 'string |
|
| 117 | + | :group 'openrouter) |
|
| 118 | + | ||
| 119 | + | (defun openrouter--api-key () |
|
| 120 | + | "Return the OpenRouter API key from password-store." |
|
| 121 | + | (require 'auth-source-pass) ; autoloaded in Emacs 28+, but cheap to be explicit |
|
| 122 | + | (let ((key (auth-source-pass-get 'secret openrouter-pass-entry))) |
|
| 123 | + | (or (and key (string-trim key)) |
|
| 124 | + | (user-error "No pass entry `%s'" openrouter-pass-entry)))) |
|
| 125 | + | ||
| 126 | + | (use-package gptel |
|
| 127 | + | :defer t |
|
| 128 | + | :config |
|
| 129 | + | (setq gptel-backend |
|
| 130 | + | (gptel-make-openai "OpenRouter" |
|
| 131 | + | :host "openrouter.ai" |
|
| 132 | + | :endpoint "/api/v1/chat/completions" |
|
| 133 | + | :stream t |
|
| 134 | + | :key #'openrouter--api-key |
|
| 135 | + | :request-params '(:tools [(:type "openrouter:web_search")]) |
|
| 136 | + | :models '(z-ai/glm-5.3 |
|
| 137 | + | z-ai/glm-5.3-flash |
|
| 138 | + | z-ai/glm-5.3-flashx)))) |
|
| 139 | + | ||
| 140 | + | (defun gptel-model (model) |
|
| 141 | + | "Set the gptel model in the current buffer." |
|
| 142 | + | (interactive |
|
| 143 | + | (list (intern (completing-read "Model: " |
|
| 144 | + | '("z-ai/glm-5.3" |
|
| 145 | + | "z-ai/glm-5.3-flash" |
|
| 146 | + | "z-ai/glm-5.3-flashx"))))) |
|
| 147 | + | (setq-local gptel-model model)) |
|
| 148 | + | ||
| 149 | + | (use-package markdown-mode |
|
| 150 | + | :defer t) |
|
| 151 | + | ||
| 152 | + | ||
| 110 | 153 | (provide 'init-tools) |