|
|
@ -119,6 +119,7 @@ class AI(object): |
|
|
|
room_id = message.additional_kwargs['room_id'] |
|
|
|
conversation_memory = self.get_memory(room_id) |
|
|
|
conversation_memory.chat_memory.messages.append(message) |
|
|
|
conversation_memory.chat_memory_day.messages.append(message) |
|
|
|
|
|
|
|
async def clear(self, room_id): |
|
|
|
conversation_memory = self.get_memory(room_id) |
|
|
@ -219,6 +220,8 @@ class AI(object): |
|
|
|
|
|
|
|
if prompt_len+256 > 2000: |
|
|
|
logger.warning(f"Prompt too large. Estimated {prompt_len} tokens") |
|
|
|
await reply_fn(f"<WARNING> Prompt too large. Estimated {prompt_len} tokens") |
|
|
|
await conversation_memory.prune_memory(conversation_memory.min_len) |
|
|
|
|
|
|
|
|
|
|
|
#roleplay_chain = RoleplayChain(llm_chain=chain, character_name=self.bot.name, persona=self.bot.persona, scenario=self.bot.scenario, ai_name_chat=chat_ai_name, human_name_chat=chat_human_name) |
|
|
@ -370,6 +373,8 @@ class AI(object): |
|
|
|
"room_id": room_id, |
|
|
|
} |
|
|
|
) |
|
|
|
if conversation_memory.chat_memory.messages[-1].content.startswith('~~~~ '): |
|
|
|
conversation_memory.chat_memory.messages.pop() |
|
|
|
conversation_memory.chat_memory.messages.append(message) |
|
|
|
#conversation_memory.chat_memory.add_system_message(message) |
|
|
|
|
|
|
@ -377,6 +382,8 @@ class AI(object): |
|
|
|
yesterday = ( datetime.now() - timedelta(days=1) ).strftime('%Y-%m-%d') |
|
|
|
for room_id in self.rooms.keys(): |
|
|
|
if len(conversation_memory.chat_memory_day.messages) > 0: |
|
|
|
if not "diary" in self.bot.rooms[room_id]: |
|
|
|
self.bot.rooms[room_id]['diary'] = {} |
|
|
|
self.bot.rooms[room_id]["diary"][yesterday] = await self.diary(room_id) |
|
|
|
# Calculate new goals for the character |
|
|
|
# Update stats |
|
|
|