Chatbot
- class dbt_llm_tools.Chatbot(dbt_project_root: str, openai_api_key: str, database_path: str = '.local_storage/db.json', vector_db_path: str = '.local_storage/chroma.db', embedding_model: str = 'text-embedding-3-large', chatbot_model: str = 'gpt-4o')[source]
A class representing a chatbot that allows users to ask questions about dbt models.
- Attributes:
project (DbtProject): The dbt project being used by the chatbot. store (VectorStore): The vector store being used by the chatbot.
- Methods:
set_embedding_model: Set the embedding model for the vector store. set_chatbot_model: Set the chatbot model for the chatbot. get_instructions: Get the instructions for the chatbot. set_instructions: Set the instructions for the chatbot. load_models: Load the models into the vector store. reset_model_db: Reset the model vector store. ask_question: Ask the chatbot a question and get a response.
- ask_question(query: str, get_model_names_only: bool = False) str[source]
Ask the chatbot a question about your dbt models and get a response. The chatbot looks the dbt models most similar to the user query and uses them to answer the question.
- Args:
query (str): The question you want to ask the chatbot.
- Returns:
str: The chatbot’s response to your question.
- get_instructions() list[str][source]
Get the instructions being used to tune the chatbot.
- Returns:
list[str]: A list of instructions being used to tune the chatbot.
- load_models(models: list[str] | None = None, included_folders: list[str] | None = None, excluded_folders: list[str] | None = None) None[source]
Upsert the set of models that will be available to your chatbot into a vector store. The chatbot will only be able to use these models to answer questions and nothing else.
The default behavior is to load all models in the dbt project, but you can specify a subset of models, included folders or excluded folders to customize the set of models that will be available to the chatbot.
- Args:
models (list[str], optional): A list of model names to load into the vector store.
included_folders (list[str], optional): A list of paths to all folders that should be included in model search. Paths are relative to dbt project root.
exclude_folders (list[str], optional): A list of paths to all folders that should be excluded in model search. Paths are relative to dbt project root.
- Returns:
None
- reset_model_db() None[source]
This will reset and remove all the models from the vector store. You’ll need to load the models again using the load_models method if you want to use the chatbot.
- Returns:
None
- set_chatbot_model(model: str) None[source]
Set the chatbot model for the chatbot.
- Args:
model (str): The name of the OpenAI chatbot model to be used.
- Returns:
None