dbally#
dbally.create_collection
#
create_collection(name: str, llm: LLM, event_handlers: Optional[List[EventHandler]] = None, view_selector: Optional[ViewSelector] = None, nl_responder: Optional[NLResponder] = None) -> Collection
Create a new Collection that is a container for registering views and the main entrypoint to db-ally features.
Unlike instantiating a [Collection][dbally.Collection] directly, this function provides a set of default values for various dependencies like LLM client, view selector, IQL generator, and NL responder.
Example#
from dbally import create_collection
from dbally.llms.litellm import LiteLLM
collection = create_collection("my_collection", llm=LiteLLM())
PARAMETER | DESCRIPTION |
---|---|
name |
Name of the collection is available for Event handlers and is used to distinguish different db-ally runs.
TYPE:
|
llm |
LLM used by the collection to generate responses for natural language queries.
TYPE:
|
event_handlers |
Event handlers used by the collection during query executions. Can be used to log events as CLIEventHandler or to validate system performance as LangSmithEventHandler. If provided, this parameter overrides the
TYPE:
|
view_selector |
View selector used by the collection to select the best view for the given query. If None, a new instance of LLMViewSelector will be used.
TYPE:
|
nl_responder |
NL responder used by the collection to respond to natural language queries. If None, a new instance of NLResponder will be used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Collection
|
New instance of db-ally Collection. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If default LLM client is not configured. |