BaseView#
Tip
- To understand the general idea better, visit Concept: Views and Concept: Freeform Views
- To learn about structured views, which in most cases are the recommended way to define views, see the reference for the
BaseStructuredView
class
dbally.views.base.BaseView
#
Base class for all Views, which are the main building blocks of db-ally. All classes implementing this interface have to be able to execute queries and return the result.
ask
abstractmethod
async
#
ask(query: str, llm: LLM, event_tracker: Optional[EventTracker] = None, n_retries: int = 3, dry_run: bool = False, llm_options: Optional[LLMOptions] = None) -> ViewExecutionResult
Executes the query and returns the result.
PARAMETER | DESCRIPTION |
---|---|
query |
The natural language query to execute.
TYPE:
|
llm |
The LLM used to execute the query.
TYPE:
|
event_tracker |
The event tracker used to audit the query execution.
TYPE:
|
n_retries |
The number of retries to execute the query in case of errors.
TYPE:
|
dry_run |
If True, the query will not be used to fetch data from the datasource.
TYPE:
|
llm_options |
Options to use for the LLM.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ViewExecutionResult
|
The result of the query. |
Source code in src/dbally/views/base.py
list_similarity_indexes
#
Lists all the similarity indexes used by the view.
RETURNS | DESCRIPTION |
---|---|
Dict[AbstractSimilarityIndex, List[IndexLocation]]
|
Mapping of similarity indexes to their locations. |
list_few_shots
#
list_few_shots() -> List[FewShotExample]
List all examples to be injected into few-shot prompt.
RETURNS | DESCRIPTION |
---|---|
List[FewShotExample]
|
List of few-shot examples |
dbally.collection.results.ViewExecutionResult
dataclass
#
Represents the result of the query execution for a single view.
PARAMETER | DESCRIPTION |
---|---|
results |
List of dictionaries containing the results of the query execution, each dictionary represents a row in the result set with column names as keys.
TYPE:
|
context |
Dictionary containing addtional metadata about the query execution.
TYPE:
|