karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.28k stars 128 forks source link

Option to save <ChatGPT> buffers by default #128

Closed moritzschaefer closed 11 months ago

moritzschaefer commented 11 months ago

It would be nice to have the configurable option to automatically associated the gptel buffers (named <ChatGPT #n> by default with a file (e.g. in a configurable directory with file name .txt). This way, without extra effort, one can maintain a well-accessible history of chat interactions.

If not within gptel, do you have a recommendation how to implement this in the easiest manner?

karthink commented 11 months ago

There are many ways to do it:

(add-hook 'gptel-mode-hook #'my/gptel-write-buffer)


This will save new gptel sessions to `~/chatgpt-log` with names like `gptel-20231105T1026.txt`.  Or you can save to `default-directory`, or to `(project-root (project-current))` to save them at the root of your current project in Emacs.

- I use a [single file per project](https://github.com/karthink/.emacs.d/blob/master/init.el#L3601) (always named `Chat.org`) to keep persistent logs of ChatGPT conversations, and bind summoning it to the project keymap (`C-x p`), where all the other project commands are. Chat topics are separated by Org headers with `gptel-set-topic`.

This is a feature best tailored by users for their individual workflows, and thus not something I plan to implement in gptel -- so I'm moving this thread to the [discussions](https://github.com/karthink/gptel/discussions) section.