Node Details

  • Name: customRetriever

  • Type: CustomRetriever

  • Category: Retrievers

  • Version: 1.0

  • Base Classes: CustomRetriever, BaseRetriever

Input Parameters

  1. Vector Store (required)

    • Type: VectorStore

    • Description: The vector store to retrieve documents from.

  2. Query (optional)

    • Type: string

    • Description: The query to retrieve documents. If not specified, the user’s question will be used.

    • Accepts variables: Yes

  3. Result Format (required)

    • Type: string

    • Description: Format template for the returned results. Use {{context}} to insert the document’s content and {{metadata.key}} to insert metadata values.

    • Default: “{{context}}\nSource: {{metadata.source}}

  4. Top K (optional)

    • Type: number

    • Description: Number of top results to fetch. Defaults to the vector store’s topK value or 4 if not specified.

    • Default: 4

Outputs

  1. Custom Retriever

    • Type: CustomRetriever

    • Description: The initialized custom retriever object.

  2. Document

    • Type: Array of Document objects

    • Description: An array of document objects containing metadata and formatted page content.

  3. Text

    • Type: string

    • Description: A concatenated string of the formatted page content from all retrieved documents.

Functionality

The Custom Retriever node enhances the standard vector store retrieval process by:

  1. Allowing customization of the number of results to retrieve (topK).

  2. Providing a flexible template system for formatting the retrieved results.

  3. Enabling access to both document content and metadata in the output format.

  4. Offering multiple output types (retriever object, document array, or concatenated text).

Usage

This node is particularly useful when you need to:

  • Customize the presentation of retrieved documents.

  • Include specific metadata fields in the output.

  • Control the number of results returned from the vector store.

  • Integrate retrieved information into a larger language model workflow with a consistent format.

Example

If you set the Result Format to: