Skip to content
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

UI keeps track of only the first 20 messages in the chat history #2063

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion private_gpt/ui/ui.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new value [-20] gives "IndexError: list index out of range" when reaching this line right after asking a question.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohans30 Can you add a pre-validation?

Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def build_history() -> list[ChatMessage]:
)

# max 20 messages to try to avoid context overflow
return history_messages[:20]
return history_messages[-20:]

new_message = ChatMessage(content=message, role=MessageRole.USER)
all_messages = [*build_history(), new_message]
Expand Down
Loading