Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryChat MessagesMemory typesMemory in LLMChainMemory in the Multi-Input ChainMemory in AgentMessage Memory in Agent backed by a databaseCustomizing Conversational MemoryCustom MemoryMultiple Memory classesAgentsCallbacksModulesSecurityGuidesMoreModulesMemoryMultiple Memory classesMultiple Memory classesWe can use multiple memory classes in the same chain. To combine multiple memory classes, we initialize and use the CombinedMemory class.from langchain.llms import OpenAIfrom langchain.prompts import PromptTemplatefrom langchain.chains import ConversationChainfrom langchain.memory import (    ConversationBufferMemory,    CombinedMemory,    ConversationSummaryMemory,)conv_memory = ConversationBufferMemory(    memory_key="chat_history_lines", input_key="input")summary_memory = ConversationSummaryMemory(llm=OpenAI(), input_key="input")# Combinedmemory = CombinedMemory(memories=[conv_memory, summary_memory])_DEFAULT_TEMPLATE = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Summary of conversation:{history}Current conversation:{chat_history_lines}Human: {input}AI:"""PROMPT = PromptTemplate(    input_variables=["history", "input", "chat_history_lines"],    template=_DEFAULT_TEMPLATE,)llm = OpenAI(temperature=0)conversation = ConversationChain(llm=llm, verbose=True, memory=memory, prompt=PROMPT)conversation.run("Hi!")            > Entering new ConversationChain chain...    Prompt after formatting:    The following is a friendly conversation between a human and an AI. The AI is talkative and
We can use multiple memory classes in the same chain. To combine multiple memory classes, we initialize and use the CombinedMemory class.
We can use multiple memory classes in the same chain. To combine multiple memory classes, we initialize and use the CombinedMemory class. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryChat MessagesMemory typesMemory in LLMChainMemory in the Multi-Input ChainMemory in AgentMessage Memory in Agent backed by a databaseCustomizing Conversational MemoryCustom MemoryMultiple Memory classesAgentsCallbacksModulesSecurityGuidesMoreModulesMemoryMultiple Memory classesMultiple Memory classesWe can use multiple memory classes in the same chain. To combine multiple memory classes, we initialize and use the CombinedMemory class.from langchain.llms import OpenAIfrom langchain.prompts import PromptTemplatefrom langchain.chains import ConversationChainfrom langchain.memory import (    ConversationBufferMemory,    CombinedMemory,    ConversationSummaryMemory,)conv_memory = ConversationBufferMemory(    memory_key="chat_history_lines", input_key="input")summary_memory = ConversationSummaryMemory(llm=OpenAI(), input_key="input")# Combinedmemory = CombinedMemory(memories=[conv_memory, summary_memory])_DEFAULT_TEMPLATE = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Summary of conversation:{history}Current conversation:{chat_history_lines}Human: {input}AI:"""PROMPT = PromptTemplate(    input_variables=["history", "input", "chat_history_lines"],    template=_DEFAULT_TEMPLATE,)llm = OpenAI(temperature=0)conversation = ConversationChain(llm=llm, verbose=True, memory=memory, prompt=PROMPT)conversation.run("Hi!")            > Entering new ConversationChain chain...    Prompt after formatting:    The following is a friendly conversation between a human and an AI. The AI is talkative and