shell_gpt icon indicating copy to clipboard operation
shell_gpt copied to clipboard

Feature request: Allow starting a chat from most recent response

Open mccartykim opened this issue 1 year ago • 6 comments

I really love this interface for working with llms, but sometimes I intend to ask a one off question and realize the LLM almost but didn't quite get me, so I'd like to follow up rather than starting over with a new prompt.

I could use my shell's built in history to pipe in the last reply as context, but I think a more pleasant solution would be to introduce a last chat that stores the output of the last prompt that didn't specify a chat. Whenever a user makes a prompt without a --chat argument, the last entry is overwritten. If it's a named chat, have the last chat point to that named chat.

Since replies are cached by default, I think this would be really sensible and maybe there could even be a --reply flag that's syntactic sugar for responding to whatever was the last chat. To me, that's more ergonomic than assuming I'll want to continue the conversation before I ask my question.

mccartykim avatar Aug 16 '23 18:08 mccartykim

What if the response comes from whatever the previous command's stdout/stderr output the shell received?

A lot of the times, I get an error I've never seen before, and being lazy to read it, I feed it to ChatGPT to read it for me. This saves a lot of time, for instance, when some unformatted json gets thrown at you. (AI models these days have better reading comprehension than humans, so why not use them this way?)

If the error code of the previous shell command is non-zero, why not pick up the buffer shell and feed it to shell-gpt by default :-)

Say you're using byobu, we could see the "next recommended command" somewhere in the status bar, and have a key-binding to run it

Or simply update PS1 for a quick hack?

Or, in zhs, shell-gpt can auto-suggest complete the command for users to just press enter and execute :-) The fzf/bash equivalent could achieve the same under a Ctrl+R-like key-binding showing you more than 1 recommended next command to choose from

pcuci avatar Sep 10 '23 13:09 pcuci

#32

moritztim avatar Dec 21 '23 14:12 moritztim

@TheR1D are you already working on this? If not I'd like to take a look since I run into this all the time

jeanlucthumm avatar Feb 11 '24 19:02 jeanlucthumm

@jeanlucthumm sure, I'm not currently working on it, feel free to take a look.

TheR1D avatar Feb 11 '24 19:02 TheR1D

Just an idea, wouldn't it be as easy, or even less code, to implement this as "--fork" option? You could follow up any chat, including the temp chat (which could be made the default, either in .sgptrc or with an alias)

> sgpt "My favourite number is 5"
...
> sgpt --chat favourites --fork temp "And my favourite color is blue."
> sgpt --chat favourite_svg --fork favourites "Generate my favourite SVG polygon"
...

I think that would be a similar implementation, solve the problem of going from a one off question to a chat, but more generic?

KjellMorgenstern avatar Jul 13 '24 09:07 KjellMorgenstern

Related #562

KjellMorgenstern avatar Jul 13 '24 09:07 KjellMorgenstern