-
Notifications
You must be signed in to change notification settings - Fork 3
MemoryManagers
In Pantella, memory managers are used to manage the memory of characters in the game. The memory manager is responsible for managing the memory of a character after they're added to a conversation, saving memories, managing the character in the game, and managing the character's memory manager.
The memory manager class is a class that manages the memory of characters in the game. The memory manager class has the following methods and properties:
-
__init__(self,character_manager): Initializes the memory manager. Thecharacter_managerparameter is the character manager that the memory manager is associated with. -
name: Returns the name of the character. -
race: Returns the race of the character. -
gender: Returns the gender of the character. -
base_id: Returns the base ID of the character. -
ref_id: Returns the reference ID of the character. -
messages: Returns the messages of the conversation manager. -
after_step(self): Performs a step in the memory manager after the conversation step. -
before_step(self): Performs a step in the memory manager before the conversation step. -
reached_conversation_limit(self): Ran when the conversation limit is reached. Some memory managers may need to perform some action when the conversation limit is reached. -
add_message(self, message): Adds a message to the memory manager. -
load_messages(self): Loads messages from the memory manager. Some memory managers may need to load messages from a file or database, and can also use this method to load old messages into the conversation_manager's messages. -
memories: Returns the memories of the character's memory manager. -
memory_offset: Returns the memory depth of the character. -
memory_offset_direction: Returns the memory offset direction of the character.
Initializes the memory manager. The character_manager parameter is the character manager that the memory manager is associated with. When creating a new memory manager, you should call the parent class's __init__ method to ensure that the default memory manager is loaded.
Perform after dialogue generation in the memory manager - Some memory managers may need to perform some action every step.
Performed before dialogue generation in the memory manager - Some memory managers may need to perform some action every step.
Ran when the conversation limit is reached, or the conversation is ended - Some memory managers may need to perform some action when the conversation limit is reached.
Add a message to the memory manager.
Load messages from the memory manager - Some memory managers may need to load messages from a file or database, and can also use this method to load old messages into the conversation_manager's messages.
Return a string representation of the memories stored in the memory manager - Some memory managers have updating memories strings.
Return the memory depth of the character.
Return the memory offset direction of the character.
from src.logging import logging
manager_slug = "example_memory_manager"
class MemoryManager():
def __init__(self,character_manager):
self.conversation_manager = character_manager.conversation_manager
self.character_manager = character_manager
self.config = self.conversation_manager.config
# Add your memory manager initialization code here
def after_step(self):
logging.info("Performing a step in the memory manager after the conversation step.")
def before_step(self):
logging.info("Performing a step in the memory manager before the conversation step.")
def reached_conversation_limit(self):
logging.info("Conversation limit reached, nothing to do in the memory manager.")
def add_message(self, message):
logging.info(f"Adding message to the memory manager: {message}")
def load_messages(self):
logging.info("Loading messages from the memory manager.")
@property
def memories(self):
logging.info("Returning the memories of the character's memory manager.")
return [{
"role": "example",
"content": "This is an example memory.",
"type": "memory"
}]