1

I'm trying to create a create_pandas_dataframe_agent using costom tools but it's not working

I'm trying this code

class callStaf(BaseModel):

        def run(self, keyword):
            return {"status": "submitted", "staff name": "abcd-xxx-xx1234"}

tools = [
    Tool(
        name="CallStaff",
        func=callStaf.run,
        description="call staff when user need staff helpe",
    )
]


prompt = """
        You are a helpful assistant named qbe that can answer questions based on the given data(table, summery),Last messages, and rules.You are working with a pandas dataframe in Python. The name of the dataframe is `df`.
        You should use the tools below to answer the question posed of you:

        summery:{summery}

        Rules:
        1. Only use the factual information from the available data to answer the question.
        2. If you don't have enough information to answer the question, say "I don't know".
        3. Provide answers without mentioning the specific source of the information.
        4. Feel free to engage in basic chitchat.
        5. If you have any doubts about the question, you can ask for clarification.
        6. when youser need a staf help then callstaff

        Last few messages between you and user:
        {history}
        """
prefix = PromptTemplate(

            input_variables=["summery", "history"],
            template=prompt
        )
df = pd.read_csv(data_file)
summery = ""
history = self.memory.load_memory_variables({})["history"]
conversational_agent = create_pandas_dataframe_agent(
            ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
            df,
            prefix=self.prefix.format(summery=summery, history=history),
            verbose=True,
            handle_parsing_errors=True,
            agent_type=AgentType.OPENAI_FUNCTIONS,
            tool=tools)

when I change the argument tool to tools in create_pandas_dataframe_agent it shows an error

TypeError: langchain.agents.openai_functions_agent.base.OpenAIFunctionsAgent() got multiple values for keyword argument 'tools'

the pandas agent is not using the tool. it's giving the answer its own. but the tool is working perfectly in normal agents like

conversational_agent = initialize_agent(
    agent='chat-conversational-react-description',
    tools=tools,
    llm=turbo_llm,
    verbose=True,
    max_iterations=3,
    early_stopping_method='generate',
    memory=memory
)
shihar
  • 48
  • 7

0 Answers0