There are a few packages and libraries that are being built to use ChatGPT along with Emacs.
This page is becoming fairly popular in search results so please let me know if there are other libraries you love or think I should try out.
Recommended
I use the following libraries myself for both writing code and prose (more prose than code these days).
- GPTel focuses on a chat client session within an Emacs buffer and sending text from the buffer (like a selected region or line). Also uses a transient menu (a la
magit
) for on-the-fly configuration like custom prompts and models to use. - ChatGPT Shell is an
eshell
for ChatGPT and dall-e that fascilitats interacting with a chat session. By default it’s prompt is configured for helping with writing code.
Best of the rest
An incomplete list of other libraries I’ve come across.
- Emacs OpenAI has a collection of packages for using ChatGPT and dall-e
- ChatGPT.el was one of the first, but hasn’t been updated to use the official API yet
- ChatGPT Arcana is a more integrated approach including prompt from region
- org-ai combines OpenAI whisper and GPT so you can talk to Emacs (also has a nifty
begin_ai
block for org-mode) - leafy-mode adds completions to
org-mode
using ChatGPT
Querying your own data
Most of the libraries mentioned rely on the user to send text to a chat session. However, they don’t have ways to index your own data to provide context to a chat session or for single-shot completions.
For example, I wrote a LangChain agent for helping me chat with my notes (also named org-ai, oh well!). While it’s one of one software and I have no intention of making it generic, you could adapt it to your own use.
Links to this note
-
Org-Mode Count the Number of Headings in a Region
Sometimes I want to see how many headings are in an org-mode file I’m working in. For example, I like to know the number of items I have to refile.
-
I use org-mode for taking notes and keeping track of tasks. I use Notion for work as an internal wiki.
-
Capture Output of Chatgpt-Shell in Org-Mode
I’m messing around with ChatGPT in Emacs and I want to capture the results of a session in org-mode. Since
chatgpt-shell
is just a buffer (like everything else in emacs), we can write an elisp source block to grab the contents of buffer. Even better, we can tell org-mode to export the results as a markdown block since the code examples all use code fences (the triple backtick).