Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsAgent TypesHow-toAdd Memory to OpenAI Functions AgentRunning Agent as an IteratorReturning Structured OutputCombine agents and vector storesAsync APICreate ChatGPT cloneCustom functions with OpenAI Functions AgentCustom agentCustom agent with tool retrievalCustom LLM agentCustom LLM Agent (with a ChatModel)Custom MRKL agentCustom multi-action agentHandle parsing errorsAccess intermediate stepsCap the max number of iterationsTimeouts for agentsReplicating MRKLShared memory across agents and toolsStreaming final agent outputUse ToolKits with OpenAI FunctionsToolsToolkitsCallbacksModulesSecurityGuidesMoreModulesAgentsHow-toShared memory across agents and toolsShared memory across agents and toolsThis notebook goes over adding memory to both an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them:Adding memory to an LLM ChainCustom AgentsWe are going to create a custom Agent. The agent has access to a conversation memory, search tool, and a summarization tool. The summarization tool also needs access to the conversation memory.from langchain.agents import ZeroShotAgent, Tool, AgentExecutorfrom langchain.memory import ConversationBufferMemory, ReadOnlySharedMemoryfrom langchain.llms import OpenAIfrom langchain.chains import LLMChainfrom langchain.prompts import PromptTemplatefrom langchain.utilities import GoogleSearchAPIWrappertemplate = """This is a conversation between a human and a bot:{chat_history}Write a summary of the conversation for {input}:"""prompt = PromptTemplate(input_variables=["input", "chat_history"], template=template)memory =
This notebook goes over adding memory to both an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them:
This notebook goes over adding memory to both an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them: ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsAgent TypesHow-toAdd Memory to OpenAI Functions AgentRunning Agent as an IteratorReturning Structured OutputCombine agents and vector storesAsync APICreate ChatGPT cloneCustom functions with OpenAI Functions AgentCustom agentCustom agent with tool retrievalCustom LLM agentCustom LLM Agent (with a ChatModel)Custom MRKL agentCustom multi-action agentHandle parsing errorsAccess intermediate stepsCap the max number of iterationsTimeouts for agentsReplicating MRKLShared memory across agents and toolsStreaming final agent outputUse ToolKits with OpenAI FunctionsToolsToolkitsCallbacksModulesSecurityGuidesMoreModulesAgentsHow-toShared memory across agents and toolsShared memory across agents and toolsThis notebook goes over adding memory to both an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them:Adding memory to an LLM ChainCustom AgentsWe are going to create a custom Agent. The agent has access to a conversation memory, search tool, and a summarization tool. The summarization tool also needs access to the conversation memory.from langchain.agents import ZeroShotAgent, Tool, AgentExecutorfrom langchain.memory import ConversationBufferMemory, ReadOnlySharedMemoryfrom langchain.llms import OpenAIfrom langchain.chains import LLMChainfrom langchain.prompts import PromptTemplatefrom langchain.utilities import GoogleSearchAPIWrappertemplate = """This is a conversation between a human and a bot:{chat_history}Write a summary of the conversation for {input}:"""prompt = PromptTemplate(input_variables=["input", "chat_history"], template=template)memory =