karthink / gptel

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

Feature request/question: Persisting logs #407

Closed agzam closed 1 month ago

agzam commented 1 month ago

I want to save everything that goes into the gpel-buffers. I rarely need to find the past exchanges, but sometimes it's useful to be able to search through older sessions. I know this could be accomplished by using standard hooks, but I'm not sure how to make it in a way that older session can be restored and continued. Perhaps this should be a standard feature of the package, where you could store/search/restore&continue older sessions?

karthink commented 1 month ago

I want to save everything that goes into the gpel-buffers. I rarely need to find the past exchanges, but sometimes it's useful to be able to search through older sessions. I know this could be accomplished by using standard hooks, but I'm not sure how to make it in a way that older session can be restored and continued. Perhaps this should be a standard feature of the package, where you could store/search/restore&continue older sessions?

store, restore and continue: This is part of gptel. Save a chat buffer to disk and close it. You can open it later, run M-x gptel-mode and continue the chat. Works for Markdown and Org buffers.

search: I don't know what you mean by "search through older sessions". Isn't this the kind of thing you'd use grep for?

agzam commented 1 month ago

Oh... I guess I should've clarified it more. I thought you'd get the gist. I know you can save any buffer manually. What I meant is that I'm looking for a way to preserve all the exchanges automatically. Set up a folder where they quietly get collected. No need for any additions to the package for that, right? And, yes, I totally forgot that you already can restore the buffer and continue the session from that point onward.

Oy, I guess I should've started a discussion topic instead of an issue, I don't think GH allows me to convert it to one. Please feel free to do so. Thank you!

agzam commented 1 month ago

Oh... I can be so obtuse and annoying. There's a discussion thread already https://github.com/karthink/gptel/discussions/129. Apologies for the noise. Closing this for now. Thank you.

karthink commented 1 month ago

Oh... I guess I should've clarified it more. I thought you'd get the gist. I know you can save any buffer manually. What I meant is that I'm looking for a way to preserve all the exchanges automatically. Set up a folder where they quietly get collected. No need for any additions to the package for that, right?

Yeah, you can do that however you'd like. Currently gptel provides three hooks that might be relevant: gptel-pre-response-hook, gptel-post-response-functions and gptel-mode-hook.

One approach would be to use gptel-post-response-functions to copy the response (when non-nil) into a sqlite db. The schema could include the date, context like the active project, and the user prompt and corresponding response. You can then query this db looking for a relevant past exchange. You can probably do something cleverer by interconnecting responses based on keywords and context in a graph db, and include additional context with future LLM queries automatically by consulting this database first. Just an idea.

agzam commented 1 month ago

You can probably do something cleverer by interconnecting responses

You are a dangerous person 😄 I used to think it's just me... I have voices in my head and they are speaking in lambda calculus... , your case sounds like it's even worse. I'm starting to think you have bad influence on me 🤣