Coder Social home page Coder Social logo

chatgpt.el's Introduction

ChatGPT.el

ChatGPT in Emacs.

Features

  • Send regions of text to ChatGPT
  • Syntax highlighting for returned code
  • Uses 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 here.

Installation

Dependency

Set your OpenAI API key. In .zshrc/bashrc,

export OPENAI_API_KEY=<API_KEY>

For Windows users, see here.

Install llm-workflow-engine:

pip install --upgrade pip
pip install setuptools
pip install git+https://github.com/llm-workflow-engine/llm-workflow-engine

If you encounter any problems, please submit an issue or refer to llm-workflow-engine (formerly chatgpt-wrapper).

(use-package chatgpt
  :straight (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el"))
  :bind ("C-c q" . chatgpt-query))
(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))

Assuming Quelpa installation:

In dotspacemacs/user-config function,

(global-set-key (kbd "C-c q") #'chatgpt-query)

In dotspacemacs/layers function for setq-default,

dotspacemacs-additional-packages
'(
  (chatgpt :location (recipe
                      :fetcher github
                      :repo "joshcho/ChatGPT.el"))
  ;; other additional packages...
  )

In packages.el ,

(package! chatgpt
  :recipe (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el")))

In config.el ,

(use-package! chatgpt
  :defer t
  :bind ("C-c q" . chatgpt-query))

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 llm-workflow-engine.

Code Query Shortcuts

Customize chatgpt-code-query-map for your own prompt shortcuts. Note that “custom” is a reserved prompt shortcut.

(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.")))

If you previously had customizations, note that we use strings now, not format strings.

Limitations

  • Multiline input is not supported yet

Related Projects

chatgpt.el's People

Contributors

andorsk avatar barryridge avatar cnsunyour avatar diamondbond avatar joshcho avatar tkhaos avatar torfjelde avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.