Skip to content

Interface

Database Interface

Base DB is the base class for all databases. It provides a common interface for all databases to follow.

Base DB

director.db.base.BaseDB

Bases: ABC

Interface for all databases. It provides a common interface for all databases to follow.

create_session abstractmethod

create_session(
    session_id, video_id=None, collection_id=None
)

Create a new session.

Source code in backend/director/db/base.py
@abstractmethod
def create_session(
    self, session_id: str, video_id: str = None, collection_id: str = None
) -> None:
    """Create a new session."""
    pass

get_session abstractmethod

get_session(session_id)

Get a session by session_id.

Source code in backend/director/db/base.py
@abstractmethod
def get_session(self, session_id: str) -> dict:
    """Get a session by session_id."""
    pass

get_sessions abstractmethod

get_sessions()

Get all sessions.

Source code in backend/director/db/base.py
@abstractmethod
def get_sessions(self) -> list:
    """Get all sessions."""
    pass

add_or_update_msg_to_conv abstractmethod

add_or_update_msg_to_conv()

Add a new message (input or output) to the conversation.

Source code in backend/director/db/base.py
@abstractmethod
def add_or_update_msg_to_conv() -> None:
    """Add a new message (input or output) to the conversation."""
    pass

get_conversations abstractmethod

get_conversations(session_id)

Get all conversations for a given session.

Source code in backend/director/db/base.py
@abstractmethod
def get_conversations(self, session_id: str) -> list:
    """Get all conversations for a given session."""
    pass

get_context_messages abstractmethod

get_context_messages(session_id)

Get context messages for a session.

Source code in backend/director/db/base.py
@abstractmethod
def get_context_messages(self, session_id: str) -> list:
    """Get context messages for a session."""
    pass

add_or_update_context_msg abstractmethod

add_or_update_context_msg(session_id, context_messages)

Update context messages for a session.

Source code in backend/director/db/base.py
@abstractmethod
def add_or_update_context_msg(
    self, session_id: str, context_messages: list
) -> None:
    """Update context messages for a session."""
    pass

health_check abstractmethod

health_check()

Check if the database is healthy.

Source code in backend/director/db/base.py
@abstractmethod
def health_check(self) -> bool:
    """Check if the database is healthy."""
    pass