Replies: 3 comments 3 replies
-
Hey @carbbin! Great to see you diving into another LangChain adventure. I remember working through our last challenge together. How's everything going? Based on the error message you're seeing, it seems that the To resolve this issue, you need to ensure that the variables managed by
Here's an example of how you might modify your code to resolve the overlap: from langchain.memory import CombinedMemory, ConversationEntityMemory, ConversationBufferWindowMemory
# Instantiate ConversationEntityMemory and ConversationBufferWindowMemory with unique variable names
entity_memory = ConversationEntityMemory(llm=llm, input_key="input_entity")
buffer_window_memory = ConversationBufferWindowMemory(llm=llm, input_key="input_window")
# Combine the memories
combined_memory = CombinedMemory(memories=[entity_memory, buffer_window_memory]) In this example, I've renamed the I hope this helps! If you have any further questions or run into any issues, please don't hesitate to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Hi @carbbin , I think its because you're not defining different variable names for your template. conv_window = ConversationBufferMemory(
memory_key="chat_history_lines", input_key="input"
)
conv_entity = ConversationEntityMemory(llm=llm, input_key="input")
# Combined
memory = CombinedMemory(memories=[conv_entity, conv_window])
_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,
)
conversation = ConversationChain(llm=llm, verbose=True, memory=memory, prompt=PROMPT)
conversation.predict(input = 'Please, tell me about large language models') Tell me what you think about this. |
Beta Was this translation helpful? Give feedback.
-
Can anyone help to understand what mistake i am making here? TIA |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
Hi!
I want to use CombinedMemory with ConversationEntityMemory and ConversationBufferWindowMemory.
I have started using the example of the link bellow:
https://python.langchain.com/docs/modules/memory/multiple_memory
I am using the model Gemini-Pro for this and I have tried a lot of ways, even combining with ConversationBufferMemory and ConversationSummaryMemory, but i do not get through this.
Does anyone tried to combine this two type of memories? The ones in the example of the link works ok.
System Info
The same variables {'history'} are found in multiplememory object, which is not allowed by CombinedMemory. (type=value_error)
Beta Was this translation helpful? Give feedback.
All reactions