text: Mongodb Chat Message History | ğŸ¦œï¸�ğŸ”— Langchain
  
  
  
  
  
  Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryCassandra Chat Message HistoryDynamodb Chat Message HistoryEntity Memory with SQLite storageMomento Chat Message HistoryMongodb Chat Message HistoryMotÃ¶rhead MemoryMotÃ¶rhead Memory (Managed)Postgres Chat Message HistoryRedis Chat Message HistoryZep MemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerIntegrationsMemoryMongodb Chat Message HistoryMongodb Chat Message HistoryThis notebook goes over how to use Mongodb to store chat message history.MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). - Wikipedia# Provide the connection string to connect to the MongoDB databaseconnection_string = "mongodb://mongo_user:password123@mongo:27017"from langchain.memory import MongoDBChatMessageHistorymessage_history = MongoDBChatMessageHistory(    connection_string=connection_string, session_id="test-session")message_history.add_user_message("hi!")message_history.add_ai_message("whats up?")message_history.messages    [HumanMessage(content='hi!', additional_kwargs={}, example=False),     AIMessage(content='whats up?', additional_kwargs={}, example=False)]PreviousMomento Chat Message HistoryNextMotÃ¶rhead MemoryCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.