class documentation

Class for managing an agent session, including conversation history and session ID.

Class Method delete Deletes the session with the specified ID from the storage backend.
Class Method delete_index Deletes the session at the specified index from the storage backend.
Class Method exists Checks if a session with the given ID exists in the storage backend.
Class Method get_conversation Retrieves the conversation history for the specified session ID from the storage backend.
Class Method ls Returns a list of all session IDs stored in the storage backend.
Method __del__ Cleans up the session before it is destroyed.
Method __init__ Initializes a new session with the given storage backend and optional session ID.
Method append Appends a message to the session's conversation history and saves it to the storage backend.
Method append_messages Append multiple messages and save the session once.
Method list Returns a list of all session IDs stored in the storage backend.
Method update Updates the session's conversation history and saves it to the storage backend.
Class Variable __slots__ Undocumented
Instance Variable conversation The conversation history for the session.
Property id Returns the unique session ID.
Property path Returns the storage path for the session JSON file.
Method _load_session Loads a session from the storage backend using the provided session ID.
Method _save Saves the current session to the storage backend.
Instance Variable _id Undocumented
Instance Variable _storage Undocumented
Instance Variable _time_created Undocumented
@classmethod
def delete(cls, storage, session_id: str) -> bool:

Deletes the session with the specified ID from the storage backend.

@classmethod
def delete_index(cls, storage, index: int) -> bool:

Deletes the session at the specified index from the storage backend.

@classmethod
def exists(cls, storage, session_id: str) -> bool:

Checks if a session with the given ID exists in the storage backend.

@classmethod
def get_conversation(cls, storage, session_id: str) -> list:

Retrieves the conversation history for the specified session ID from the storage backend.

@classmethod
def ls(cls, storage) -> list:

Returns a list of all session IDs stored in the storage backend.

def __del__(self):

Cleans up the session before it is destroyed.

def __init__(self, view_manager, session_id: str = None):

Initializes a new session with the given storage backend and optional session ID.

Parameters
view_managerAn instance of the view manager containing the storage backend for saving and loading session data.
session_id:str, optionalThe unique identifier for the session. If not provided, a new session ID will be generated.
Raises
ExceptionIf the session cannot be loaded from storage with the provided session ID.
def append(self, message: dict) -> bool:

Appends a message to the session's conversation history and saves it to the storage backend.

def append_messages(self, messages: list[dict]) -> bool:

Append multiple messages and save the session once.

def list(self) -> list:

Returns a list of all session IDs stored in the storage backend.

def update(self, conversation: list) -> bool:

Updates the session's conversation history and saves it to the storage backend.

__slots__: tuple[str, ...] =

Undocumented

conversation: list =

The conversation history for the session.

@property
id: str =

Returns the unique session ID.

@property
path: str =

Returns the storage path for the session JSON file.

def _load_session(self, session_id: str) -> bool:

Loads a session from the storage backend using the provided session ID.

def _save(self) -> bool:

Saves the current session to the storage backend.

_id =

Undocumented

_storage =

Undocumented

_time_created =

Undocumented