LLM-powered tool for converting natural language into visualizations
Top 98.4% on sourcepulse
This library enables users to generate data visualizations and explanations from natural language queries using Large Language Models (LLMs). It targets data analysts and researchers who need to quickly explore and present data without writing code. The primary benefit is a secure, language-independent, and interactive way to create charts by having the LLM output declarative JSON specifications rather than executable code.
How It Works
Chat2Plot leverages LLMs to translate natural language requests into high-level chart specifications in JSON format, supporting both a simple internal format and Vega-Lite. This declarative approach is advantageous because it enhances security by preventing the LLM from generating executable code, making it language-independent for use in non-Python environments, and enabling interactive refinement of plots through user-LLM collaboration. The generated JSON specifications are then rendered into actual charts using libraries like Plotly or Altair.
Quick Start & Requirements
pip install chat2plot
OPENAI_API_KEY
).import os
import pandas as pd
from chat2plot import chat2plot
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
df = pd.read_csv("your_data.csv")
c2p = chat2plot(df)
result = c2p("average target over countries")
result.figure.show()
Highlighted Details
description_strategy="dtypes"
option.Maintenance & Community
The project is maintained by nyanp. Further community or roadmap information is not detailed in the README.
Licensing & Compatibility
The README does not explicitly state a license. Compatibility for commercial use or closed-source linking is not specified.
Limitations & Caveats
The declarative JSON output limits visualization expressiveness compared to direct code generation. The default model is gpt-3.5-turbo-0613
, and OpenAI API keys are required, which may have cost implications.
1 year ago
1 week