add gregory grubbs ai stuff
This commit is contained in:
parent
0081b2ec37
commit
c0a3ae4a24
1 changed files with 249 additions and 229 deletions
206
init.org
206
init.org
|
@ -1,3 +1,4 @@
|
|||
|
||||
#+TITLE: My Emacs Configuration
|
||||
#+PROPERTY: header-args :tangle 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
|
||||
|
||||
#+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-directory
|
||||
(executable-find "mu")))
|
||||
"share/emacs/site-lisp/mu4e"))
|
||||
"share/emacs/site-lisp/mu4e")))
|
||||
|
||||
(use-package mu4e
|
||||
:load-path snm/mu4e-load-path
|
||||
|
@ -1652,6 +1655,7 @@ importing and exporting confluence pages.
|
|||
(setq message-kill-buffer-on-exit t)
|
||||
|
||||
)
|
||||
))
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
@ -3113,7 +3117,8 @@ integration in Emacs.
|
|||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package gptel
|
||||
:ensure t
|
||||
:commands (gptel)
|
||||
;:commands (gptel)
|
||||
:demand t
|
||||
:config
|
||||
(setq gptel-default-mode 'org-mode
|
||||
gptel-expert-commands t
|
||||
|
@ -3128,87 +3133,10 @@ integration in Emacs.
|
|||
(add-hook 'gptel-post-stream-hook 'gptel-auto-scroll)
|
||||
;; move to next prompt after response
|
||||
(add-hook 'gptel-post-response-functions 'gptel-end-of-response)
|
||||
)
|
||||
|
||||
(use-package gptel-curl)
|
||||
(use-package gptel-transient)
|
||||
(use-package 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 GPTel’s 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
|
||||
(require 'gptel-curl)
|
||||
(require 'gptel-transient)
|
||||
(require 'gptel-integrations)
|
||||
(setq gptel-api-key openai-api-key)
|
||||
(gptel-make-gemini "Gemini" :key gemini-api-key :stream t)
|
||||
(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"))
|
||||
|
||||
|
||||
#+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
|
||||
:function (lambda (url)
|
||||
(with-current-buffer (url-retrieve-synchronously url)
|
||||
|
@ -3261,6 +3179,7 @@ install the Emacs dependencies yaml and templatel.
|
|||
:category "emacs")
|
||||
|
||||
;; Message buffer logging tool
|
||||
|
||||
(gptel-make-tool
|
||||
:function (lambda (text)
|
||||
(message "%s" text)
|
||||
|
@ -3273,6 +3192,7 @@ install the Emacs dependencies yaml and templatel.
|
|||
:category "emacs")
|
||||
|
||||
;; buffer retrieval tool
|
||||
|
||||
(gptel-make-tool
|
||||
:function (lambda (buffer)
|
||||
(unless (buffer-live-p (get-buffer buffer))
|
||||
|
@ -3349,8 +3269,108 @@ install the Emacs dependencies yaml and templatel.
|
|||
:category "filesystem")
|
||||
|
||||
|
||||
|
||||
)
|
||||
#+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 GPTel’s 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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue