Skip to main content

Visualize your data with langchain and plotly as a plotly agent

Reason this release was yanked:

this version is deprecated, install plotly-agent >= 0.1.4 instead

Project description

plotly-agent

A library to create interactive charts with Plotly and Langchain through an data visualization agent.

Instalação

pip install plotly_agent

Exemplo de uso

from plotly_agent import extract_python_code
from plotly_agent.evaluate.judge_text import judge
from plotly_agent import create_plotly_agent
# judge if a input deserve a data visualization
judgment = judge(text=prompt, openai_api_key=OPENAI_API_KEY)

if judgment:
        llm = ChatOpenAI(
            openai_api_key=OPENAI_API_KEY,
            # gpt-4-turbo had a better perform than gpt-4o and gpt-4o-mini
            model_name='gpt-4-turbo',
            temperature=0.0
        )

        plotly_agent = create_plotly_agent(llm=llm, max_interations=8, verbose=True)
        plotly_response = plotly_agent.invoke({'input': prompt})
        
        # Get python code from llm reponse
        fig_code = extract_python_code(plotly_response['output'])
        fig_dict = {"fig": Figure}
        exec(fig_code, fig_dict)
        
        # Returns a plottable figure
        fig = fig_dict.get("fig", None)

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

plotly_agent-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

plotly_agent-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file plotly_agent-0.1.0.tar.gz.

File metadata

  • Download URL: plotly_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for plotly_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 61e1d0645b40f96f11b8f6919851d683a3de7ce1f5d6b0fa4724fe55514651b4
MD5 98f0f5f3112df78ddefb25009ed13b63
BLAKE2b-256 d87164b08f3abd381f6366006f52f6c2ed10840efe67092a9b59541f3a520fbb

See more details on using hashes here.

File details

Details for the file plotly_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: plotly_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for plotly_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7adf98aacd8537da517c929036ba9a0bcdae2d60603db192d5c4301cdb99600
MD5 44369f28c5a77780357913afe3a3fdde
BLAKE2b-256 7d2e99a3c28c62f55c509f737e50f116f420840733fb558eb1eecc30e7dec136

See more details on using hashes here.

Supported by

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