Skip to content

ViewSelector Base Class#

View selectors are responsible for choosing the most relevant View for the given user query.

flowchart LR
    Q[Do we have any Data Scientists?]
    Views["`Employees View
    ProjectsView
    BenefitsView`"]
    VS[ViewSelector]

    Q --> VS
    Views --> VS
    VS --> S[EmployeesView]

dbally.view_selection.base.ViewSelector #

Bases: ABC

Base class for view selectors.

select_view abstractmethod async #

select_view(question: str, views: Dict[str, str], event_tracker: EventTracker, llm_options: Optional[LLMOptions] = None) -> str

Based on user question and list of available views select the most relevant one.

PARAMETER DESCRIPTION
question

user question asked in the natural language e.g "Do we have any data scientists?"

TYPE: str

views

dictionary of available view names with corresponding descriptions.

TYPE: Dict[str, str]

event_tracker

event tracker used to audit the selection process.

TYPE: EventTracker

llm_options

options to use for the LLM client.

TYPE: Optional[LLMOptions] DEFAULT: None

RETURNS DESCRIPTION
str

The most relevant view name.

Source code in src/dbally/view_selection/base.py
@abc.abstractmethod
async def select_view(
    self,
    question: str,
    views: Dict[str, str],
    event_tracker: EventTracker,
    llm_options: Optional[LLMOptions] = None,
) -> str:
    """
    Based on user question and list of available views select the most relevant one.

    Args:
        question: user question asked in the natural language e.g "Do we have any data scientists?"
        views: dictionary of available view names with corresponding descriptions.
        event_tracker: event tracker used to audit the selection process.
        llm_options: options to use for the LLM client.

    Returns:
        The most relevant view name.
    """