vanna.remote
Helper class that provides a standard way to create an ABC using inheritance.
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.
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.
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.
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.
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.
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.
Not necessary for remote models as embeddings are generated on the server side.
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.
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.
Not necessary for remote models as prompts are generated on the server side.
Not necessary for remote models as prompts are generated on the server side.
Not necessary for remote models as prompts are handled on the server side.
Not necessary for remote models as similar questions are generated on the server side.
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.
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.