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 classesAgentsCallbacksModulesSecurityGuidesMoreModulesMemoryCustomizing Conversational MemoryOn this pageCustomizing Conversational MemoryThis notebook walks through a few ways to customize conversational memory.from langchain.llms import OpenAIfrom langchain.chains import ConversationChainfrom langchain.memory import ConversationBufferMemoryllm = OpenAI(temperature=0)AI prefix‚ÄãThe first way to do so is by changing the AI prefix in the conversation summary. By default, this is set to "AI", but you can set this to be anything you want. Note that if you change this, you should also change the prompt used in the chain to reflect this naming change. Let's walk through an example of that in the example below.# Here it is by default set to "AI"conversation = ConversationChain(    llm=llm, verbose=True, memory=ConversationBufferMemory())conversation.predict(input="Hi there!")            > Entering new ConversationChain chain...    Prompt after formatting:    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.        Current conversation:        Human: Hi there!    AI:        > Finished ConversationChain chain.    " Hi there! It's nice to meet you. How can I help you today?"conversation.predict(input="What's the weather?")            > Entering new ConversationChain chain...    Prompt after formatting:
This notebook walks through a few ways to customize conversational memory.
This notebook walks through a few ways to customize conversational memory. ->: 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 classesAgentsCallbacksModulesSecurityGuidesMoreModulesMemoryCustomizing Conversational MemoryOn this pageCustomizing Conversational MemoryThis notebook walks through a few ways to customize conversational memory.from langchain.llms import OpenAIfrom langchain.chains import ConversationChainfrom langchain.memory import ConversationBufferMemoryllm = OpenAI(temperature=0)AI prefix‚ÄãThe first way to do so is by changing the AI prefix in the conversation summary. By default, this is set to "AI", but you can set this to be anything you want. Note that if you change this, you should also change the prompt used in the chain to reflect this naming change. Let's walk through an example of that in the example below.# Here it is by default set to "AI"conversation = ConversationChain(    llm=llm, verbose=True, memory=ConversationBufferMemory())conversation.predict(input="Hi there!")            > Entering new ConversationChain chain...    Prompt after formatting:    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.        Current conversation:        Human: Hi there!    AI:        > Finished ConversationChain chain.    " Hi there! It's nice to meet you. How can I help you today?"conversation.predict(input="What's the weather?")            > Entering new ConversationChain chain...    Prompt after formatting: