Trying to trim memory properly
This commit is contained in:
parent
814102e921
commit
2724f7cee6
@ -95,9 +95,6 @@ class ReginaldCog(commands.Cog):
|
||||
|
||||
response_text = await self.generate_response(api_key, formatted_messages)
|
||||
|
||||
memory.append({"user": user_name, "content": prompt})
|
||||
memory.append({"user": "Reginald", "content": response_text})
|
||||
|
||||
if len(memory) > self.short_term_memory_limit:
|
||||
summary = await self.summarize_memory(memory)
|
||||
|
||||
@ -118,6 +115,8 @@ class ReginaldCog(commands.Cog):
|
||||
keep_count = max(1, int(len(memory) * retention_ratio)) # Keep at least 1 message
|
||||
memory = memory[-keep_count:] # Remove oldest 75%, keep recent
|
||||
|
||||
memory.append({"user": user_name, "content": prompt})
|
||||
memory.append({"user": "Reginald", "content": response_text})
|
||||
|
||||
short_memory[channel_id] = memory
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user