langchain.js
    Preparing search index...

    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

    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 (View Summary)

    Index

    Constructors

    Accessors

    • get lc_namespace(): string[]

      Returns string[]

    Methods

    • Get relevant documents based on time-weighted relevance

      Parameters

      • query: string

        The query to search for

      • OptionalrunManager: any

      Returns Promise<DocumentInterface[]>

      The relevant documents

    • 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>

    • Get the memory stream of documents.

      Returns DocumentInterface[]

      The memory stream of documents.

    • Set the memory stream of documents.

      Parameters

      • memoryStream: DocumentInterface[]

        The new memory stream of documents.

      Returns void

    • Returns string