yera.ui.sessions_store.base
Module for managing and persisting Yera app session data.
Symbols
BaseSessionStore
ABCSQLiteSessionStoreAbstract base class for storing and retrieving chat sessions.
Methods
BaseSessionStore.create
create(
app_id: str,
) → SessionRecordCreates a new session in the store.
Parameters
The ID of the application associated with the session.
Returns
The created SessionRecord.
BaseSessionStore.has
has(
session_id: str,
) → boolChecks if a session exists in the store.
Parameters
The unique identifier of the session.
Returns
True if the session exists, False otherwise.
BaseSessionStore.has_events
has_events(
session_id: str,
) → boolChecks whether a session already has any recorded events.
Used to distinguish a brand-new session (safe to launch live) from a historical one (should only ever be replayed).
Parameters
The unique identifier of the session.
Returns
True if the session has one or more recorded events.
BaseSessionStore.get
get(
session_id: str,
) → SessionRecordRetrieves a session record by its ID.
Parameters
The unique identifier of the session.
Returns
The requested SessionRecord.
BaseSessionStore.list
list() → list[SessionRecord]Lists all stored session records.
Returns
A list of all SessionRecords.
BaseSessionStore.update
update(
session_id: str,
title: str | None = None,
status: SessionStatus | None = None,
) → NoneUpdates the metadata of an existing session.
Parameters
The unique identifier of the session.
An optional new title for the session.
An optional new lifecycle status for the session.
BaseSessionStore.append_event
append_event(
session_id: str,
event: OutputEvent | InputEvent,
update: SessionRecordUpdate | None = None,
) → NoneAppends an event to a session's history.
Parameters
The unique identifier of the session.
The input or output event to store.
Optional session metadata changes to apply atomically.
BaseSessionStore.read_events
read_events(
session_id: str,
) → Iterator[OutputEvent | InputEvent]Reads all events associated with a session.
Parameters
The unique identifier of the session.
Returns
An iterator over the session's events.
BaseSessionStore.__enter__
__enter__() → SelfEnter the session store context.
BaseSessionStore.__exit__
__exit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) → NoneExit the session store context.
SessionRecord
BaseModelRepresents a record of a user session, including its metadata.
Methods
SessionRecord.new
new(
app_id: str,
title: str | None = None,
) → SessionRecordCreates a new session record.
Parameters
The ID of the application associated with the session.
optional title to assign to the session. Defaults to new chat.
Returns
A new SessionRecord instance.
SessionRecordUpdate
BaseModelMetadata changes to apply while recording a session event.