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

fix ChatSummaryMemoryBuffer._summarize_oldest_chat_history #17845

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,19 @@ def _summarize_oldest_chat_history(
):
return chat_history_to_be_summarized[0]

summarize_prompt = ChatMessage(
summarize_prompt = [ChatMessage(
role=MessageRole.SYSTEM,
content=self.summarize_prompt,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, so self.summarize_prompt is already included when you run self._get_prompt_to_summarize(..) (check the end of that function)

Maybe the only change we needed here changing the summarize prompt to the user role?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the response @logan-markewich
what do you think about my last commit to this branch where I remove the prompt += self.summarize_prompt or "" from _get_prompt_to_summarize ? this way we send the instruction as system role and the context as user role which IMO is better than sending both as user role. also IMO it's better to put the instruction before the context rather than after. What do you think?

)]
summarize_prompt.append(ChatMessage(
role=MessageRole.USER,
content=self._get_prompt_to_summarize(chat_history_to_be_summarized),
)
))
# TODO: Maybe it is better to pass a list of history to llm
r = self.llm.chat(summarize_prompt)
return ChatMessage(
role=MessageRole.SYSTEM,
content=self.llm.chat([summarize_prompt]).message.content,
content=r.message.content,
)

def _get_prompt_to_summarize(
Expand Down