/chatgpt

Use ChatGPT inside Emacs

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

License: GPL v3 JCS-ELPA

chatgpt

Use ChatGPT inside Emacs

CI

This Emacs Code extension allows you to use the official OpenAI API to generate code or natural language responses from OpenAI's ChatGPT to your questions, right within the editor.

P.S. This plugin focuses on experience with making conversations with ChatGPT!

explain

๐Ÿ’พ Installation

package.el

This package is available from JCS-ELPA. Install from these repositories then you should be good to go!

Normally, you don't need to add (require 'chatgpt) to your configuration since most 'chatgpt commands are autoload and can be called without loading the module!

use-package

If you are using use-package, add the following to your init.el file:

(use-package 'chatgpt :ensure t)

or with straight.el:

(use-package 'chatgpt
  :straight ('chatgpt :type git :host github :repo "emacs-openai/'chatgpt"))

Manual installation

Copy all .el files in this repository to ~/.emacs.d/lisp and add the following:

(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'chatgpt)

๐Ÿ”‘ Obtaining API key

To use this extension, you will need an API key from OpenAI. To obtain one, follow these steps:

  1. Go to OpenAI's website. If you don't have an account, you will need to create one or sign up using your Google or Microsoft account.
  2. Click on the Create new secret key button.
  3. Copy the key and paste into the 'API Key' field under the 'openai' custom group settings.

When you create a new account, you receive $18 in free credits for the API which you must use in the first 90 days. You can see pricing information here. 1000 tokens are about 700 words, and you can see the token count for each request at the end of the response in the sidebar.

๐Ÿ”จ Usage

To start this package:

M-x chatgpt

You will then be asked to insert your response; in this window, you press return to send the message, and Shift+return to insert a newline like a normal browser!

๐Ÿ“ Customization

๐Ÿงช Variables

  • chatgpt-model - ID of the model to use.
  • chatgpt-max-tokens - The maximum number of tokens to generate in the completion.
  • chatgpt-temperature - What sampling temperature to use.
  • chatgpt-input-method - Method to receive input.
  • chatgpt-spinner-type - Type of the spinner.
  • chatgpt-display-tokens-info - Non-nil we display tokens information for each request.

๐Ÿ”— References

Contribute

PRs Welcome Elisp styleguide Donate on paypal Become a patron

If you would like to contribute to this project, you may either clone and make pull requests to this repository. Or you can clone the project and establish your own branch of this tool. Any methods are welcome!