我想添加一个
ConversationBufferMemory
到
pandas_dataframe_agent
但到目前为止,我没有成功。
-
我试着通过constructor添加记忆:
create_pandas_dataframe_agent(llm, df, verbose=True, memory=memory)
这并没有破坏代码,但也没有让代理记住我之前的问题。
-
此外,我还试图通过以下代码片段将内存添加到代理中:
pd_agent.agent.llm_chain.memory = memory
。这导致
ValueError: One input key expected got ['input', 'agent_scratchpad']
这是我迄今为止的代码(不起作用):
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