LLMViewSelector#
dbally.view_selection.LLMViewSelector
#
LLMViewSelector(llm: LLM, prompt_template: Optional[PromptTemplate[ViewSelectionPromptFormat]] = None)
Bases: ViewSelector
The LLMViewSelector
utilises LLMs to select the most suitable view to answer the user question.
Its primary function is to determine the optimal view that can effectively be used to answer a user's question.
The method used to select the most relevant view is self.select_view
.
It formats views using view.name: view.description format and then calls LLM Client,
ultimately returning the name of the most suitable view.
Constructs a new LLMViewSelector instance.
PARAMETER | DESCRIPTION |
---|---|
llm |
LLM used to generate IQL
TYPE:
|
prompt_template |
template for the prompt used for the view selection
TYPE:
|
Source code in src/dbally/view_selection/llm_view_selector.py
select_view
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 by prompting LLM.
PARAMETER | DESCRIPTION |
---|---|
question |
user question asked in the natural language e.g "Do we have any data scientists?"
TYPE:
|
views |
dictionary of available view names with corresponding descriptions.
TYPE:
|
event_tracker |
event tracker used to audit the selection process.
TYPE:
|
llm_options |
options to use for the LLM client.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The most relevant view name. |
RAISES | DESCRIPTION |
---|---|
LLMError
|
If LLM text generation fails. |