summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVineet Kumar <git@vineetk.net>2026-04-15 10:56:17 -0400
committerVineet Kumar <git@vineetk.net>2026-04-15 10:59:19 -0400
commit88701b4c01498f5bd987f71d01e34eeda4f90e62 (patch)
tree4e21973211b0020ceb89011aca7afa893e7fb67e
parent6c25a2f8f115ec2d29557ca7731d41ee4866ed1e (diff)
emacs: add gptel-agent
-rw-r--r--epistemia/packages/emacs.scm160
1 files changed, 160 insertions, 0 deletions
diff --git a/epistemia/packages/emacs.scm b/epistemia/packages/emacs.scm
index 0488898..87d8087 100644
--- a/epistemia/packages/emacs.scm
+++ b/epistemia/packages/emacs.scm
@@ -65,3 +65,163 @@ underline style instead of regular underline. (setq kaolin-themes-underline-wave
65t) ;; When t, will display colored hl-line style (setq 65t) ;; When t, will display colored hl-line style (setq
66kaolin-themes-hl-line-colored t).") 66kaolin-themes-hl-line-colored t).")
67 (license license:gpl3))) 67 (license license:gpl3)))
68
69(define-public emacs-gptel-new
70 (package
71 (name "emacs-gptel-new")
72 (version "20260410.711")
73 (source
74 (origin
75 (method git-fetch)
76 (uri (git-reference
77 (url "https://github.com/karthink/gptel")
78 (commit "8d6411b5f89d796c817ff79324973b8910e164fe")))
79 (file-name (git-file-name name version))
80 (sha256
81 (base32 "0zl5qdp9qqh8chadsp2m3jpbpsxlywdlfkax8p97y73q1yias0q6"))))
82 (build-system emacs-build-system)
83 (propagated-inputs (list emacs-transient emacs-compat))
84 (home-page "https://github.com/karthink/gptel")
85 (synopsis "Interact with ChatGPT or other LLMs")
86 (description
87 "gptel is a simple Large Language Model chat client, with support for multiple
88models and backends. It works in the spirit of Emacs, available at any time and
89in any buffer. gptel supports: - The services @code{ChatGPT}, Azure, Gemini,
90Anthropic AI, Together.ai, Perplexity, AI/ML API, Anyscale, @code{OpenRouter},
91Groq, @code{PrivateGPT}, @code{DeepSeek}, Cerebras, Github Models, @code{GitHub}
92Copilot chat, AWS Bedrock, Novita AI, @code{xAI}, Sambanova, Mistral Le Chat and
93Kagi (@code{FastGPT} & Summarizer). - Local models via Ollama, Llama.cpp,
94Llamafiles or GPT4All Additionally, any LLM service (local or remote) that
95provides an @code{OpenAI-compatible} API is supported. Features: - Interact
96with LLMs from anywhere in Emacs (any buffer, shell, minibuffer, wherever). -
97LLM responses are in Markdown or Org markup. - Supports conversations and
98multiple independent sessions. - Supports tool-use to equip LLMs with agentic
99capabilities. - Supports Model Context Protocol (MCP) integration using the
100mcp.el package. - Supports multi-modal models (send images, documents). -
101Supports \"reasoning\" content in LLM responses. - Save chats as regular
102Markdown/Org/Text files and resume them later. - You can go back and edit your
103previous prompts or LLM responses when continuing a conversation. These will be
104fed back to the model. - Redirect prompts and responses easily - Rewrite,
105refactor or fill in regions in buffers. - Write your own commands for custom
106tasks with a simple API. Requirements for @code{ChatGPT}, Azure, Gemini or Kagi:
107- You need an appropriate API key. Set the variable `gptel-api-key to the key
108or to a function of no arguments that returns the key. (It tries to use
109`auth-source by default) @code{ChatGPT} is configured out of the box. For the
110other sources: - For Azure: define a gptel-backend with `gptel-make-azure'. -
111For Gemini: define a gptel-backend with `gptel-make-gemini'. - For Anthropic
112(Claude): define a gptel-backend with `gptel-make-anthropic'. - For AI/ML API,
113Together.ai, Anyscale, Groq, @code{OpenRouter}, @code{DeepSeek}, Cerebras or
114Github Models: define a gptel-backend with `gptel-make-openai'. - For
115@code{PrivateGPT}: define a backend with `gptel-make-privategpt'. - For
116Perplexity: define a backend with `gptel-make-perplexity'. - For Deepseek:
117define a backend with `gptel-make-deepseek'. - For Kagi: define a gptel-backend
118with `gptel-make-kagi'. For local models using Ollama, Llama.cpp or GPT4All: -
119The model has to be running on an accessible address (or localhost) - Define a
120gptel-backend with `gptel-make-ollama or `gptel-make-gpt4all'. - Llama.cpp or
121Llamafiles: Define a gptel-backend with `gptel-make-openai'. Consult the
122package README for examples and more help with configuring backends. Usage:
123gptel can be used in any buffer or in a dedicated chat buffer. The interaction
124model is simple: Type in a query and the response will be inserted below. You
125can continue the conversation by typing below the response. To use this in any
126buffer: - Call `gptel-send to send the buffer's text up to the cursor. Select a
127region to send only the region. - You can select previous prompts and responses
128to continue the conversation. - Call `gptel-send with a prefix argument to
129access a menu where you can set your backend, model and other parameters, or to
130redirect the prompt/response. To use this in a dedicated buffer: - M-x gptel:
131Start a chat session. - In the chat session: Press `C-c RET (`gptel-send') to
132send your prompt. Use a prefix argument (`C-u C-c RET') to access a menu. In
133this menu you can set chat parameters like the system directives, active backend
134or model, or choose to redirect the input or output elsewhere (such as to the
135kill ring or the echo area). - You can save this buffer to a file. When opening
136this file, turn on `gptel-mode before editing it to restore the conversation
137state and continue chatting. - To include media files with your request, you can
138add them to the context (described next), or include them as links in Org or
139Markdown mode chat buffers. Sending media is disabled by default, you can turn
140it on globally via `gptel-track-media', or locally in a chat buffer via the
141header line. Include more context with requests: If you want to provide the LLM
142with more context, you can add arbitrary regions, buffers, files or directories
143to the query with `gptel-add'. To add text or media files, call `gptel-add in
144Dired or use the dedicated `gptel-add-file'. You can also add context from
145gptel's menu instead (`gptel-send with a prefix arg), as well as examine or
146modify context. When context is available, gptel will include it with each LLM
147query. LLM Tool use: gptel supports \"tool calling\" behavior, where LLMs can
148specify arguments with which to call provided \"tools\" (elisp functions). The
149results of running the tools are fed back to the LLM, giving it capabilities and
150knowledge beyond what is available out of the box. For example, tools can
151perform web searches or API lookups, modify files and directories, and so on.
152Tools can be specified via `gptel-make-tool', or obtained from other
153repositories, or from Model Context Protocol (MCP) servers using the mcp.el
154package. See the README for details. Tools can be included with LLM queries
155using gptel's menu, or from `gptel-tools'. Rewrite interface In any buffer:
156with a region selected, you can rewrite prose, refactor code or fill in the
157region. This is accessible via `gptel-rewrite', and also from the `gptel-send
158menu. Presets Define a bundle of configuration (model, backend, system message,
159tools etc) as a \"preset\" that can be applied together, making it easy to switch
160between tasks in gptel. Presets can be saved and applied from gptel's transient
161menu. You can also include a cookie of the form \"@@preset-name\" in the prompt
162to send a request with a preset applied. This feature works everywhere, but
163preset cookies are also fontified in chat buffers. gptel in Org mode: gptel
164offers a few extra conveniences in Org mode: - You can limit the conversation
165context to an Org heading with `gptel-org-set-topic'. - You can have branching
166conversations in Org mode, where each hierarchical outline path through the
167document is a separate conversation branch. See the variable
168`gptel-org-branching-context'. - You can declare the gptel model, backend,
169temperature, system message and other parameters as Org properties with the
170command `gptel-org-set-properties'. gptel queries under the corresponding
171heading will always use these settings, allowing you to create mostly
172reproducible LLM chat notebooks. Finally, gptel offers a general purpose API
173for writing LLM ineractions that suit your workflow. See `gptel-request', and
174`gptel-fsm for more advanced usage.")
175 (license license:gpl3)))
176
177(define-public emacs-gptel-agent
178 (package
179 (name "emacs-gptel-agent")
180 (version "20260412.716")
181 (source
182 (origin
183 (method git-fetch)
184 (uri (git-reference
185 (url "https://github.com/karthink/gptel-agent")
186 (commit "bef06bccdbf847e0c4a94d1b57dd96d979437430")))
187 (file-name (git-file-name name version))
188 (sha256
189 (base32 "1g33w8db2g33l3qf4f9vnafkdpilaxh4s9cy76yv79rphg92ipaw"))))
190 (build-system emacs-build-system)
191 (propagated-inputs (list emacs-compat emacs-gptel-new emacs-yaml
192 emacs-orderless))
193 (arguments
194 '(#:include '("^[^/]*.el$" "^[^/]*.el.in$"
195 "^dir$"
196 "^[^/]*.info$"
197 "^[^/]*.texi$"
198 "^[^/]*.texinfo$"
199 "^doc/dir$"
200 "^doc/[^/]*.info$"
201 "^doc/[^/]*.texi$"
202 "^doc/[^/]*.texinfo$"
203 "^agents$")
204 #:exclude '("^.dir-locals.el$" "^test.el$" "^tests.el$"
205 "^[^/]*-test.el$" "^[^/]*-tests.el$")))
206 (home-page "https://github.com/karthink/gptel-agent")
207 (synopsis "Agentic LLM use for gptel")
208 (description
209 "This is a collection of tools and prompts to use gptel \"agentically\" with any
210LLM, to autonomously perform tasks. It has access to - the web (via basic web
211search, URL fetching and @code{YouTube} video metadata), - local files
212(read/write/edit), - the state of Emacs (documentation and Elisp evaluation), -
213and Bash, if you are in a POSIX-y environment. To use gptel-agent in a
214dedicated buffer: - Set `gptel-model and `gptel-backend to use your preferred
215LLM. - Run M-x `gptel-agent'. This will open a buffer with the agent preset
216loaded. - Use gptel as usual, calling `gptel-send etc. - If you change the
217system prompt, tools or other settings in this buffer, you can reset the agent
218state by (re)applying the \"gptel-agent\" preset from gptel's menu. To use
219gptel-agent anywhere in Emacs: - As with gptel, you can use gptel-agent in any
220buffer. Just apply the \"gptel-agent\" preset in the buffer, or include
221\"@@gptel-agent\" in a prompt. gptel-agent can delegate tasks to \"sub-agents\".
222Sub-agents can be specified in Markdown or Org files in a directory. To see how
223to specify agents, examine the \"agents\" directory in this package. You can add
224your directory of agents to `gptel-agent-dirs', which see. Please note:
225gptel-agent uses significantly more tokens than the average gptel LLM
226interaction.")
227 (license license:gpl3)))