mljar/plotai

model_version="gpt-4"

Closed this issue · 6 comments

Hi,

I am trying to set model version to gpt-4 as you suggested in the README file but I am getting the following error:


TypeError Traceback (most recent call last)
Cell In[4], line 6
3 df = pd.DataFrame({"x":[1,2,3], "y": [4,5,6]})
4 ## create a plot
----> 6 plot = PlotAI(df,model_version="gpt-4")
8 plot.make("scatter plot")

TypeError: PlotAI.init() got multiple values for argument 'model_version'

Initially when i tried with the default version , i got the following error:

...
178 """
--> 179 raise TypeError(f'Object of type {o.class.name} '
180 f'is not JSON serializable')

TypeError: Object of type DataFrame is not JSON serializable

Any suggestions how to fix the above errors? Thanks

Hi @rajayyala,

Are you using version 0.0.3?

that is correct...version 0.0.3..but i was able to solve the issue by passing it as keyword parameter..then i got past the error

like so:

plot = PlotAI(df=df,model_version="gpt-4")

that worked...

however i am running into another issue...

frequently the generated python code throws error saying that df is not defined.

this is the code i am trying:

df = pd.DataFrame({"x":[1,2,3], "y": [4,5,6]})
plot = PlotAI(df=df,model_version="gpt-4")
plot.make("scatter plot")

this is the prompt it generated:

**Create a plot in Python with matplotlib package.

Input data:

# pandas DataFrame
'''
   x  y
0  1  4
1  2  5
2  3  6
'''
# DataFrame columns
'''
['x', 'y']
'''

# pandas data frame variable is df

Plot should contain: scatter plot

Initial python code to be updated

# TODO import required dependencies
# TODO Provide the plot

Output only Python code.**

and this is the response:

# import required dependencies
import matplotlib.pyplot as plt

# Provide the plot
plt.scatter(df['x'], df['y'])
plt.xlabel('x')
plt.ylabel('y')
plt.title('Scatter plot of x and y')
plt.show()

as u can see its missing the dataframe variable "df"

Error output:
name 'df' is not defined

attaching some screenshots of the same:

image

image

any suggestions? thanks

Try to move data frame creation into separate cell.

did that...got the same error...

it works some times and doesnt work some times though...so not sure if having it in the same cell is the issue....

also when we do in a python script instead of a notebook then the concept of cell does not arise...right? any thoughts?

There was bug in the code. I fixed it and released new version 0.0.4, please let me know if it works for you.