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
11.7k stars 1.08k forks source link

feat: add support for IBM watsonx.ai models #1121

Closed rahulkalluri closed 2 months ago

rahulkalluri commented 2 months ago

Adding using the ibm-watsonx-ai package as another LLM method. At this time, the watsonx.ai package does not support multi-turn conversations (I've included that in the updated docs).

gventuri commented 2 months ago

Thanks a lot @rahulkalluri. Tests are failing, can you check it out?

rahulkalluri commented 2 months ago

Thanks a lot @rahulkalluri. Tests are failing, can you check it out?

After some quick investigation it looks like the ibm-watsonx-ai package requires python 3.10 and up. Would it be okay with updating the pandasai requirements to minimum of python 3.10?

gventuri commented 2 months ago

@rahulkalluri I think this is something we need to discuss with the community. But since it's an optional dependency, you can make it only available for some python versions:

For example:

sqlalchemy-bigquery = {version = "^1.8.0", optional = true, markers = "python_version >= '3.8' and python_version < '3.13'"}

Hope it helps

rahulkalluri commented 2 months ago

Isn't the langchain integration enough?

I saw other users were having issues using the langchain integration, plus I thought having a more native integration would be easier to use.

mspronesti commented 2 months ago

When I tried using it for IBM Watson (a couple of months ago) I didn't run into any issues. Did you face any?

rahulkalluri commented 2 months ago

When I tried using it for IBM Watson (a couple of months ago) I didn't run into any issues. Did you face any?

To be honest I tried and couldn't figure out how to leverage langchain with pandas and watsonx.

On top of that, the package the documentation refers to is now deprecated and is superseded by ibm-watsonx-ai which I've included here.

Since I wasn't able to figure it out and I saw the open issue, I thought it would be best to have a more native integration with watsonx, similar to other vendors like Amazon/Google.

gventuri commented 2 months ago

@rahulkalluri almost there, could you fix the linting errors? Also, what issue where you facing with LangChain?

rahulkalluri commented 2 months ago

@rahulkalluri almost there, could you fix the linting errors? Also, what issue where you facing with LangChain?

Sorry about that! Ran through the tests, we should be good to go now.

On the LangChain stuff, I think it's more user error than anything. Nothing was broken, and I'll post in the Discord for some help if need be.

rahulkalluri commented 2 months ago

Hey @gventuri I see the test failed on Python 3.9 which makes sense since the ibm-watsonx-ai package only works on 3.10 and above. Are you able to trigger the CI builds for 3.10+ only?

gventuri commented 2 months ago

@rahulkalluri can we temporarily use a skipif for the old version?

i.e.

@pytest.mark.skipif(sys.version_info[:2] != (3, 8), reason="requires Python 3.8")

What do you think? We don't want to drop the support for python 3.8 yet!

rahulkalluri commented 2 months ago

@rahulkalluri can we temporarily use a skipif for the old version?

i.e.

@pytest.mark.skipif(sys.version_info[:2] != (3, 8), reason="requires Python 3.8")

What do you think? We don't want to drop the support for python 3.8 yet!

Absolutely, PandasAI should continue to support Python 3.9. I was not aware of the pytest skip but I've implemented that alongside some other minor changes to ensure users won't have issues if they're using Python 3.9. I tested the code on my machine in both Python 3.9 and 3.10 environments as well.

Thanks for the suggestion!

gventuri commented 2 months ago

@rahulkalluri thanks a lot for the effort, merging!