Closed Emad-Eldin-G closed 1 month ago
Imported the wrong OpenAI, fixed ✅
May I know how you solve the issue? Which OpenAI is correct?
Import the OpenAI instance from the pandas LLM library:
import os
import pandas as pd
from pandasai import Agent, SmartDataframe
from pandasai.llm import OpenAI
Then pass it in to your Smart DataFrame as a config param:
os.environ["PANDASAI_API_KEY"] = os.environ.get("PANDASAI_API_KEY")
llm = OpenAI(api_token=os.environ.get("OPENAI_API_KEY"))
df = pd.DataFrame(self.__dataset)
pAI = SmartDataframe(df, config={"verbose": True, "llm": llm})
And Chat !
llm_analysis_response = pAI.chat("Your query here")
There are probably other ways to go around it, but this is how I've done it.
System Info
MACOS Sonoma 14.4.1 Python Version 3.11.7 Pandasai Version 2.0.37
🐛 Describe the bug
Imports
Code
This is a minimal version of the code, where a simple pandas csv read df is passed:
Error Message
Log file