Skip to content

PandasAI with Gemini API #1412

Answered by dosubot bot
pgvetrivel asked this question in Q&A
Discussion options

You must be logged in to vote

To resolve the "ValidationError: 1 validation error for Config llm instance of LLM expected" error, you need to ensure that the llm attribute in your Config object is an instance of a class that inherits from LLM or LangchainLLM. Since you are using the Gemini API, you should wrap it in a custom class that implements the required methods for the LLM interface.

Here's an example of how you might define a custom LLM class for the Gemini API:

from pandasai.llm import LLM

class GeminiLLM(LLM):
    def __init__(self, api_key):
        self.api_key = api_key
        # Initialize any other necessary attributes

    def call(self, instruction, context=None):
        # Implement the logic to cal…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pgvetrivel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant