How to use TimeWeightedVectorStoreRetriever as VectorStoreRetrieverMemory's retriever? #27980
Replies: 1 comment 1 reply
-
Hey there, @Percival-Chan! I'm here to help you out with any bugs, questions, or contributions you have. Let's tackle this together! The To resolve this, you might need to implement a custom method or wrapper that provides the expected interface for If you want to stick with |
Beta Was this translation helpful? Give feedback.
-
Hi, I want to use a TimeWeightedVectorStoreRetriever for my chatbot's memory, but I faced AttributeError: 'TimeWeightedVectorStoreRetriever' object has no attribute 'get'. What would be the correct approach? My code is as follow:
from langchain.chains.llm_math.base import LLMMathChain
from langchain_community.utilities.serpapi import SerpAPIWrapper
from langchain.chains.conversation.base import ConversationChain
from langchain.memory import VectorStoreRetrieverMemory
decay_rate = 0.01
number_of_documents = 10
from langchain.retrievers import TimeWeightedVectorStoreRetriever
retriever = TimeWeightedVectorStoreRetriever(
vectorstore=vectorstore, decay_rate=decay_rate, k=number_of_documents
)
vector_memory = VectorStoreRetrieverMemory(retriever=retriever)
data = retrieve_data(user_name)
database_history = load_conversation_history_from_database(data)
memory_with_history = save_conversation_to_memory(database_history, vector_memory)
vectorstore_chain = ConversationChain(
llm=azure_llm_low_temp_model,
prompt=VECTORSTORE_PROMPT,
memory=memory_with_history,
verbose=True
)
vectorstore_chain.invoke
Beta Was this translation helpful? Give feedback.
All reactions