Skip to content

Tableau tools for Agentic use cases with Langchain & Langgraph. Enfuse agents with updated data so they make better informed decisions that scale with your analytics practice

License

Notifications You must be signed in to change notification settings

tableau/tableau_langchain

Repository files navigation

Tableau Langchain

Community Supported PyPI version GitHub Repo

This project builds Agentic tools from Tableau capabilities for use within the Langchain and LangGraph frameworks. Solutions such as Tools, Utilities, and Chains are published to the PyPi registry under langchain-tableau following conventions for integrations to Langchain.

Important

On May 27 2025 this project was moved from the Tableau Solution Engineering GitHub organization to the main Tableau OSS one:

Everything should be moved over intact and everyone should still have the same access.

All links to the previous location should automatically redirect to the new location. If you have a copy of this project cloned locally, we recommend updating to point to the new location:

git remote set-url origin https://github.com/tableau/tableau_langchain

tableau logo

pip install langchain-tableau

We'd like you to explore how Agentic tools can drive alignment between your organization's data and the day-to-day needs of your users. Consider contributing to this project or creating your own work on a different framework, ultimately we seek to increase the flow of data and help people get answers from it.

To see live demos of Agents using Tableau, visit:


Table of Contents

area chart

Getting Started

The easiest way to start with tableau_langchain is to try the Jupyter Notebooks in the experimental/notebooks/ folder. These examples will guide you through different use cases and scenarios with increasing complexity.

Published Solutions

To use the solutions available at langchain-tableau in notebooks and your code, do the following:

  1. Install langchain-tableau

    pip install langchain-tableau
  2. Import langchain-tableau and use it with your Agent (in a Python file or Jupyter Notebook)

     # langchain and langgraph package imports
     from langchain_openai import ChatOpenAI
     from langgraph.prebuilt import create_react_agent
     # langchain_tableau imports
     from langchain_tableau.tools.simple_datasource_qa import initialize_simple_datasource_qa
    
     # initialize an LLM
     llm = ChatOpenAI(model='gpt-4o-mini', temperature=0)
    
     # initalize `simple_datasource_qa` for querying a Tableau Published Datasource through VDS
     analyze_datasource = initialize_simple_datasource_qa(
         domain='https://your-tableau-cloud-or-server.com',
         site='Tableau site name',
         jwt_client_id='from an enabled Tableau Connected App',
         jwt_secret_id='from an enabled Tableau Connected App',
         jwt_secret='from an enabled Tableau Connected App',
         tableau_api_version='Tableau REST API version',
         tableau_user='user to query the Agent with',
         datasource_luid='unique data source ID can be obtained via REST or Metadata APIs',
         tooling_llm_model='model to use for the data query tool'
     )
    
     # Add the tool to the array of tools used by the Agent
     tools = [ analyze_datasource ]
    
     # Build the Agent using the minimum components (LLM + Tools)
     tableauAgent = create_react_agent(llm, tools)
    
     # Run the Agent
     messages = tableauAgent.invoke({"messages": [("human",'which states sell the most? Are those the same states with the most profits?')]})

Experimental Sandbox

To develop and test solutions for the langchain-tableau package, this repository contains an experimental/ folder organizing Agents, Tools, Utilities and other files that allow contributors to improve the solutions made available to the open-source community.

To use the sandbox, do the following:

  1. Clone the repository

    git clone https://github.com/Tab-SE/tableau_langchain.git
  2. Create a Python environment to isolate project dependencies (optional)

    Note: This example uses conda (environment.yml file provided). If you use conda skip to step #4 since dependencies will already be installed. Other environment management systems should also work (poetry, venv, mamba etc.)

    conda env create -f environment.yml
    conda activate tableau_langchain
  3. Install project dependencies (use this to install anytime with or without isolated Python environments)

    Note: dependencies are listed in the pyproject.toml file

    pip install .

    You must also install the langgraph-cli developer dependency to run the Langgraph Server (see langgraph-cli)

    pip install langgraph-cli

    If you wish to run the Langgraph Server in local development mode, you will need the inmem extra (see langgraph dev command)

    pip install -U "langgraph-cli[inmem]"
  4. Declare Environment Variables

    Start by duplicating the template file:

    cp .env.template .env

    Replace the values in the .env file with your own. These values are secure and never published to Github

  5. Run an Agent in the terminal

    python main.py
  6. Run the Langgraph Server API (see langgraph-cli)

    Note: Docker Desktop must also be running

    Local Development

    langgraph dev

    Docker Container

    langgraph build
    langgraph up

dual axis area chart

About This Project

This repository is a monorepo with two components. The main goal is to publish and support a Langchain integration. This produces a need to have a development sandbox to try these solutions before publishing them for open-source use.

The code base has two top-level folders: experimental/ and pkg/. Experimental is where active development takes place. Use this folder to build and test new tools, chains, and agents, or extend the resources that are already there. The pkg/ folder packages up well-tested resources for inclusion in our public PyPi package: langchain-tableau. If you have a contribution to pkg/, first make sure it’s been tested in experimental, and then submit your PR via GitHub.

The main branch will always be the latest stable branch.

Published Solutions

The pgk folder contains production code shipped to the PyPi registry. These are available resources:

  1. simple_datasource_qa.py
    • Query a Published Datasource in natural language
    • Leverage the analytical engine provided by Tableau's VizQL Data Service
      • Supports aggregating, filtering, and soon: calcs!
      • Scales securely by way of the API interface, preventing SQL injection

Experimental Sandbox

The experimental folder organizes agents, tools, utilities, and notebooks for developing and solution testing that may eventually be published (see Published Agent Tools) for community use. This folder is a sandbox for Tableau AI.

Security

Tableau resources are accessed via supported authentication methods such as Connected Apps. Secrets, keys and other credentials used to access Tableau should not be published to Github and instead stored securely via .env files. See step #4 in the Getting Started section.

Learn more by reading our Security article.

Contributing

The Tableau developer community (aka DataDev) is more than welcome to contribute to this project by enhancing either the experimental or pkg folders.

This is the founding team for the project. Please consider contributing in your own way to further what's possible when you combine Tableau with AI Agents.

If you wish to contribute to this project, please refer to our Contribution Guidelines. Also, check out the Code of Conduct.

datadev

About

Tableau tools for Agentic use cases with Langchain & Langgraph. Enfuse agents with updated data so they make better informed decisions that scale with your analytics practice

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published