tarasglek / chatcraft.org

Developer-oriented ChatGPT clone
https://chatcraft.org/
MIT License
154 stars 31 forks source link

Consider adding prompt history to ChatCraft #588

Open Amnish04 opened 5 months ago

Amnish04 commented 5 months ago

Today, I was using ChatCraft to generate a cover photo for my blog post. Since I didn't like one of the responses, I started clicking "up" arrow out of instinct, trying to get previous command and making changes to it.

However, I realized this functionality doesn't exist in ChatCraft but could be kinda useful, especially for people using ChatCraft commands a lot.

I was wondering if we could implement a Prompt History in user's local storage, and pressing up and down arrows would allow navigating through previous prompts just like we can do in any command line interface.

We could probably limit the number of prompts that are saved (maybe 10), so we do not eat up too much memory on user's computer. And we could also provide an option in user pref to set a customer prompt history.

humphd commented 5 months ago

We actually do support up-arrow, but in a very limited way. I like your idea. We don't even need to do any changes to localStorage or the database, since we already have all the messages in indexeddb, and would need to get the "previous" human message. You could support infinite history with this.

Amnish04 commented 5 months ago

We could do that, but the problem is many human messages do not exactly hold the text originally entered in the prompt.

This especially happens when we are using ChatCraft command. The entered prompt gets lost and only the response is stored as a Human Message.

One example is the /image command. image

Even with Web Handlers, only the response is saved that is practically no use for the user to have in the prompt. image

Also, while looking into this, I've noticed that we are using Human Messages for Image generation and Web Handlers. Should they be System Messages instead?

Amnish04 commented 5 months ago

@humphd If we don't like this approach, we could also have a separate db collection for our history stack, and only push prompts that are a ChatCraft command to it.

Although I think it would be better to go with the first approach for wider support.

Please let me know what you would prefer.

humphd commented 5 months ago

I'm not against trying the localStorage approach, but it becomes one more thing you have to keep in sync.

Here's another thought: what if up-arrow goes through the previous messages in the chat, no matter what type they are? I ask because I'm not sure if "previous prompts" are useful outside of the current chat. I often want to edit the AI responses too.

NOTE: we can't use System Messages for these, as this has a specific meaning for LLMs.