Custom Langchain agent/tools with memory video code file: (Patreon)
Downloads
Content
UPDATE: This code would redefine the agent memory each time with streamlit erasing the memory. I have uploaded a file with the fixed code so that when using this with streamlit, agent's memory doesn't reset. I am leaving the old code file as reference
CODE THAT NEEDS TO CHANGE:
if "agent_memory" not in st.session_state:
st.session_state["agent_memory"] =
ConversationBufferMemory(memory_key="chat_history")
llm=OpenAI(temperature=0, verbose=True)
agent_chain = initialize_agent(tools, llm, agent="conversational-react-description", memory=st.session_state["agent_memory"], verbose=True)
this is for video: https://youtu.be/NIG8lXk0ULg
Turn any python function into a custom langchain agent with tools including short term conversational memory