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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PandasAI not compatible with HuggingFaceTextGen object (any LLM other than BambooLLM) #1577

Closed
SimranAnand1 opened this issue Feb 3, 2025 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@SimranAnand1
Copy link

SimranAnand1 commented Feb 3, 2025

System Info

Though HuggingFaceTexrGen object for any HuggingFace LLM shows pandasai.huggingfacetextgen object as its type and it is an instance of LLM class, yet on executing pandasai code of chat function (pai.chat method), I get JSONDecode error due to resp.json() line. The response is a string from the chat method but resp.json() is trying to convert to a json object ehich thrrows JSON Decode Error.

Kindly check the chat(), call method in huggingface_text_gen.py code inside extensions (huggingface).

Looking forward to a solution so that HuggingFace models are compatible to work with chat function of pandasai.

🐛 Describe the bug

'''
import pandasai as pai
from pandasai_huggingface import HuggingFaceTextGen

employees_data = {
'EmployeeID': [1, 2, 3, 4, 5],
'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'],
'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance']
}

salaries_data = {
'EmployeeID': [1, 2, 3, 4, 5],
'Salary': [5000, 6000, 4500, 7000, 5500]
}

employees_df = pai.DataFrame(employees_data)
salaries_df = pai.DataFrame(salaries_data)

llm= HuggingFaceTextGen(inference_url="http://127.0.0.1:8080")
pai.config.set({"llm":llm})

pai.chat("Who gets paid the most?", employees_df, salaries_df)

@SimranAnand1
Copy link
Author

Also, the file has been removed: https://github.com/Sinaptik-AI/pandas-ai/blob/main/pandasai/llm/huggingface_text_gen.py

The new file for huggingface models:
https://github.com/sinaptik-ai/pandas-ai/blob/main/extensions/llms/huggingface/pandasai_huggingface/huggingface_text_gen.py

The call function returns res.generated_text which is throwing a JSON Decode Error. Kindly check this.

@gdcsinaptik gdcsinaptik added the duplicate This issue or pull request already exists label Feb 3, 2025
@gdcsinaptik
Copy link
Collaborator

Hey @SimranAnand1 let's consider this ticket as a duplicate of #1577, as the JSON Decode Error does not happen for all LLMs. And the OpenAI and Google LLMs data extensions work in the 3.x. Thanks for sharing further info. If you have to use hugging face models, for now please revert to the 2.4. We will notify you as soon as we fix the hugging face models in the 3.x, which is currently in Beta release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants