vanna.remote

class VannaDefault(vanna.base.base.VannaBase):

Helper class that provides a standard way to create an ABC using inheritance.

VannaDefault(model: str, api_key: str, config=None)
def get_training_data(self, **kwargs) -> pandas.core.frame.DataFrame:

Get the training data for the current model

Example:

training_data = vn.get_training_data()
Returns:

pd.DataFrame or None: The training data, or None if an error occurred.

def remove_training_data(self, id: str, **kwargs) -> bool:

Remove training data from the model

Example:

vn.remove_training_data(id="1-ddl")
Arguments:
  • id (str): The ID of the training data to remove.
def generate_questions(self) -> list[str]:

Example:

vn.generate_questions()
# ['What is the average salary of employees?', 'What is the total salary of employees?', ...]

Generate questions using the Vanna.AI API.

Returns:

List[str] or None: The questions, or None if an error occurred.

def add_ddl(self, ddl: str, **kwargs) -> str:

Adds a DDL statement to the model's training data

Example:

vn.add_ddl(
    ddl="CREATE TABLE employees (id INT, name VARCHAR(255), salary INT)"
)
Arguments:
  • ddl (str): The DDL statement to store.
Returns:

str: The ID of the DDL statement.

def add_documentation(self, doc: str, **kwargs) -> str:

Adds documentation to the model's training data

Example:

vn.add_documentation(
    documentation="Our organization's definition of sales is the discount price of an item multiplied by the quantity sold."
)
Arguments:
  • documentation (str): The documentation string to store.
Returns:

str: The ID of the documentation string.

def add_question_sql(self, question: str, sql: str, **kwargs) -> str:

Adds a question and its corresponding SQL query to the model's training data. The preferred way to call this is to use [vn.train(sql=...)][vanna.train].

Example:

vn.add_sql(
    question="What is the average salary of employees?",
    sql="SELECT AVG(salary) FROM employees"
)
Arguments:
  • question (str): The question to store.
  • sql (str): The SQL query to store.
  • tag (Union[str, None]): A tag to associate with the question and SQL query.
Returns:

str: The ID of the question and SQL query.

def generate_embedding(self, data: str, **kwargs) -> list[float]:

Not necessary for remote models as embeddings are generated on the server side.

def generate_plotly_code( self, question: str = None, sql: str = None, df_metadata: str = None, **kwargs) -> str:

Example:

vn.generate_plotly_code(
    question="What is the average salary of employees?",
    sql="SELECT AVG(salary) FROM employees",
    df_metadata=df.dtypes
)
# fig = px.bar(df, x="name", y="salary")

Generate Plotly code using the Vanna.AI API.

Arguments:
  • question (str): The question to generate Plotly code for.
  • sql (str): The SQL query to generate Plotly code for.
  • df (pd.DataFrame): The dataframe to generate Plotly code for.
  • chart_instructions (str): Optional instructions for how to plot the chart.
Returns:

str or None: The Plotly code, or None if an error occurred.

def generate_question(self, sql: str, **kwargs) -> str:

Example:

vn.generate_question(sql="SELECT * FROM students WHERE name = 'John Doe'")
# 'What is the name of the student?'

Generate a question from an SQL query using the Vanna.AI API.

Arguments:
  • sql (str): The SQL query to generate a question for.
Returns:

str or None: The question, or None if an error occurred.

def get_sql_prompt( self, question: str, question_sql_list: list, ddl_list: list, doc_list: list, **kwargs):

Not necessary for remote models as prompts are generated on the server side.

def get_followup_questions_prompt( self, question: str, df: pandas.core.frame.DataFrame, question_sql_list: list, ddl_list: list, doc_list: list, **kwargs):

Not necessary for remote models as prompts are generated on the server side.

def submit_prompt(self, prompt, **kwargs) -> str:

Not necessary for remote models as prompts are handled on the server side.

def get_similar_question_sql(self, question: str, **kwargs) -> list:

Not necessary for remote models as similar questions are generated on the server side.

def generate_sql(self, question: str, **kwargs) -> str:

Example:

vn.generate_sql_from_question(question="What is the average salary of employees?")
# SELECT AVG(salary) FROM employees

Generate an SQL query using the Vanna.AI API.

Arguments:
  • question (str): The question to generate an SQL query for.
Returns:

str or None: The SQL query, or None if an error occurred.

def generate_followup_questions( self, question: str, df: pandas.core.frame.DataFrame, **kwargs) -> list[str]:

Example:

vn.generate_followup_questions(question="What is the average salary of employees?", df=df)
# ['What is the average salary of employees in the Sales department?', 'What is the average salary of employees in the Engineering department?', ...]

Generate follow-up questions using the Vanna.AI API.

Arguments:
  • question (str): The question to generate follow-up questions for.
  • df (pd.DataFrame): The DataFrame to generate follow-up questions for.
Returns:

List[str] or None: The follow-up questions, or None if an error occurred.