diff --git a/docs/notebooks/vn-ask.md b/docs/notebooks/vn-ask.md index 1249c16d..f6f4bd90 100644 --- a/docs/notebooks/vn-ask.md +++ b/docs/notebooks/vn-ask.md @@ -1,10 +1,10 @@ -![Vanna AI](https://img.vanna.ai/vanna-full.svg) +![Vanna AI](https://img.vanna.ai/vanna-ask.svg) -This notebook will help you unleash the full potential of AI-powered data analysis at your organization. We'll go through how to "bulk train" Vanna and generate SQL, tables, charts, and explanations, all with minimal code and effort. For more about Vanna, see our [intro blog post](https://medium.com/vanna-ai/intro-to-vanna-a-python-based-ai-sql-co-pilot-218c25b19c6a). +The following notebook goes through the process of asking questions from your data using Vanna AI. Here we use a demo model that is pre-trained on the [TPC-H dataset](https://docs.snowflake.com/en/user-guide/sample-data-tpch.html) that is available in Snowflake. -[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanna-ai/vanna-py/blob/main/notebooks/vn-full.ipynb) +[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vanna-ai/vanna-py/blob/main/notebooks/vn-ask.ipynb) -[![Open in GitHub](https://img.vanna.ai/github.svg)](https://github.com/vanna-ai/vanna-py/blob/main/notebooks/vn-full.ipynb) +[![Open in GitHub](https://img.vanna.ai/github.svg)](https://github.com/vanna-ai/vanna-py/blob/main/notebooks/vn-ask.ipynb) # Install Vanna First we install Vanna from [PyPI](https://pypi.org/project/vanna/) and import it. @@ -20,7 +20,6 @@ Here, we'll also install the Snowflake connector. If you're using a different da ```python import vanna as vn import snowflake.connector -import pandas as pd ``` # Login @@ -37,7 +36,7 @@ You need to choose a globally unique model name. Try using your company name or ```python -vn.set_model('my-model') # Enter your dataset name here. This is a globally unique identifier for your dataset. +vn.set_model('tpc') # Enter your model name here. This is a globally unique identifier for your model. ``` # Set Database Connection @@ -64,20 +63,105 @@ vn.ask("What are the top 10 customers by sales?") GROUP BY customer_name ORDER BY total_sales desc limit 10; -![plot1](plot1.png) - AI-generated follow-up questions: - What are the countries of the top 10 customers by sales? - How many orders did each of the top 10 customers place? - What is the average sales amount per customer in the top 10? - Can you provide a breakdown of the sales by country for the top 10 customers? - Who are the top 10 customers in terms of returned parts gross value? - What are the total sales for each customer in the top 3? - Can you provide a breakdown of the sales by region for the top customers? - How many customers are there in each country? - What is the total revenue for the top 5 countries? - Can you provide a breakdown of the sales by customer for the top 5 countries? +
+ | CUSTOMER_NAME | +TOTAL_SALES | +
---|---|---|
0 | +Customer#000143500 | +6757566.0218 | +
1 | +Customer#000095257 | +6294115.3340 | +
2 | +Customer#000087115 | +6184649.5176 | +
3 | +Customer#000131113 | +6080943.8305 | +
4 | +Customer#000134380 | +6075141.9635 | +
5 | +Customer#000103834 | +6059770.3232 | +
6 | +Customer#000069682 | +6057779.0348 | +
7 | +Customer#000102022 | +6039653.6335 | +
8 | +Customer#000098587 | +6027021.5855 | +
9 | +Customer#000064660 | +5905659.6159 | +
+ | id | +training_data_type | +question | +content | +
---|---|---|---|---|
0 | +15-doc | +documentation | +None | +This is a table in the PARTSUPP table.\n\nThe ... | +
1 | +11-doc | +documentation | +None | +This is a table in the CUSTOMER table.\n\nThe ... | +
2 | +14-doc | +documentation | +None | +This is a table in the ORDERS table.\n\nThe fo... | +
3 | +1244-sql | +sql | +What are the names of the top 10 customers? | +SELECT c.c_name as customer_name\nFROM snowf... | +
4 | +1242-sql | +sql | +What are the top 5 customers in terms of total... | +SELECT c.c_name AS customer_name, SUM(l.l_quan... | +
5 | +17-doc | +documentation | +None | +This is a table in the REGION table.\n\nThe fo... | +
6 | +16-doc | +documentation | +None | +This is a table in the PART table.\n\nThe foll... | +
7 | +1243-sql | +sql | +What are the top 10 customers with the highest... | +SELECT c.c_name as customer_name,\n sum(... | +
8 | +1239-sql | +sql | +What are the top 100 customers based on their ... | +SELECT c.c_name as customer_name,\n sum(... | +
9 | +13-doc | +documentation | +None | +This is a table in the SUPPLIER table.\n\nThe ... | +
10 | +1241-sql | +sql | +What are the top 10 customers in terms of tota... | +SELECT c.c_name as customer_name,\n sum(... | +
11 | +12-doc | +documentation | +None | +This is a table in the LINEITEM table.\n\nThe ... | +
12 | +18-doc | +documentation | +None | +This is a table in the NATION table.\n\nThe fo... | +
13 | +1248-sql | +sql | +How many customers are in each country? | +SELECT n.n_name as country,\n count(*) a... | +
14 | +1240-sql | +sql | +What is the number of orders placed each week? | +SELECT date_trunc('week', o_orderdate) as week... | +
\n", + " | id | \n", + "training_data_type | \n", + "question | \n", + "content | \n", + "
---|---|---|---|---|
0 | \n", + "15-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the PARTSUPP table.\\n\\nThe ... | \n", + "
1 | \n", + "11-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the CUSTOMER table.\\n\\nThe ... | \n", + "
2 | \n", + "14-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the ORDERS table.\\n\\nThe fo... | \n", + "
3 | \n", + "1244-sql | \n", + "sql | \n", + "What are the names of the top 10 customers? | \n", + "SELECT c.c_name as customer_name\\nFROM snowf... | \n", + "
4 | \n", + "1242-sql | \n", + "sql | \n", + "What are the top 5 customers in terms of total... | \n", + "SELECT c.c_name AS customer_name, SUM(l.l_quan... | \n", + "
5 | \n", + "17-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the REGION table.\\n\\nThe fo... | \n", + "
6 | \n", + "16-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the PART table.\\n\\nThe foll... | \n", + "
7 | \n", + "1243-sql | \n", + "sql | \n", + "What are the top 10 customers with the highest... | \n", + "SELECT c.c_name as customer_name,\\n sum(... | \n", + "
8 | \n", + "1239-sql | \n", + "sql | \n", + "What are the top 100 customers based on their ... | \n", + "SELECT c.c_name as customer_name,\\n sum(... | \n", + "
9 | \n", + "13-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the SUPPLIER table.\\n\\nThe ... | \n", + "
10 | \n", + "1241-sql | \n", + "sql | \n", + "What are the top 10 customers in terms of tota... | \n", + "SELECT c.c_name as customer_name,\\n sum(... | \n", + "
11 | \n", + "12-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the LINEITEM table.\\n\\nThe ... | \n", + "
12 | \n", + "18-doc | \n", + "documentation | \n", + "None | \n", + "This is a table in the NATION table.\\n\\nThe fo... | \n", + "
13 | \n", + "1248-sql | \n", + "sql | \n", + "How many customers are in each country? | \n", + "SELECT n.n_name as country,\\n count(*) a... | \n", + "
14 | \n", + "1240-sql | \n", + "sql | \n", + "What is the number of orders placed each week? | \n", + "SELECT date_trunc('week', o_orderdate) as week... | \n", + "