karthink / gptel

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

mode-line-process instead of header-line-format #9

Closed minad closed 8 months ago

minad commented 1 year ago

It would be great if we could use different indicators, e.g., the mode line instead of the header line for process updates via a configurable gptel-status-function. I just started experimenting with your package and sometimes it takes a long time for chatgpt to answer. Would it be possible to give more progress updates? For example in the browser the answer comes in "live".

karthink commented 1 year ago

Sure, the header-line is just a stopgap solution. I'm sure there are better alternatives.

To get more progress updates, there are a couple of possibilities:

  1. The API has a stream option that sends chunks of data. It is possible to write a process filter that updates the buffer live as these come in, like in the browser. This is the correct solution, but I've been working on other aspects. (PRs are welcome!)
  2. There is a gptel-playback option in the package that plays back data in chunks. This doesn't save you any time, it waits until it receives the full response, then plays it back continuously so it's actually slower! It's silly but it does make the process feel somewaht interactive.
  3. Another cheap trick I've tried is to pulse-momentary-highlight-region when the response comes in. It's still slow, but like the previous option it feels a little more interactive.
minad commented 1 year ago

The API has a stream option that sends chunks of data. It is possible to write a process filter that updates the buffer live as these come in, like in the browser. This is the correct solution, but I've been working on other aspects. (PRs are welcome!)

This is the approach I favor. I am happy to help out if I find time, but I just started experimenting with this. The overall approach of your package seems good with the list of prompts in a plain text document, but I haven't checked out the other solutions.

minad commented 1 year ago

Would you accept a quick PR which replaces the header-line with a mode-line indicator? I would add a gptel-status-function which can be either set to a function for the header-line and a function for the mode-line.

karthink commented 1 year ago

Sure, that would be a welcome addition! Which one do you think should be the default?

The reason I picked the header-line is because there are too many mode-line packages out there that transform/hide mode-line elements and minor-mode lighter info. doom-modeline is a popular example of this -- no Doom users would see any status messages until someone adds explicit support for doom-modeline. This makes my job of reporting errors/readiness etc harder.

Since the header-line is only intended for dedicated gptel buffers, it seemed like a safe bet.

minad commented 1 year ago

Which one do you think should be the default?

I don't care much, but personally I would for sure disable the header line.

The reason I picked the header-line is because there are too many mode-line packages out there that transform/hide mode-line elements and minor-mode lighter info.

I agree. In my setup I only use minions and made a few simple adjustments to the mode line myself. But besides that my mode-line is mostly vanilla.

Since the header-line is only intended for dedicated gptel buffers, it seemed like a safe bet.

Indeed, it is. The mode-line-process variable should be a reasonable safe alternative.

karthink commented 1 year ago

Indeed, it is. The mode-line-process variable should be a reasonable safe alternative.

Sounds good to me.

karthink commented 1 year ago

This is the approach I favor. I am happy to help out if I find time, but I just started experimenting with this. The overall approach of your package seems good with the list of prompts in a plain text document, but I haven't checked out the other solutions.

@minad I added continuous response streaming -- it's now much faster (and continues to be async):

https://user-images.githubusercontent.com/8607532/229309176-cad5f46f-6f9d-4e6b-995a-ccf343df60fc.mp4

I haven't merged it yet (it's in the streaming branch) since the markdown -> Org conversion from an incomplete parse state is proving tricky.

karthink commented 1 year ago

@minad Streaming responses is now added, and is turned on by default.

karthink commented 8 months ago

Done, finally! Set gptel-use-header-line to nil for less obtrusive status display/messaging when using gptel-mode.