Query CSV Files with Natural Language Using LangChain and Panel

Query CSV Files with Natural Language Using LangChain and Panel

The LangChain library provides pandas DataFrame agents that can be used to analyze data in a CSV file. These agents work by using large language models such as GPT-3 to first logically deduce what is required, then use that information to write code that achieves the purpose using the LLM, and finally run the code to get an observation. This cycle can repeat several times until the required answer is achieved.

In this project, we will use the Python Panel library to create an interactive dashboard that can be used to analyze any CSV file that is uploaded to it. The following components will be available on the web page:

  • A file upload widget that can be used to upload any CSV file.

  • A chat box for interacting with the agent.

  • An interactive table that shows the data present in the CSV file.

  • A Plotly scatter plot that can be used to visualize relations between any two features with respect to the target class.

The complete dashboard can be seen in the figure below:

The complete web application
The complete web application