Skip to content

xenodium/dall-e-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

dall-e-shell

An Emacs shell for OpenAI’s DALL-E

For related packages, see:

  • chatgpt-shell: An Emacs shell for OpenAI’s ChatGPT.
  • ob-chatgpt-shell: Evaluate ChatGPT shell blocks in Emacs org babel blocks.
  • ob-dall-e-shell: Evaluate DALL-E shell blocks in Emacs org babel blocks.
  • shell-maker: Create Emacs shells backed by either local or cloud services.

Support this effort

If you’re finding dall-e-shell useful, help make the project sustainable and consider ✨sponsoring✨.

dall-e-shell is in development. Please report issues or send pull requests for improvements.

Like this package? Tell me about it 💙

Finding it useful? Like the package? I’d love to hear from you. Get in touch (Mastodon / Twitter / Reddit / Email).

Install

  • Load (require 'dall-e-shell)

MELPA

If using use-package, you can install with :ensure t.

(use-package dall-e-shell
  :ensure t
  :custom
  ((dall-e-shell-openai-key
    (lambda ()
      (auth-source-pass-get 'secret "openai-key")))))

Set OpenAI key

You’ll first need to get a key from OpenAI.

As function

;; if you are using the "pass" password manager
(setq dall-e-shell-openai-key
      (lambda ()
        ;; (auth-source-pass-get 'secret "openai-key") ; alternative using pass support in auth-sources
        (nth 0 (process-lines "pass" "show" "openai-key"))))

;; or if using auth-sources, e.g., so the file ~/.authinfo has this line:
;;  machine api.openai.com password OPENAI_KEY
(setq dall-e-shell-openai-key
      (auth-source-pick-first-password :host "api.openai.com"))

;; or same as previous but lazy loaded (prevents unexpected passphrase prompt)
(setq dall-e-shell-openai-key
      (lambda ()
        (auth-source-pick-first-password :host "api.openai.com")))

Manually

M-x set-variable dall-e-shell-openai-key

As variable

(setq dall-e-shell-openai-key "my key")

As an ENV variable

(setq dall-e-shell-openai-key (getenv "OPENAI_API_KEY"))

Launch

Launch with M-x dall-e-shell.

Note: M-x =dall-e-shell keeps a single shell around, refocusing if needed. To launch multiple shells, use C-u M-x dall-e-shell.

Clear buffer

Type clear as a prompt.

DALL-E(v3)>  clear

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

Customizations

Custom variableDescription
dall-e-shell-welcome-functionFunction returning welcome message or nil for no message.
dall-e-shell-openai-keyOpenAI key as a string or a function that loads and returns it.
dall-e-shell-image-sizeThe default size of the requested image as a string.
dall-e-shell-read-string-functionFunction to read strings from user.
dall-e-shell-request-timeoutHow long to wait for a request to time out.
dall-e-shell-model-versionThe used DALL-E OpenAI model. For Dall-E 3, use “dall-e-3”.
dall-e-shell-display-functionFunction to display the shell. Set to `display-buffer’ or custom function.
dall-e-shell-model-versionsThe list of Dall-E OpenAI models to swap from.
dall-e-shell-additional-curl-optionsAdditional options for `curl’ command.
dall-e-shell-image-output-directoryOutput directory for the generated image.
dall-e-shell-image-qualityImage quality: `standard’ or `hd’ (DALL-E 3 only feature).

Commands

C-<up> or M-pdall-e-shell-previous-inputCycle backwards through input history, saving input.
dall-e-shellStart a DALL-E shell.
dall-e-shell-insert-image-from-region-descriptionGenerate and insert an image using current region as description.
dall-e-shell-interruptInterrupt `dall-e-shell’ from any buffer.
S-<return>dall-e-shell-newlineInsert a newline, and move to left margin of the new line.
RETdall-e-shell-submitSubmit current input.
C-x C-sdall-e-shell-save-session-transcriptSave shell transcript to file.
C-c C-vdall-e-shell-swap-model-versionSwap model version from `dall-e-shell-model-versions’.
dall-e-shell-modeMajor mode for DALL-E shell.
C-<down> or M-ndall-e-shell-next-inputCycle forwards through input history.
M-rdall-e-shell-search-historySearch previous input history.
dall-e-shell-rename-bufferRename current shell buffer.

Support my work

👉 Find my work useful? Support this work via GitHub Sponsors or buy my iOS apps.

My other utilities, packages, apps, writing…

About

An Emacs shell for OpenAI's DALL-E

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published