Sinaptik-AI / pandas-ai

Chat with your database (SQL, CSV, pandas, polars, mongodb, noSQL, etc). PandasAI makes data analysis conversational using LLMs (GPT 3.5 / 4, Anthropic, VertexAI) and RAG.
https://pandas-ai.com
Other
13.31k stars 1.29k forks source link

issue with running this code - from pandasai.llm.local_llm import LocalLLM #1345

Open anilmadishetty2498 opened 2 months ago

anilmadishetty2498 commented 2 months ago

System Info

Python 3.11.7

🐛 Describe the bug

----> 1 from pandasai.llm.local_llm import LocalLLM

File c:\Users\AKM098\AppData\Local\anaconda3\Lib\site-packages\pandasai\llm\local_llm.py:5 1 from future import annotations 3 from typing import TYPE_CHECKING ----> 5 from openai import OpenAI 7 from ..helpers.memory import Memory 8 from ..prompts.base import BasePrompt

ImportError: cannot import name 'OpenAI' from 'openai' (c:\Users\USERID\AppData\Local\anaconda3\Lib\site-packages\openai__init__.py)

dosubot[bot] commented 2 months ago

Hello, @anilmadishetty2498! 👋 I'm here to help you with any bugs, questions, or contribution guidance while you wait for a human maintainer.

To resolve the ImportError: cannot import name 'OpenAI' from 'openai' when running the code from pandasai.llm.local_llm import LocalLLM, you need to ensure that you are importing the OpenAI class from the correct module within the pandasai package. The correct import statement should be:

from pandasai.llm.openai import OpenAI

Make sure that your code reflects this import statement. If you are trying to use LocalLLM, ensure that it is correctly defined and imported from the appropriate module within the pandasai package. Here is an example of how LocalLLM is defined:

from pandasai.llm.local_llm import LocalLLM

Ensure that you have the openai package installed and properly configured in your environment. If the issue persists, double-check the version compatibility between the openai package and the pandasai package. The pandasai documentation specifies that the openai package version should be less than 2 [1].

Additionally, you might find it helpful to refer to similar issues:

To continue talking to Dosu, mention @dosu.

anilmadishetty2498 commented 2 months ago

thank you for your quick workaround, let me check

anilmadishetty2498 commented 2 months ago

thank you it worked