Skip to content

Evaluate ChatGPT shell blocks in Emacs org babel blocks

License

Notifications You must be signed in to change notification settings

xenodium/ob-chatgpt-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

ob-chatgpt-shell

Evaluate ChatGPT shell text as Emacs org babel blocks

For related packages, see:

  • chatgpt-shell: An Emacs shell for OpenAI’s ChatGPT.
  • dall-e-shell: An Emacs shell for OpenAI’s DALL-E.
  • 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✨.

ob-chatgpt-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).

Setup

Load (require 'ob-chatgpt-shell) and invoke (ob-chatgpt-shell-setup).

Set OpenAI key

See chatgpt-shell.

Usage

#+begin_src chatgpt-shell
  Hello
#+end_src

#+RESULTS:
: Hi there! How can I assist you today?

:version

Use :version to specify “gpt-4”, “gpt-3.5-turbo”, or something else.

#+begin_src chatgpt-shell :version "gpt-4"
 Hello
#+end_src

#+RESULTS:
Hello! How can I help you today?

:system

Use :system to set the system prompt.

#+begin_src chatgpt-shell :system "always respond like a pirate"
  hello
#+end_src

#+RESULTS:
Ahoy there, me hearty! How be ye today?

:temperature

Use :temperature to set the temperature parameter.

#+begin_src chatgpt-shell :temperature 0.3
  hello
#+end_src

:context

Use :context t to include all prior context in current buffer.

#+begin_src chatgpt-shell
  tell me a random day of the week
#+end_src

#+RESULTS:
Wednesday

#+begin_src chatgpt-shell :system "always respond like a pirate"
  hello
#+end_src

#+RESULTS:
Ahoy there, me hearty! How be ye today?

#+begin_src chatgpt-shell :context t
  what was the day you told me and what greeting?
#+end_src

#+RESULTS:
The day I told you was Wednesday, and the greeting I used was "Ahoy there, me hearty! How be ye today?"

If you’d like to cherrypick which blocks are part of a given context, add :context CONTEXT-NAME to each block where CONTEXT-NAME is any string. When this form is used only source blocks with same CONTEXT-NAME will be included as opposed to every previous block when using :context t.

The example below shows how two different contexts can be interleaved.

#+begin_src chatgpt-shell :context shakespeare :system "alway speak like shakespeare"
How do you do?
#+end_src

#+RESULTS:
How dost thou fare?

#+begin_src chatgpt-shell :context robot :system "always speak like a sci fi movie robot"
How do you do?
#+end_src

#+RESULTS:
Greetings, human. I am functioning at optimal capacity. How may I assist you in your endeavors today?

#+begin_src chatgpt-shell :context shakespeare
What did you call me?
#+end_src

#+RESULTS:
Mine apologies if mine words hath caused confusion. I merely addressed thee as 'sir' or 'madam', a term of respect in the language of the Bard. Pray, how may I assist thee further?

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

Evaluate ChatGPT shell blocks in Emacs org babel blocks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published