Skip to main content

chat to visualization with LLM

Project description

📈 Chat2Plot - interactive text-to-visualization with LLM

Chat2plot is a project that provides visualizations based on chat instructions for given data.

demo: https://chat2plot-sample.streamlit.app/

Usage

import os
import pandas as pd
from chat2plot import chat2plot

# 1. Set api-key
os.environ["OPENAI_API_KEY"] = "..."

df = pd.read_csv(...)

# 2. Pass a dataframe to draw
c2p = chat2plot(df)

# 3. Plot chart interactively
c2p("average target over countries")

c2p("change to horizontal-bar chart")

c2p("...")

Why Chat2Plpot

Inside Chat2Plot, LLM does not generate Python code, but generates plot specifications in json.

The declarative visualization specification in json is transformed into actual charts in Chat2Plot using plotly or altair, but users can also use json directly in their own applications.

This design limits the visualization expression compared to Python code generation (such as ChatGPT's Code Interpreter Plugin), but has the following practical advantages:

  • Secure

    • More secure execution, as LLM does not directly generate code.
  • Language-independent

    • Declarative data structures are language-agnostic, making it easy to plot in non-Python environments.
  • Interactive

    • Declarative data can be modified by the user to improve plots through collaborative work between the user and LLM.

The json schema can be selected from a default simple definition or a vega-lite compliant schema.

c2p = chat2plot(df, "vega")  # use vega-lite format

ret = c2p("plot x vs y")

ret.config  # get vega-lite compliant json data

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chat2plot-0.0.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chat2plot-0.0.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file chat2plot-0.0.3.tar.gz.

File metadata

  • Download URL: chat2plot-0.0.3.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for chat2plot-0.0.3.tar.gz
Algorithm Hash digest
SHA256 12d577ec0413bfc414c5824698d41f983606c5b441e93f0f976837973273ebc4
MD5 08576d5315ce401885024b0c71d7a7b0
BLAKE2b-256 d8d51b57914b535b8638594245d8ae0c94cba872689fdf3de3f233329edd215d

See more details on using hashes here.

File details

Details for the file chat2plot-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: chat2plot-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for chat2plot-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2865a275b817feb7d8ea7e8c580feffa5ee841e887451c02dcf199a3daddcc81
MD5 c41920819989ffce897f93d8288b781f
BLAKE2b-256 e7259be45d5bcfdbb9f301d84c2d45295190c319509f4ac1c4493d731b741ff6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page