add gregory grubbs ai stuff

This commit is contained in:
Peter Tillemans 2025-08-13 12:10:40 +02:00
parent 0081b2ec37
commit c0a3ae4a24

206
init.org
View file

@ -1,3 +1,4 @@
#+TITLE: My Emacs Configuration #+TITLE: My Emacs Configuration
#+PROPERTY: header-args :tangle yes #+PROPERTY: header-args :tangle yes
#+PROPERTY: header-args:emacs-lisp :lexical yes :tangle yes :comments nil :padline yes #+PROPERTY: header-args:emacs-lisp :lexical yes :tangle yes :comments nil :padline yes
@ -1573,11 +1574,13 @@ importing and exporting confluence pages.
** Mu4e Configuration ** Mu4e Configuration
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq snm/mu4e-load-path (concat (defvar snm/mu4e-load-path nil)
(if (executable-find "mu")
(let ((snm/mu4e-load-path (concat
(file-name-parent-directory (file-name-parent-directory
(file-name-directory (file-name-directory
(executable-find "mu"))) (executable-find "mu")))
"share/emacs/site-lisp/mu4e")) "share/emacs/site-lisp/mu4e")))
(use-package mu4e (use-package mu4e
:load-path snm/mu4e-load-path :load-path snm/mu4e-load-path
@ -1652,6 +1655,7 @@ importing and exporting confluence pages.
(setq message-kill-buffer-on-exit t) (setq message-kill-buffer-on-exit t)
) )
))
#+END_SRC #+END_SRC
#+RESULTS: #+RESULTS:
@ -3113,7 +3117,8 @@ integration in Emacs.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package gptel (use-package gptel
:ensure t :ensure t
:commands (gptel) ;:commands (gptel)
:demand t
:config :config
(setq gptel-default-mode 'org-mode (setq gptel-default-mode 'org-mode
gptel-expert-commands t gptel-expert-commands t
@ -3128,87 +3133,10 @@ integration in Emacs.
(add-hook 'gptel-post-stream-hook 'gptel-auto-scroll) (add-hook 'gptel-post-stream-hook 'gptel-auto-scroll)
;; move to next prompt after response ;; move to next prompt after response
(add-hook 'gptel-post-response-functions 'gptel-end-of-response) (add-hook 'gptel-post-response-functions 'gptel-end-of-response)
)
(use-package gptel-curl) (require 'gptel-curl)
(use-package gptel-transient) (require 'gptel-transient)
(use-package gptel-integrations) (require 'gptel-integrations)
#+END_SRC
#+RESULTS:
*** Load jwiegley/gptel-prompts for prompt composability
This package offers an alternative way to manage your ~gptel-directives~ variable, using files rather than customizing the variable directly.
Whenever your prompt files change, you must arrange for
~gptel-prompts-update~ to be called, which will update gptel-directives
appropriately.
#+begin_src emacs-lisp :tangle no
(use-package gptel-prompts
:ensure t
:after (gptel)
:demand t
:config
(gptel-prompts-update)
;; Ensure prompts are updated if prompt files change
(gptel-prompts-add-update-watchers))
#+end_src
**** Different prompt types
You may now put prompts, one per file, in the directory
gptel-prompts-directory, which by default is
"~/.emacs.d/prompts". Prompts may be one of three different kinds:
Plain text
If the file extension is *.txt, .md or .org*, the content of the file is
used directly, as if you had added that string to ~gptel-directives~.
Emacs Lisp lists
If the file extension is *.el*, the file must evaluate to a list of
strings and/or symbols, as expected by ~gptel-directives~. Please see
the documentation of that variable for more information. Prompt Poet
templates
Based on the standard set by Prompt Poet, files ending in *.poet* or
*.jinja* will be interpreted as YAML files using Jinja templating. The
templating is applied first, before it is parsed as a Yaml file.
This is done dynamically, at the time the prompt is used, so you can
see the results of your expansion using GPTels Inspect capabilities
when ~gptel-expert-commands~ is set to a non-nil value. Here is an
example poet prompt.:
#+begin_src
- role: system
content: >-
You are an Latin-American Spanish translator, spelling corrector and
improver. I will speak to you in English, and you will translate and
answer in the corrected and improved version of my text, in Latin-American
Spanish. I want you to replace my simplified A0-level words and sentences
with more beautiful and elegant, upper level Latin-American Spanish words
and sentences. Keep the meaning same, but make them more literary and
clear. I want you to only reply with the correction, the improvements and
nothing else, do not write explanations.
- role: user
content: |
Please translate the following into Spanish. The time is {{
current_time }}:
#+end_src
Note the ~>-~ and ~|~ content directives, which are used to manage when
and where newlines appear in the actual prompts, while allowing the
file itself to use what is easiest to maintain in the editor.
NOTE: If you wish to use the Prompt Poet format, you will need to
install the Emacs dependencies yaml and templatel.
*** Models
#+BEGIN_SRC emacs-lisp
(setq gptel-api-key openai-api-key) (setq gptel-api-key openai-api-key)
(gptel-make-gemini "Gemini" :key gemini-api-key :stream t) (gptel-make-gemini "Gemini" :key gemini-api-key :stream t)
(gptel-make-anthropic "Claude" :stream t :key anthropic-api-key) (gptel-make-anthropic "Claude" :stream t :key anthropic-api-key)
@ -3217,16 +3145,6 @@ install the Emacs dependencies yaml and templatel.
:description "QWen 2.5 Coder 14b")) :description "QWen 2.5 Coder 14b"))
#+END_SRC
#+RESULTS:
: #s(gptel-ollama "Qwen Coder" "localhost:11434" nil "http" nil "/api/chat" nil (qwen2.5-coder:14b :description QWen\ 2.5\ Coder\ 14b) "http://localhost:11434/api/chat" nil nil nil)
*** Tools
#+BEGIN_SRC emacs-lisp
;; define some tools for gptel
(gptel-make-tool (gptel-make-tool
:function (lambda (url) :function (lambda (url)
(with-current-buffer (url-retrieve-synchronously url) (with-current-buffer (url-retrieve-synchronously url)
@ -3261,6 +3179,7 @@ install the Emacs dependencies yaml and templatel.
:category "emacs") :category "emacs")
;; Message buffer logging tool ;; Message buffer logging tool
(gptel-make-tool (gptel-make-tool
:function (lambda (text) :function (lambda (text)
(message "%s" text) (message "%s" text)
@ -3273,6 +3192,7 @@ install the Emacs dependencies yaml and templatel.
:category "emacs") :category "emacs")
;; buffer retrieval tool ;; buffer retrieval tool
(gptel-make-tool (gptel-make-tool
:function (lambda (buffer) :function (lambda (buffer)
(unless (buffer-live-p (get-buffer buffer)) (unless (buffer-live-p (get-buffer buffer))
@ -3349,8 +3269,108 @@ install the Emacs dependencies yaml and templatel.
:category "filesystem") :category "filesystem")
)
#+END_SRC #+END_SRC
#+RESULTS:
*** TODO Load MCP.el
placeholder
check [[https://www.youtube.com/watch?v=Hkih7jaqOnE&t=544s][Agentic LLM use in Emacs using Model Context Protocol (MCP)]] of
Gregg Grubbs for examples what to put here.
#+BEGIN_SRC emacs-lisp :tangle no
(use-package mcp
:ensure t
:after gptel
:custom (mcp-hub-servers
`(("filesystem" . (:command "npx" :args ("-y" "@modelcontextprotocol/server-filesystem" "/home/lizqwer/MyProject/")))
("fetch" . (:command "uvx" :args ("mcp-server-fetch")))
("qdrant" . (:url "http://localhost:8000/sse"))
("graphlit" . (
:command "npx"
:args ("-y" "graphlit-mcp-server")
:env (
:GRAPHLIT_ORGANIZATION_ID "your-organization-id"
:GRAPHLIT_ENVIRONMENT_ID "your-environment-id"
:GRAPHLIT_JWT_SECRET "your-jwt-secret")))))
:config (require 'mcp-hub)
:hook (after-init . mcp-hub-start-all-server))
#+END_SRC
*** Load jwiegley/gptel-prompts for prompt composability
This package offers an alternative way to manage your ~gptel-directives~ variable, using files rather than customizing the variable directly.
Whenever your prompt files change, you must arrange for
~gptel-prompts-update~ to be called, which will update gptel-directives
appropriately.
#+begin_src emacs-lisp :tangle no
(use-package gptel-prompts
:ensure t
:after (gptel)
:demand t
:config
(gptel-prompts-update)
;; Ensure prompts are updated if prompt files change
(gptel-prompts-add-update-watchers))
#+end_src
**** Different prompt types
You may now put prompts, one per file, in the directory
gptel-prompts-directory, which by default is
"~/.emacs.d/prompts". Prompts may be one of three different kinds:
Plain text
If the file extension is *.txt, .md or .org*, the content of the file is
used directly, as if you had added that string to ~gptel-directives~.
Emacs Lisp lists
If the file extension is *.el*, the file must evaluate to a list of
strings and/or symbols, as expected by ~gptel-directives~. Please see
the documentation of that variable for more information. Prompt Poet
templates
Based on the standard set by Prompt Poet, files ending in *.poet* or
*.jinja* will be interpreted as YAML files using Jinja templating. The
templating is applied first, before it is parsed as a Yaml file.
This is done dynamically, at the time the prompt is used, so you can
see the results of your expansion using GPTels Inspect capabilities
when ~gptel-expert-commands~ is set to a non-nil value. Here is an
example poet prompt.:
#+begin_src
- role: system
content: >-
You are an Latin-American Spanish translator, spelling corrector and
improver. I will speak to you in English, and you will translate and
answer in the corrected and improved version of my text, in Latin-American
Spanish. I want you to replace my simplified A0-level words and sentences
with more beautiful and elegant, upper level Latin-American Spanish words
and sentences. Keep the meaning same, but make them more literary and
clear. I want you to only reply with the correction, the improvements and
nothing else, do not write explanations.
- role: user
content: |
Please translate the following into Spanish. The time is {{
current_time }}:
#+end_src
Note the ~>-~ and ~|~ content directives, which are used to manage when
and where newlines appear in the actual prompts, while allowing the
file itself to use what is easiest to maintain in the editor.
NOTE: If you wish to use the Prompt Poet format, you will need to
install the Emacs dependencies yaml and templatel.
** Copilot Support ** Copilot Support