Hello all,
I am trying to instantiate a SmartDatalake using the PandasAI API and OpenAI.
My code looks like this:
import pandas as pd
from pandasai import Agent, SmartDataframe
import os
#from pandasai.llm import OpenAI
from pandasai.llm.openai import OpenAI
from pandasai.smart_datalake import SmartDatalake
# Step 1: Create sample CSV files
# Data for employees
employees_data = {
"employee_id": [1, 2, 3, 4, 5],
"name": ["Alice", "Bob", "Charlie", "David", "Eve"],
"age": [25, 30, 35, 40, 45],
"salary": [50000, 60000, 65000, 70000, 75000],
"department_id": [101, 102, 101, 103, 102]
}
df_employees = pd.DataFrame(employees_data)
df_employees.to_csv("../data/employees.csv", index=False)
# Data for departments
departments_data = {
"department_id": [101, 102, 103],
"department_name": ["HR", "Engineering", "Marketing"]
}
df_departments = pd.DataFrame(departments_data)
df_departments.to_csv("../data/departments.csv", index=False)
# Step 2: Initialize the OpenAI LLM and SmartDataLake
llm = OpenAI(model = 'GPT-4o',OPENAI_API_KEY = "XXXX")
# Step 3: Load data from the SmartDataLake
smart_df_employees = SmartDataframe(pd.read_csv("../data/employees.csv"))
smart_df_departments = SmartDataframe(pd.read_csv("../data/departments.csv"))
# Step 4: Perform natural language queries
data_lake = SmartDatalake([smart_df_employees,smart_df_departments],config={"llm": llm})
response_salary = data_lake.chat (' What is the average employee salary')
print("Average salary:", response_salary)
The error I get is: UnsupportedModelError: Unsupported model: The model ‘GPT-4o’ doesn’t exist or is not supported yet.
I’ve set up the api key with no restrictions, so it should support all of the OpenAI current models.
Can anyone point me in the right direction to solve this?
Thanks