memoryscope.core.service.memory_scope_service
- class memoryscope.core.service.memory_scope_service.MemoryScopeService(history_msg_count: int = 100, contextual_msg_max_count: int = 10, contextual_msg_min_count: int = 0, **kwargs)[source]
Bases:
BaseMemoryService
- __init__(history_msg_count: int = 100, contextual_msg_max_count: int = 10, contextual_msg_min_count: int = 0, **kwargs)[source]
init function. :param history_msg_count: The conversation history in memory, control the quantity, and reduce memory usage. :type history_msg_count: int :param contextual_msg_max_count: The maximum context length in a conversation. If it exceeds this length,
it will not be included in the context to prevent token overflow.
- Parameters:
contextual_msg_min_count (int) – The minimum context length in a conversation. If it is shorter than this length, no conversation summary will be made and no long-term memory will be generated.
kwargs (dict) – Additional parameters to customize service behavior.
- add_messages_pair(messages: List[Message])[source]
Adds a list of messages to the chat history, it can be a pair [user_message, assistant_message]. Ensuring the message list remains sorted by creation time and does not exceed the maximum history message count.
- run_operation(name: str, role_name: str = '', **kwargs)[source]
Executes a specific operation by its name with provided keyword arguments.
- Parameters:
name (str) – The name of the operation to execute.
role_name (str) – The name of the operation to execute.
**kwargs – Keyword arguments for the operation’s execution.
- Returns:
The result of the operation execution, if any. Otherwise, None.
- Raises:
Warning – If the operation name is not initialized in _operation_dict.