langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.08k stars 14.96k forks source link

RunnableWithMessageHistory and ConversationSummaryBufferMemory #21069

Closed pechaut78 closed 5 months ago

pechaut78 commented 5 months ago

Checked other resources

Example Code

Using a ConversationSummaryBufferMemory generates an error:

                chat_history_for_chain = ConversationSummaryBufferMemory(llm=self.model,
                    memory_key="history",
                    input_key="input",max_token_limit=200,
                   return_messages=False) 

             self.chain_with_message_history = RunnableWithMessageHistory(
            self.chain_with_chat_history,
            lambda session_id: chat_history_for_chain,
            input_messages_key="input",
            history_messages_key="history",
        )

The code works fine if replaced with another type of memory

Error Message and Stack Trace (if applicable)

AttributeError: 'ConversationSummaryBufferMemory' object has no attribute 'aget_messages'. Did you mean: 'return_messages'?

Description

Using a ConversationSummaryBufferMemory generates an error:

The code works fine if replaced with another type of memory

System Info

System Information

OS: Darwin OS Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:08 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8122 Python Version: 3.10.14 (main, Mar 21 2024, 11:21:31) [Clang 14.0.6 ]

Package Information

langchain_core: 0.1.45 langchain: 0.1.16 langchain_community: 0.0.34 langsmith: 0.1.48 langchain_chroma: 0.1.0 langchain_experimental: 0.0.57 langchain_groq: 0.1.2 langchain_openai: 0.1.3 langchain_text_splitters: 0.0.1 langchainhub: 0.1.15 langserve: 0.1.0

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

Freezaa9 commented 4 months ago

Hi, how did you solve the issue ? I face the same