Visualize your data with Langchain and Plotly through 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
Imports
from plotly_agent import extract_python_code
from plotly_agent.evaluate 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.2.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file plotly_agent-0.1.2.tar.gz
.
File metadata
- Download URL: plotly_agent-0.1.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b3ba1110a5d8862a3343e02f5e303bd70b1c4724aeb3f916cac1ce714c2f630 |
|
MD5 | b25ef6ef9e0b970423f751da12cabb33 |
|
BLAKE2b-256 | 011944c28226bc33cb19058345a0ed3704a0873c42427ca85f219ed68c456b2f |
File details
Details for the file plotly_agent-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: plotly_agent-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d73f089133bfe9903fa1cbc47b2ad7010c9e5d9af7925e7c5182f6376bd911e |
|
MD5 | 46e7c96346634f4e464f15505dbf5c54 |
|
BLAKE2b-256 | 4bb1ede3c720fd0ba08a3aa63445a10fe1a212321f86387c9c264faf59d05606 |