LangChain Data Demo banner
hodgesmr hodgesmr

LangChain Data Demo

Data community

Description

Jupyter Notebook that demonstrates LLM-driven voter file data engineering, using LangChain to write SQL and Python

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

LangChain Data Demo

This is a [Jupyter Notebook](https://github.com/hodgesmr/LangChain-Data-Demo/blob/main/LangChain%20Data%20Demo.ipynb) that demonstrates a variety of data engineering and anaysis tasks one can tackle with [LangChain](https://python.langchain.com/en/latest/index.html). It walks through using the LLM (via OpenAI) to write and execute SQL queries, and then pass the results of those queries to Python for data visualization. It uses public data voter files.

This Notebook was written with LangChain version `0.0.128` using the `text-davinci-003` model from OpenAI.

![The LangChain agent executing SQL and Python to generate data visualization against the voter file](https://raw.githubusercontent.com/hodgesmr/LangChain-Data-Demo/main/agent_steps.png)

⚠️ **This Notebook generates and executes Python code written by an LLM. This has the potential to run unpredictable, buggy, or even harmful executions. Take caution to run this Notebook only in a sandboxed or appropriately controlled environment.** ⚠️

Setup

Before you can run the [Notebook](https://github.com/hodgesmr/LangChain-Data-Demo/blob/main/LangChain%20Data%20Demo.ipynb), you need to copy [.env.example](./.env.example) to [.env](./.env) (which is ignored by git) and fill in the `OPENAI_API_KEY` environment variable.

Also, be sure to install the requirements:

pip install -r requirements.txt

I wrote and tested this Notebook in Python 3.10.

License

All code is provided under the [BSD 3-Clause license](https://github.com/hodgesmr/LangChain-Data-Demo/blob/main/LICENSE).

North Carolina Voter Data

The data used by the code in this repository originated from the North Carolina State Board of Elections, with the following [license](https://s3.amazonaws.com/dl.ncsbe.gov/data/ReadMe_PUBLIC_DATA.txt):

/* *******************************************************************************
* name:     ReadMe_PUBLIC_DATA.txt
* purpose:  Notification to the public, media, and intereste