A small repo for a tutorial I wrote on using LangChain's python library from a JS app.
This repo was created for a blog post I wrote on using the python langchain library from a Javascript app.
The code is organized in two folders. The flask server code lives in langchain-flask-server
and the JS test file and data lives in js-test
.
The flask server has one POST endpoint that accepts json and a query, and then uses LangChain's pandas_dataframe_agent to answer the query.
You must have the following installed on your computer:
- python
- pip
- virtualenv
- node version 17.5 or greater
- Clone the Repo
- Create the virtual environment
python3 -m venv .venv
- Activate the virtual environment
. .venv/bin/activate
- Install the required packages:
pip install Flask
pip install pandas
pip install langchain
pip install python-dotenv
- Open a new terminal window for the
langchain-flask-server
- Run the server
flask run
You'll know it's working if you navigate to http://127.0.0.1:5000/ and see "I'm building something cool today!"
In order for the API to execute the langchain POST request, you'll have to create a .env
file and add your OpenAI API key.
- Open a terminal window for the js test file
- Run the code
node api-test
Replace the JSON data or update the query to see what the pandas_dataframe_agent can do!