Node Details

  • Name: customDocumentLoader
  • Type: Document
  • Version: 1.0
  • Category: Document Loaders

Input Parameters

  1. Input Variables (optional)

    • Type: JSON
    • Description: Input variables that can be used in the function with a ‘prefix(e.g.,' prefix (e.g., var)
    • Accepts variables and lists
  2. Javascript Function

    • Type: Code
    • Description: A JavaScript function that must return either:
      • An array of document objects (each containing pageContent and metadata) if “Document” output is selected
      • A string if “Text” output is selected

Output

Output

The node provides two possible output types:

  1. Document

    • Description: Array of document objects containing metadata and pageContent
    • Base Classes: Document, json
  2. Document

    • Description: Array of document objects containing metadata and pageContent
    • Base Classes: Document, json
  3. Text

    • Description: Concatenated string from pageContent of documents
    • Base Classes: string, json
  4. Text

    • Description: Concatenated string from pageContent of documents
    • Base Classes: string, json

Functionality

Functionality

The Custom Document Loader node allows users to write custom JavaScript code to load and process documents or text. It provides a sandboxed environment with access to various built-in and external dependencies, as well as input variables and flow information. Key features:

  • Supports both document object arrays and plain text output
  • Provides access to input variables, chat flow information, and custom variables
  • Runs the custom code in a secure sandbox environment
  • Allows for complex document loading and processing logic

Use Cases

  • Integrating custom data sources
  • Implementing complex document processing logic
  • Generating dynamic document content within a chatflow
  • Creating custom document loading workflows
  • Supports both document object arrays and plain text output
  • Provides access to input variables, chat flow information, and custom variables
  • Runs the custom code in a secure sandbox environment
  • Allows for complex document loading and processing logic

Use Cases

  • Integrating custom data sources
  • Implementing complex document processing logic
  • Generating dynamic document content within a chatflow
  • Creating custom document loading workflows

Usage

  1. Configure any necessary input variables
  2. Write a JavaScript function that loads and/or processes documents or text
  3. Choose the appropriate output type (Document or Text)
  4. Use the node in your chatflow to dynamically load or generate document content

Example JavaScript Function

return [
    {
        pageContent: 'Document Content',
        metadata: {
            title: 'Document Title',
            }
    }
    ]
    {
        pageContent: 'Document Content',
        metadata: {
            title: 'Document Title',
            }
    }
    ]

This node is particularly useful for integrating custom data sources, implementing complex document processing logic, or generating dynamic document content within a chatflow.