Open Rumeysakeskin opened 1 month ago
To resolve the TypeError: PandasAIReader.__init__() got an unexpected keyword argument 'llm'
error, you need to ensure that you are using the correct class and its initialization parameters. The LangchainLLM
class is likely the one you should be using for Hugging Face models.
Here is an example of how you might initialize and use the LangchainLLM
class correctly:
from langchain_core.language_models import BaseLanguageModel
from pandasai.llm.langchain import LangchainLLM
# Initialize the BaseLanguageModel with the appropriate parameters
# Replace 'YourHuggingFaceModel' with the actual Hugging Face model you are using
huggingface_llm = BaseLanguageModel(model_name="YourHuggingFaceModel")
# Wrap the Hugging Face model with LangchainLLM
langchain_llm = LangchainLLM(langchain_llm=huggingface_llm)
# Use the initialized LLM with PandasAI
# Assuming you have a PandasAI instance and a DataFrame to work with
pandas_ai = PandasAI(llm=langchain_llm)
result = pandas_ai.run(your_dataframe, "your query")
print(result)
Make sure to replace "YourHuggingFaceModel"
, your_dataframe
, and "your query"
with the actual Hugging Face model name, your DataFrame, and your query respectively. This should resolve the TypeError
by ensuring that the correct class and parameters are used [1][2][3].
To continue talking to Dosu, mention @dosu.
System Info
🐛 Describe the bug
I get below error:
----> 5 loader = PandasAIReader(llm=llm)
TypeError: PandasAIReader.init() got an unexpected keyword argument 'llm'
I noticed that
PandasAIReader
is generally used with OpenAI's LLM. Am I getting errors because I use it with HuggingFace? How can I resolve this issue?