Our system can convey the previous chat histories within contexts in the Message class.
Now, we have the summarization function.
If the Message has an exceeding number of chat histories, automatically summarize the past conversations to shorten our next prompts.
#### src/agent/base_agent.py ####
# First two messages are system and user personas
if len(messages) > 2 + NONEVICTION_LENGTH:
messages = messages[2:-NONEVICTION_LENGTH]
del self.message.llm_message["messages"][2:-NONEVICTION_LENGTH]
else:
messages = messages[2:]
del self.message.llm_message["messages"][2:]
message_contents = [
message.to_dict()['content'] for message in messages
]
llm_message_chatgpt = {
"model": self.model,
"messages": [{
"role": "user",
"content": "Summarize these previous conversations into 50 words:"
Update
message_contents = [ message.to_dict()['content'] for message in messages ]
llm_message_chatgpt = { "model": self.model, "messages": [{ "role": "user", "content": "Summarize these previous conversations into 50 words:"
To Reviewers