CHATGPT-SHELL-UPDATED

<2025-02-15 Sat>

Watch the Video Here

How I came across this package

What it does

It allows you to run chatgpt inside Emacs

https://github.com/xenodium/chatgpt-shell/tree/main

Create API

You will first need to get an api key from OpenAI

https://platform.openai.com/account/api-keys

add to .authinfo

machine api.openai.com password [API KEY]

Setup

Install Llama language model

ollama pull llama3.2

Using openai instead

To use openai you will need a paid plan, minimum $5:

https://platform.openai.com/usage

https://platform.openai.com/settings/organization/billing/overview

https://platform.openai.com/settings/organization/limits

(use-package chatgpt-shell
  :ensure t
  :custom
  ((chatgpt-shell-openai-key
    (lambda ()
      (auth-source-pick-first-password :host "api.openai.com")))))
;; (setq chatgpt-shell-model-version "llama3.2")
(setq chatgpt-shell-model-version "gpt-4o")
Some other models:
gpt-4o
gpt-4o-mini
gpt-3.5-turbo
text-embedding-3-small
dall-e-3
tts-1
whisper-1

Most interesting commands

chatgpt-shell
chatgpt-shell-describe-code
chatgpt-shell-explain-code
chatgpt-shell-describe-image
chatgpt-shell-generate-unit-test ;; test code units
chatgpt-shell-proofread-region ;; (C-c s)
chatgpt-shell-send-and-review-region ;; ask questions about a region

Example

"We are peparing ourselves for the days
when the nations shall beat their swords into plowshares,
and their spears into puning hooks;
nation shall not lift up sword against nation,
neither shall they learn war any more.."

Use Hydra to access the main commands

(defhydra my-hydra-chatgpt-shell (:hint nil :exit t)
  "
ChatGPT-Shell:
  _g_: chatgpt-shell
  _p_: chatgpt-shell-proofread-region
  _s_: chatgpt-shell-send-and-review-region
  _r_: chatgpt-shell-refactor-code
  _d_: chatgpt-shell-describe-code
  _q_: Quit
"
  ("g" chatgpt-shell)
  ("p" chatgpt-shell-proofread-region)
  ("s" chatgpt-shell-send-and-review-region)
  ("r" chatgpt-shell-refactor-code)
  ("d" chatgpt-shell-describe-code)
  ("q" nil :color blue))
(global-set-key (kbd "C-c g") 'my-hydra-chatgpt-shell/body)

Return to Home