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
12.73k stars 1.23k forks source link

Unable to run locally to contribute #1125

Closed jackwalkin closed 1 month ago

jackwalkin commented 5 months ago

System Info

master branch (2.0.34) Using Python 3.11 Package installation (I have tried both approaches):

🐛 Describe the bug

I can get pandasai working via pip install pandasai using the PANDASAI_API_KEY however when I use the same API key but use the poetry local installation: poetry install --all-extras --with dev

I get the following error when I run sdf.chat("message"):

  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/pipelines/chat/generate_chat_pipeline.py", line 307, in run
    output = (self.code_generation_pipeline | self.code_execution_pipeline).run(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/pipelines/pipeline.py", line 137, in run
    raise e
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/pipelines/pipeline.py", line 101, in run
    step_output = logic.execute(
                  ^^^^^^^^^^^^^^
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/pipelines/chat/code_generator.py", line 33, in execute
    code = pipeline_context.config.llm.generate_code(input, pipeline_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/llm/base.py", line 200, in generate_code
    response = self.call(instruction, context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/llm/bamboo_llm.py", line 18, in call
    response = self._session.post("/llm/chat", json=data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/helpers/request.py", line 37, in post
    return self.make_request("POST", path, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalkinshaw/GenAI/Testing_others/Random testing/pandas/pandas-ai/pandasai/helpers/request.py", line 71, in make_request
    raise PandasAIApiCallError(data["message"])
pandasai.exceptions.PandasAIApiCallError: Unable to generate LLM response.```

**For reference the error code does not occur during installation it is at the end of this code**

```python 
import pandas as pd
from pandasai import SmartDataframe
import os

os.environ['PANDASAI_API_KEY'] ="XXXX"

df = pd.DataFrame({
    "country": [
        "United States",
        "United Kingdom",
        "France",
        "Germany",
        "Italy",
        "Spain",
        "Canada",
        "Australia",
        "Japan",
        "China",
    ],
    "gdp": [
        19294482071552,
        2891615567872,
        2411255037952,
        3435817336832,
        1745433788416,
        1181205135360,
        1607402389504,
        1490967855104,
        4380756541440,
        14631844184064,
    ],
    "happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12],
})

sdf = SmartDataframe(df,config={"verbose": True})
sdf.chat("Return the top 5 countries by GDP")

Has anyone come across this issue? Am I doing something incorrectly?

pkdhirasaria commented 5 months ago

I'm facing the same error, it was working before for me with pip install pandasai, but it's not working now.

NEHA0901-US commented 5 months ago

I am facing this same issue.

wllbll commented 5 months ago

counter the same issue with pandas installed with pip, pandasai version 2.0.36 , python version 3.10.13

silasoli commented 5 months ago

I tried here, it didn't work, but thank you very much, I'm trying to create a "chat" for the user to talk to their csv, but these version issues in Python make everything so difficult

ssling0817 commented 4 months ago

Does anyone find the solution? I am facing the same issue. The same code worked yesterday but fails today. The version I used is pandasai 2.0.40, python version 3.10.12.

gventuri commented 4 months ago

@ssling0817 can you try to pull the latest update and try again? Let me know

ssling0817 commented 4 months ago

I think it works in 2.0.42. Thank you!

silasoli commented 4 months ago

I think it works in 2.0.42. Thank you!

Thanks for this, I'll test it