First look at chatgpt-shell history

Posted on Jun 26, 2023

I need some sort of switchable “memory” using chatgpt-shell, for both the shell and org-mode. Memory, here, refers to e.g. a conversation like we have in the ChatGPT web interface. The Emacs chatgpt shell and org-mode both have the ability to hold a single conversation of chat messages. (with the current caveat that the org-babel integration has a bug and the shell can’t be restored).

The Shell

chatgpt-shell does indeed have saving / loading session transcripts. Let’s try it out… alright looks like this works well enough as-is. The key functions are:

  • shell-maker-save-session-transcript – save the session transcript to a txt file
  • chatgpt-shell-restore-session-from-transcript – restore the session from a txt file

The session text file is useful in and of itself:

Welcome to ChatGPT shell

Type help and press RET for details.

<shell-maker-failed-command> ChatGPT(4-0613/Prorg)> remember the term flooball <shell-maker-end-of-prompt>

context = ["flooball"]

ChatGPT(4-0613/Prorg)>

See also the feature request to Support multiple shell instances (#121).

The Org

chatgpt-shell only currently supports a single conversation / context in it’s org-babel incarnation. And, that’s bugged out for me. The src block arg syntax is already almost perfect: :context t. It just needs a lil tweaking such that the second argument is the name of the context / chat rather than a boolean.

So, this is a spot for future investigation. I opened a feature request / issue on chatgpt-shell’s github forge. Thanks in advance, xenodium!