Imemorymanager

Classes

class arshai.core.interfaces.imemorymanager.ConversationMemoryType(value)[source]

Bases: StrEnum

SHORT_TERM_MEMORY = 'SHORT_TERM_MEMORY'
LONG_TERM_MEMORY = 'LONG_TERM_MEMORY'
WORKING_MEMORY = 'WORKING_MEMORY'
class arshai.core.interfaces.imemorymanager.IMemoryConfig(**data)[source]

Bases: IDTO

Configuration for memory systems.

This class represents configuration settings for different memory types such as working memory, short-term memory, and long-term memory.

working_memory: Optional[Dict[str, Any]]
short_term_memory: Optional[Dict[str, Any]]
long_term_memory: Optional[Dict[str, Any]]
model_config: ClassVar[ConfigDict] = {'allow_mutation': False, 'arbitrary_types_allowed': True, 'smart_union': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class arshai.core.interfaces.imemorymanager.IMemoryInput(**data)[source]

Bases: IDTO

Represents the input for memory operations.

conversation_id

Unique identifier for the conversation

memory_type

Type of memory to operate on

data

Memory data for store/update operations

query

Search query for retrieve operations

memory_id

Specific memory ID for update/delete operations

limit

Maximum number of items to retrieve

filters

Additional filters to apply

metadata

Additional metadata for the memory entry

conversation_id: str
memory_type: ConversationMemoryType
data: Optional[List[IWorkingMemory]]
query: Optional[str]
memory_id: Optional[str]
limit: Optional[int]
filters: Optional[Dict[str, Any]]
metadata: Optional[Dict[str, Any]]
model_config: ClassVar[ConfigDict] = {'allow_mutation': False, 'arbitrary_types_allowed': True, 'smart_union': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class arshai.core.interfaces.imemorymanager.IMemoryItem(**data)[source]

Bases: IDTO

Represents a single item in conversation memory.

This class represents a message or other item stored in conversation memory, with metadata about the item.

role: str
content: str
metadata: Optional[Dict[str, Any]]
model_config: ClassVar[ConfigDict] = {'allow_mutation': False, 'arbitrary_types_allowed': True, 'smart_union': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class arshai.core.interfaces.imemorymanager.IMemoryManager(*args, **kwargs)[source]

Bases: Protocol

Universal interface for memory management systems. Provides a unified approach to handling different types of memory: - Short-term memory: Recent conversations and temporary information - Long-term memory: Persistent knowledge and important information - Context management: Current conversation state and context

Implementations can choose to implement all or specific memory management features.

store(input)[source]

Universal method to store any type of memory data.

Parameters:

input (IMemoryInput) – IMemoryInput containing data and metadata for storage

Returns:

Unique identifier for the stored memory

Return type:

str

retrieve(input)[source]

Universal method to retrieve any type of memory data.

Parameters:

input (IMemoryInput) – IMemoryInput containing query and retrieval parameters

Returns:

Matching memory entries

Return type:

List[IWorkingMemory]

update(input)[source]

Universal method to update any type of memory data.

Parameters:

input (IMemoryInput) – IMemoryInput containing memory ID and update data

Return type:

None

delete(input)[source]

Universal method to delete memory data.

Parameters:

input (IMemoryInput) – IMemoryInput containing memory ID or deletion criteria

Return type:

None

__init__(*args, **kwargs)
class arshai.core.interfaces.imemorymanager.IWorkingMemory(**data)[source]

Bases: IDTO

Maintains the assistant’s working memory during conversations.

Contains a single structured string field that encompasses all Working Memory components in a format optimized for LLM understanding and processing.

working_memory: str
classmethod initialize_memory()[source]

Create a new working memory state with initial values

Return type:

IWorkingMemory

to_dict()[source]

Convert the working memory state to dictionary format for storage

Return type:

Dict

classmethod from_dict(data)[source]

Create working memory state from stored dictionary format

Return type:

IWorkingMemory

model_config: ClassVar[ConfigDict] = {'allow_mutation': False, 'arbitrary_types_allowed': True, 'smart_union': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].