-
-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "Could not determine chat role" when sending too many messages to a single chat #633
Comments
… chat role" error (TheR1D#633)
… chat role" error (TheR1D#633)
I've also aliased the
|
Hello @igrmk, thank you for raising the issue, I experiment the same behavior. |
Ah, I see I have the same problem :-) |
I'm not a Python developer, but purely through deductive reasoning, I think the problem is on this line. shell_gpt/sgpt/handlers/chat_handler.py Line 74 in aac2f54
And it is caused by how the cache is set up, as when the number of items from the end is taken, the first entry in the cache, which defines the initial role (e.g., system), is also deleted. Since the slice is taken from the end according to the number of items defined by the chat cache size, the role gets deleted. A possible solution could be either defining the role as "user" or fixing the code to something like: message_role_item = messages.pop(0)
json.dump([message_role_item] + messages[-self.length :], file_path.open("w")) |
Thanks @EmVee381 👍 It doesn't look good that the previous PR to fix this submitted in October is still waiting approval 🙁 |
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
optioneach 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.
The text was updated successfully, but these errors were encountered: