Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'Agent' from 'pandasai' #1250

Open
NehaKoppikar opened this issue Jun 25, 2024 · 1 comment
Open

ImportError: cannot import name 'Agent' from 'pandasai' #1250

NehaKoppikar opened this issue Jun 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@NehaKoppikar
Copy link

System Info

OS Version: 14.4.1
Python Version: 3.9.7
PandasAI version: 0.2.2

馃悰 Describe the bug

Unable to import Agent

Code used:
import os
import pandas as pd
from pandasai import Agent

Sample DataFrame

sales_by_country = 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]
})

By default, unless you choose a different LLM, it will use BambooLLM.

##You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os.environ["PANDASAI_API_KEY"] = ""

agent = Agent(sales_by_country)
response = agent.chat('write insight about data')
print(response)

@dosubot dosubot bot added the bug Something isn't working label Jun 25, 2024
Copy link

dosubot bot commented Jun 25, 2024

Hello @NehaKoppikar! I'm here to help you with any issues, questions, or contributions you have. Whether it's a bug or a query, feel free to ask me anything.

To resolve the ImportError when trying to import the Agent class from the pandasai library, ensure that you are importing it correctly from the pandasai.agent module. The correct import statement should be:

from pandasai.agent import Agent

This import statement should work as long as the pandasai library is properly installed and the pandasai/agent/agent.py file contains the Agent class definition. If you are still encountering issues, make sure that the pandasai library is installed in your environment. You can install it using pip if it is not already installed:

pip install pandasai

Additionally, you can refer to the unit tests provided in the tests/unit_tests/agent/test_agent.py file to ensure that your setup is correct. The tests include various scenarios for initializing and using the Agent class, which can help you verify that the class is being imported and used correctly in your environment [1][2][3].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant