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

  • BaseRetriever
    • 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<Record<string, any>>[]

      The documents to add to vector store in the retriever

    Returns Promise<void>

  • Get the memory stream of documents.

    Returns DocumentInterface<Record<string, any>>[]

    The memory stream of documents.

  • Set the memory stream of documents.

    Parameters

    • memoryStream: DocumentInterface<Record<string, any>>[]

      The new memory stream of documents.

    Returns void

Generated using TypeDoc