You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It cannot go through when using the Agent to plot pictures. It is okay if the question response is supposed to be text.
Below is my code:
import os
from dotenv import load_dotenv
import pandas as pd
from pandasai import Agent
load_dotenv()
DEFAULT_PICTURE_FOLDER = "./exports/charts"
# create picture folder if necessary
if not os.path.isdir(DEFAULT_PICTURE_FOLDER):
os.makedirs(DEFAULT_PICTURE_FOLDER)
df = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"sales": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})
agent = Agent(
df,
config={
"verbose": True,
"enforce_privacy": True,
"enable_cache": True,
"conversational": False,
"save_charts": False,
"open_charts": False,
"save_charts_path": DEFAULT_PICTURE_FOLDER,
},
)
qeury = "Plot the histogram of countries in Europe showing for each the gdp, using different colors for each bar"
response = agent.chat(qeury)
full traceback is as below
Traceback (most recent call last):
File "/Users/liaden/miniconda3/envs/genai/lib/python3.10/site-packages/pandasai/pipelines/chat/generate_chat_pipeline.py", line 283, in run
output = (self.code_generation_pipeline | self.code_execution_pipeline).run(
File "/Users/liaden/miniconda3/envs/genai/lib/python3.10/site-packages/pandasai/pipelines/pipeline.py", line 137, in run
raise e
File "/Users/liaden/miniconda3/envs/genai/lib/python3.10/site-packages/pandasai/pipelines/pipeline.py", line 101, in run
step_output = logic.execute(
File "/Users/liaden/miniconda3/envs/genai/lib/python3.10/site-packages/pandasai/pipelines/chat/code_execution.py", line 134, in execute
{"content_type": "response", "value": ResponseSerializer.serialize(result)},
File "/Users/liaden/miniconda3/envs/genai/lib/python3.10/site-packages/pandasai/responses/response_serializer.py", line 29, in serialize
with open(result["value"], "rb") as image_file:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/liaden/genai_streamlitapp/exports/charts/temp_chart.png'
The text was updated successfully, but these errors were encountered:
leungdunn
changed the title
FileNotFoundError: [Errno 2] No such file or directory: '~/exports/charts/temp_chart.png'
FileNotFoundError: [Errno 2] No such file or directory: 'path/to/project/exports/charts/temp_chart.png'
Apr 6, 2024
Does it work if you remove the save_charts_path? Did you check whether the folder actually exists and is created?
I did recreate @leungdunn 's code to try and fix the error on my side, and I can say that the issue persists with or without specifying save_charts_path.
The weird thing is that the directory or folder itself is created (exports/charts/), but the png file for the chart output itself is not created.
@leungdunn try to set open_charts to True, this will create the plot png file, which can then be accessed via the returned path.
Note that turning it to True also opens the file automatically.
Also try setting save_charts to True, this should create the plot and save it without opening it (Although this creates some unexpected behaviour, @gventuri check issue #1175)
System Info
OS version: macOS Sonoma 14.4.1
Python version: 3.10.12
pandasai version: 2.0.28
馃悰 Describe the bug
It cannot go through when using the Agent to plot pictures. It is okay if the question response is supposed to be text.
Below is my code:
full traceback is as below
The text was updated successfully, but these errors were encountered: