Overview
Tableau’s VizQL Data Service (aka VDS) provides developers with programmatic access to their Tableau Published Data Sources, allowing them to extend their business semantics for any custom workload or application, including AI Agents. The simple_datasource_qa tool adds VDS to the LangChain framework. This notebook shows you how you can use it to build agents that answer analytical questions grounded on your enterprise semantic models. Follow the tableau-langchain project for more tools coming soon!Setup
Make sure you are running and have access to:- python version 3.12.2 or higher
- A Tableau Cloud or Server environment with at least 1 published data source
Credentials
You can declare your environment variables explicitly, as shown in several cases in this doc. However, if these parameters are not provided, the simple_datasource_qa tool will attempt to automatically read them from environment variables. For the Data Source that you choose to query, make sure you’ve updated the VizqlDataApiAccess permission in Tableau to allow the VDS API to access that Data Source via REST. More info here.Authentication Variables
You can declare your environment variables explicitly, as shown in several cases in this cookbook. However, if these parameters are not provided, the simple_datasource_qa tool will attempt to automatically read them from environment variables. For the Data Source that you choose, make sure you’ve updated the VizqlDataApiAccess permission in Tableau to allow the VDS API to access that Data Source via REST. More info here.Instantiation
The initialize_simple_datasource_qa initializes the LangGraph tool called simple_datasource_qa, which can be used for analytical questions and answers on a Tableau Data Source. This initializer function:- Authenticates to Tableau using Tableau’s connected-app framework for JWT-based authentication. All the required variables must be defined at runtime or as environment variables.
- Asynchronously queries for the field metadata of the target datasource specified in the datasource_luid variable.
- Grounds on the metadata of the target datasource to transform natural language questions into the json-formatted query payload required to make VDS query-datasource requests.
- Executes a POST request to VDS.
- Formats and returns the results in a structured response.