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.
Installation
pip install plotly_agent
Example
Libraries:
from plotly_agent import extract_python_code
from plotly_agent.evaluate.judge_text import judge
from plotly_agent import create_plotly_agent
Execution code:
# 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
Release history Release notifications | RSS feed
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.1.tar.gz
(5.1 kB
view details)
File details
Details for the file plotly_agent-0.1.1.tar.gz
.
File metadata
- Download URL: plotly_agent-0.1.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65f7f354fba43aedcb66dc448897c0ec1078b7383a0448cdeff965d2657d71d0 |
|
MD5 | 7c0a7b39e09d13c89ea4a2eb85eb932d |
|
BLAKE2b-256 | 849f8a5c0292c3e8ddcdc48ca82fe1b2285240c7d6782b00a3c1a198cbc9f865 |