đź”® ChatGPT-Arcana is an Emacs Lisp package that gives you arcane powers. Yer a space wizard now, Harry.
demo1.mp4
demo2.mp4
demo3.mp4
chatgpt-jedi-2023-03-03_12.18.52.mp4
There are various interactive functions available. Some of them even work.
This package, for now, provides the following functionality:
- Chat with GPT in Emacs with
chatgpt-arcana-chat-start-chat
(this is the best part of this package). - Generate text content based on prompt and optionally selected region using
chatgpt-arcana-query
- Replace selected text region with generated text content using
chatgpt-arcana-replace-region
- Insert generated text at the current cursor position with informative context lines using
chatgpt-arcana-insert-at-point-with-context
- Insert generated text at, after or before selected text region using
chatgpt-arcana-insert-after-region
andchatgpt-arcana-insert-before-region
andchatgpt-arcana-insert-at-point
- Chat buffer auto-naming (modify prompt with custom var
chatgpt-arcana-generated-buffer-name-prompt
) - Chat session autosave and automatic file naming (disable with custom var
chatgpt-arcana-chat-autosave-enabled
, modify save directory withchatgpt-arcana-chat-autosave-directory
)
ChatGPT-Arcana isn’t on melpa or elpa. You can use use-package to install from github:
(use-package chatgpt-arcana
:straight (:host github :repo "CarlQLange/ChatGPT-Arcana.el" :files ("*.el"))
:init (setq chatgpt-arcana-api-key "your-api-key-here"))
You may wish to use .authinfo
or similar to hold your API key. You can do this by creating or adding to your ~/.authinfo
file like the following:
machine chat.openai.com login YOUR_CHATGPT_EMAIL_HERE password YOUR_API_KEY_HERE
and using the line
(setq chatgpt-arcana-api-key (auth-source-pick-first-password
:host "chat.openai.com"))
in your config.
My own config adds a few extra parts that don't need to be part of the package.
(use-package chatgpt-arcana
:straight (:host github :repo "CarlQLange/ChatGPT-Arcana.el" :files ("*.el"))
:init (setq chatgpt-arcana-api-key "your-api-key-here")
:config
(use-package all-the-icons
:config
(add-to-list 'all-the-icons-mode-icon-alist
'(chatgpt-arcana-chat-mode all-the-icons-octicon "comment-discussion" :height 1.0 :v-adjust -0.1 :face all-the-icons-purple)))
(use-package pretty-hydra
:config
(eval `(pretty-hydra-define chatgpt-arcana-hydra (:color blue :quit-key "q" :title "ChatGPT Arcana")
("Query"
(("a" chatgpt-arcana-query "Query")
("r" chatgpt-arcana-replace-region "Replace region"))
"Insert"
(("i" chatgpt-arcana-insert-at-point-with-context "At point with context")
("I" chatgpt-arcana-insert-at-point "At point")
("j" chatgpt-arcana-insert-after-region "Before region")
("J" chatgpt-arcana-insert-before-region "After region"))
"Chat"
(("c" chatgpt-arcana-start-chat "Start chat"))
"Shortcuts"
(,@(chatgpt-arcana-generate-prompt-shortcuts))))))
(map! :leader
:prefix ("[" . "ChatGPT")
:desc "Start chat" :g "c" #'chatgpt-arcana-start-chat
:desc "Start chat" :g "[" #'chatgpt-arcana-start-chat
:desc "Open Hydra" :g "h" #'chatgpt-arcana-hydra/body))
You are going to want to add a keymap of your own, that's for sure :)
I have to stress at this point that this package is very new, and I only wrote it to scratch an itch. Sorry if it turns you into a chicken or something.
You will need to have an API key from OpenAI’s GPT-3 language model to use this package, and set it as chatgpt-arcana-api-key
. You can sign up for an API key on the OpenAI website. Depending on how much you use the package, the API cost may vary.
I strongly recommend setting a low usage limit on your account to stop runaway spending. The default model is quite cheap but it costs nothing to be prudent.
I have done exactly zero work in terms of compatibility. It works on my machine, sometimes. Maybe it'll even work on yours. Also, even though ChatGPT is pretty much the largest computing leap since the iPhone, it has its own limitations. Particularly, I've noticed it's pretty terrible at writing org-mode - I guess due to a lack of source data. Hence, the chatgpt-arcana-chat-mode
is based on Markdown.
This package was developed by Carl Lange with judicious help from ChatGPT.
Other contributors and contributions:
- GitHub user macownersclub for PR #6
- GitHub user vxe for authinfo tip in issue #8
This package is licensed under the GNU General Public License v3.0.
Important note: code generated by ChatGPT probably has a massive license headache attached to it and may result in RMS eating your dog.