Skip to content

How to add question rewriter function to pandas_dataframe_agent? #26131

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

You must be logged in to vote

To incorporate the create_question_rewriter function with the pandas_dataframe_agent and build a query generator, you can follow these steps:

  1. Incorporate create_question_rewriter Function:

    Modify the agent's invocation to include the rewritten question as input. Here is a sample code:

    from langchain_community.chat_models import ChatOpenAI
    from langchain_experimental.agents import create_pandas_dataframe_agent
    import pandas as pd
    
    # Load your DataFrame
    df = pd.read_csv("your_data.csv")
    
    # Initialize your language model
    llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
    
    # Define the create_question_rewriter function
    def create_question_rewriter(model):
        """
        Creates a question…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@mraguth
Comment options

@dosubot
Comment options

Answer selected by mraguth
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@dosubot
Comment options

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