Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshcho/chatgpt.el
ChatGPT in Emacs
https://github.com/joshcho/chatgpt.el
chatgpt emacs
Last synced: 3 months ago
JSON representation
ChatGPT in Emacs
- Host: GitHub
- URL: https://github.com/joshcho/chatgpt.el
- Owner: joshcho
- License: gpl-3.0
- Created: 2022-12-10T10:43:20.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-31T22:48:37.000Z (about 1 year ago)
- Last Synced: 2024-06-15T15:36:08.709Z (5 months ago)
- Topics: chatgpt, emacs
- Language: Emacs Lisp
- Homepage:
- Size: 83 KB
- Stars: 395
- Watchers: 9
- Forks: 34
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
- awesome-ChatGPT-repositories - ChatGPT.el - ChatGPT in Emacs (Others)
README
#+TITLE: ChatGPT.el
[[https://chat.openai.com/chat][ChatGPT]] in Emacs.
** Features
- Send *regions* of text to ChatGPT
- *Syntax highlighting* for returned code
- Uses [[https://github.com/llm-workflow-engine/llm-workflow-engine][llm-workflow-engine]], so can customize as needed
** News
- 9/10/2023: Status - I use this every day and is stable. Please submit an issue if not.
- 7/8/2023: Shortcut customization has been reworked, see [[Code Query Shortcuts][here]].
** Installation
*** Dependency
Set your [[https://platform.openai.com/account/api-keys][OpenAI API key]]. In ~.zshrc/bashrc~,
#+begin_src shell
export OPENAI_API_KEY=
#+end_src
For Windows users, see [[https://www.computerhope.com/issues/ch000549.htm][here]].Install [[https://github.com/llm-workflow-engine/llm-workflow-engine][llm-workflow-engine]] (lwe):
#+begin_src shell
pip install --upgrade pip
pip install setuptools
pip install git+https://github.com/llm-workflow-engine/llm-workflow-engine
#+end_srcIf you encounter any problems, please submit an issue or refer to [[https://github.com/llm-workflow-engine/llm-workflow-engine][llm-workflow-engine]] (formerly chatgpt-wrapper).
*** [[https://github.com/radian-software/straight.el][Straight]]
#+begin_src emacs-lisp
(use-package chatgpt
:straight (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el"))
:bind ("C-c q" . chatgpt-query))
#+end_src*** [[https://github.com/quelpa/quelpa][Quelpa]]
#+begin_src emacs-lisp
(require 'quelpa-use-package)
(use-package chatgpt
:quelpa ((chatgpt :fetcher git :url "https://github.com/joshcho/ChatGPT.el.git") :upgrade t)
:bind ("C-c q" . chatgpt-query))
#+end_src*** [[https://www.spacemacs.org/][Spacemacs]]
Assuming Quelpa installation:
In ~dotspacemacs/user-config~ function,
#+begin_src emacs-lisp
(global-set-key (kbd "C-c q") #'chatgpt-query)
#+end_srcIn ~dotspacemacs/layers~ function for ~setq-default~,
#+begin_src emacs-lisp
dotspacemacs-additional-packages
'(
(chatgpt :location (recipe
:fetcher github
:repo "joshcho/ChatGPT.el"))
;; other additional packages...
)
#+end_src*** [[https://github.com/doomemacs/doomemacs][Doom Emacs]]
In ~packages.el~ ,
#+begin_src emacs-lisp
(package! chatgpt
:recipe (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el")))
#+end_srcIn ~config.el~ ,
#+begin_src emacs-lisp
(use-package! chatgpt
:defer t
:bind ("C-c q" . chatgpt-query))
#+end_src** Usage
Press ~C-c q~ to query ChatGPT. Select a code block before ~C-c q~ to query the code.** Customization
*** Chat
Configure default model, system message, browser backend, etc. with [[https://llm-workflow-engine.readthedocs.io/en/latest/configuration.html][llm-workflow-engine]].
*** Code Query Shortcuts
Customize ~chatgpt-code-query-map~ for your own prompt shortcuts. Note that "custom" is a reserved prompt shortcut.#+begin_src emacs-lisp
(setq chatgpt-code-query-map
'(
;; ChatGPT.el defaults, string for each shortcut
("bug" . "There is a bug in the following, please help me fix it.")
("doc" . "Please write the documentation for the following.")
("improve" . "Please improve the following.")
("understand" . "What is the following?")
("refactor" . "Please refactor the following.")
("suggest" . "Please make suggestions for the following.")
;; your shortcut
("prompt-name" . "My custom prompt.")))
#+end_srcIf you previously had customizations, note that we use strings now, not format strings.
** Limitations
- Multiline input is not supported yet** Related Projects
- [[https://github.com/suonlight/ob-chatgpt][ob-chatgpt]]
- [[https://github.com/semiosis/pen.el][Pen.el]]