I want to add a ConversationBufferMemory
to pandas_dataframe_agent
but so far I was unsuccessful.
- I have tried adding the memory via construcor:
create_pandas_dataframe_agent(llm, df, verbose=True, memory=memory)
which didn't break the code but didn't resulted in the agent to remember my previous questions. - Also I have tried to add memory into the agent via this pieace of code:
pd_agent.agent.llm_chain.memory = memory
. Which resulted inValueError: One input key expected got ['input', 'agent_scratchpad']
This is my code so far (which doesn't work):
llm = ChatOpenAI(temperature=0, model_name="gpt-4-0613")
memory = ConversationBufferMemory()
pd_agent = create_pandas_dataframe_agent(llm, df, verbose=True, memory=memory)
#pd_agent.agent.llm_chain.memory = memory #Or if I use this approach the code breaks when calling the .run() methods
pd_agent.run("Look into the data in step 12. Are there any weird patterns? What can we say about this part of the dataset.")
pd_agent.run("What was my previouse question?") #Agent doesn't rember