shell_gpt icon indicating copy to clipboard operation
shell_gpt copied to clipboard

Add --refine option to continue a conversation

Open joeytwiddle opened this issue 2 years ago • 3 comments

With --resume or -r shell_gpt will now continue the most recently used conversation.

Disadvantage:

  • Every conversation, even if not named, will be given a chat_id and cached.

Example:

Screenshot_20230323_151046

Closes #78

joeytwiddle avatar Mar 23 '23 07:03 joeytwiddle

This is not very efficient, we will just store all messages, and spam the system with JSON files. It can be implemented in much more efficient way. I think we can just keep track of only last prompt passed to sgpt and OpenAI response. When user calls sgpt -r ... we can get that last prompt with reponse and make a chat session assigning to it some id. All following queries sgpt -r ... should be included on that single file and as soon as user stopped passing -r we delete that file.

# We are storing this query/response as last message, and keep overwriting it.
sgpt "remember my favorite number: 6"
# -> I will remember your favorite number ...

# Here we are starting new chat session with previous prompt and response and including this one.
sgpt -r "what is my favorite number + 2
# -> ... 8

# Keep adding messages to the chat session.
sgpt -r "what is my favorite number + 24
# -> ... 30

# When user doesn't pass -r delete resumable chat session.
# Also we will save this as our last prompt and response for it.
sgpt "some random query"

TheR1D avatar Mar 25 '23 02:03 TheR1D

Thanks for the suggestion.

Oh, I get it. You want -r to work on named chat sessions too.

~Reading this:~

~> we can get that last prompt with reponse and make a chat session assigning to it some id~

~it sounds like two different files, or at least two different states: 1. last initial prompt+response, and 2. latest resumed chat session.~

~I wonder if we can simplify it to one file, a chat session called perhaps latest-unnamed, which might have only 1. query-response, or might have many.~

~If we make an unnamed request without -r then this session would be overwritten to have just 1 entry. If we use -r we would resume this session, by using latest-unnamed as the chat_id.~

~Would that be an acceptable solution?~

~Advantage: Simple. No need to store state about which chat session -r will refer to (initial or resumed).~

~Disadvantage: These resumed chats will not be given a random chat_id so they will be overwritten when a new query is made. Perhaps you prefer resumed chats to be retained in their own chat_id for posterity?~

~I can implement either way. (I hope. I am traveling next week.)~

joeytwiddle avatar Mar 25 '23 07:03 joeytwiddle

It now tracks the latest unnamed query in a chat session called unnamed. If -r is used then that session will given a name / chat id. -r can also be used to continue a previously named session.

I renamed "resume" to "refine", to use the same language as interactive mode.

Currently, if both -r and --chat are provided, then it will use the --chat chat_id, rather than the latest conversation. (-r is ignored)

Screenshot_20230326_105229

joeytwiddle avatar Mar 25 '23 19:03 joeytwiddle

I like the date and time idea. I think that will be a great placeholder until we have some kind of a background process system to manage running little commands to make the user experience better.

lpurdy01 avatar Mar 27 '23 19:03 lpurdy01

https://github.com/TheR1D/shell_gpt/pull/94

TheR1D avatar Apr 03 '23 00:04 TheR1D