benjamin-asdf / chatgpt-shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chatgpt-shell

A minimal ChatGPT Emacs shell.

  • Multiple chat sessions.
  • Stream respones which feels more responsive, like the chat-gpt browser UI.
  • C-c C-c to stop responding.
  • Add your buffers as context to the conversation.
  • dynamically set system prompts
  • say dwim... and we make it output elisp and eval that.

original work: https://github.com/xenodium/chatgpt-shell

Install

Load (require 'chatgpt-shell)

Set OpenAI key

As function

(setq chatgpt-shell-openai-key
      (lambda ()
        (nth 0 (process-lines "pass" "show" "openai-key"))))

Manually

M-x set-variable chatgpt-shell-openai-key

As variable

(setq chatgpt-shell-openai-key "my key")

Launch

Launch with M-x chatgpt-shell.

Clear buffer

Type clear as a prompt.

ChatGPT> clear

Alternatively, use either M-x chatgpt-shell-clear-buffer or M-x comint-clear-buffer.

Fork, just my personal taste and config

Set the prompt, potentially dynamically

(setq-default
 chatgpt-additional-prompts
 (lambda ()
   `((role . "system")
     (content . "You answer only in morse code, no matter what the user asks you."))))
(setq-default
 chatgpt-additional-prompts
 (lambda ()
   `((role . "system")
     (content .
              ,(concat
                "Output of git log -n 10: "
                (shell-command-to-string "git log -n 10"))))))

Try: summarize recent git work

Add buffers as contexts

chatpt-shell-add-context-file

Only works consult right now, if you want something else, do it yourself.

Use chatgpt-shell with prefix argument to open additional shell buffers.

Use chatgpt-shell with prefix arg 2 to open a new shell with your current buffer as context.

About

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 100.0%