/ChatGPT.el

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

ChatGPT.el

ChatGPT in Emacs. Demo

Installation

Authentication

Follow instructions at acheong08/ChatGPT and create config.json in your home directory, not local.

Straight

(use-package chatgpt
  :straight (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el"))
  :bind ("C-c q" . chatgpt-query)
  :config
  (setq chatgpt-repo-path "~/.emacs.d/straight/repos/ChatGPT.el/"))

Quelpa

(quelpa '(chatgpt :fetcher git :url "https://github.com/joshcho/ChatGPT.el.git"))
(use-package chatgpt
  :quelpa t
  :bind ("C-c q" . chatgpt-query)
  :config
  (setq chatgpt-repo-path (expand-file-name "ChatGPT.el" quelpa-build-dir)))

Usage

  • Press C-c q to query ChatGPT.
  • Select region before C-c q to query ChatGPT by type.

Customization

Customize chatgpt-query-types for your own types.

(setq chatgpt-query-types '(
                            ;; ChatGPT.el defaults
                            ("doc" . "Please write the documentation for the following function.\n\n%s")
                            ("bug" . "There is a bug in the following function, please help me fix it.\n\n%s")
                            ("understand" . "What does the following function do?\n\n%s")
                            ("improve" . "Please improve the following code.\n\n%s")
                            ;; your new prompt
                            ("my-custom-type" . "My custom prompt.\n\n%s")))

Misc.

  • Don’t use “custom” as a type. It’s reserved for custom prepend string through minibuffer.

Future Roadmap

  • Authenticate using browser
  • Add more query types
  • Add structure to \*ChatGPT\* buffer
  • Don’t force config.json in home