TimeWeightedVectorStoreRetriever retrieves documents based on their time-weighted relevance. ref: https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/time_weighted_retriever.py

Example

const retriever = new TimeWeightedVectorStoreRetriever({
vectorStore: new MemoryVectorStore(new OpenAIEmbeddings()),
memoryStream: [],
searchKwargs: 2,
});
await retriever.addDocuments([
{ pageContent: "My name is John.", metadata: {} },
{ pageContent: "My favourite food is pizza.", metadata: {} },

]);
const results = await retriever.getRelevantDocuments(
"What is my favourite food?",
);

Hierarchy

  • Toolkit
    • TimeWeightedVectorStoreRetriever

Constructors

Methods

  • NOTE: When adding documents to a vector store, use addDocuments via retriever instead of directly to the vector store. This is because it is necessary to process the document in prepareDocuments.

    Parameters

    • docs: DocumentInterface[]

      The documents to add to vector store in the retriever

    Returns Promise<void>

Generated using TypeDoc