TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
9.67k stars 764 forks source link

Error "Could not determine chat role" when sending too many messages to a single chat #633

Open igrmk opened 1 month ago

igrmk commented 1 month ago

I have an alias set up to use the predefined role using the --chat option. For example, --chat improve is automatically added to every "Improve writing" query.

ShellGPT truncates the chat using the CHAT_CACHE_LENGTH option each time it saves the conversation.

As a result, the first message eventually gets removed, causing the tool to display "Could not determine chat role", since the role is defined in that initial message.

To prevent this issue, the first message should likely never be truncated.

DanijelDomazet commented 3 weeks ago

I've also aliased the --chat option, and I have the same issue.

Could not determine chat role of "dd"

tinmarino commented 3 weeks ago

Hello @igrmk, thank you for raising the issue, I experiment the same behavior. For me, it seems to happen when I interrupt the chat with Ctrl-C and try to start it again.

Screenshot from 2024-10-25 13-05-27