dustinblackman / oatmeal

Terminal UI to chat with large language models (LLM) using different model backends, and integrations with your favourite editors!
https://dustinblackman.com/posts/oatmeal/
MIT License
487 stars 23 forks source link

Feature request: Hotkeys to control response stream #1

Closed dxrcy closed 9 months ago

dxrcy commented 9 months ago

Hi, this is a really neat project. I was wondering if it would be possible to add hotkeys to control the model's responses (similar to ChatGPT).

Example:

Or if there is a better way to handle this?

Thanks :)

dxrcy commented 9 months ago

I realize that Ctrl+C is used to quit, so keybind would need to be used obviously.

dustinblackman commented 9 months ago

Hey @darccyy

Both are solid ideas! I appreciate the PR to get CTRL+R in there.

Hotkey bindings are doable, but then I get the complexity of introducing config files, and managing them across different OS'. I don't think I'm there yet, we can solve this through the existing experience.

Thinking about it a bit, it could be simpler to do CTRL C if waiting_for_backend then CANCEL else EXIT_APP so that if waiting for the backend and you wanna exit, you get CTRL C twice. I think that feels a bit more natural.

I can picture how to put this together, I'll just have refactor how I listen for a events first, which I had intended to do for other reasons anyway. :)

I'm not a big ChatGPT user, is there other hotkeys that should be considered?

dxrcy commented 9 months ago

I don't actually think the ChatGPT web app has hotkeys, but it has action buttons to regenerate or copy the response (as well as rate positive or negative). The ollama CLI uses Ctrl+C to stop response, and Ctrl+D or /bye to quit. (It also shows a prompt to press Ctrl+D if you try to quit with Ctrl+C)

Other potential hotkeys could be:

I like the idea of Ctrl+C to stop OR quit, depending on state, but this might be annoying if the program is accidently exited, if history is not preserved. But I'm not sure, what do you think?

I can try to make a PR for cross-platform keybinding config if you think it's within the project scope :)

dustinblackman commented 9 months ago

I can try to make a PR for cross-platform keybinding config if you think it's within the project scope :)

It's not that I don't like the idea, it's more that I'd rather only introduce config files if the feature set of the app hit a complexity that we'd need it (such as getting to the silly point of trying to stick JSON in envs or command line parameters :P). I've felt the pains of trying to do backwards compatibility for config files, I'd like to see how the app evolves first. :)

I like the idea of Ctrl+C to stop OR quit, depending on state, but this might be annoying if the program is accidently exited, if history is not preserved. But I'm not sure, what do you think?

That's a good point. A history file isn't on my TODOs yet either, though I'd be open to it as a feature. As CTRL+D is used for page down to follow what Vim uses, I think I'll take a page out of NodeJS' book and add a final confirmation before closing. If it really becomes a problem, maybe removing CTRL C for exiting. I'll sleep on it. :)

dxrcy commented 9 months ago

I think I'll take a page out of NodeJS' book and add a final confirmation before closing.

That sounds good.

dustinblackman commented 9 months ago

Fixed in v0.3.0. Thanks!