Dify Knowledge Base icon

Dify Knowledge Base

Manage Dify AI knowledge base datasets, documents, segments, and metadata with comprehensive CRUD operations

Document → Create From File

AI-generated

Overview

The node "Dify Knowledge Base" enables managing AI knowledge base datasets, documents, segments, and metadata through various CRUD (Create, Read, Update, Delete) operations. Specifically, the Document - Create From File operation allows users to create a new document in a specified dataset by uploading a file from binary input data.

This operation is useful when you want to add documents to your AI knowledge base by importing files directly, such as PDFs, text files, or other supported formats. It automates the ingestion of content into the knowledge base for indexing and later retrieval or analysis.

Practical examples:

  • Uploading a PDF report to a dataset for AI-powered search.
  • Importing multiple text files as separate documents into a knowledge base.
  • Adding scanned documents or images containing text to be processed and indexed.

Properties

Name Meaning
Dataset ID The unique identifier of the dataset where the document will be created.
Input Binary Field The name of the binary property that contains the file data to upload. Typically, this corresponds to the binary input field holding the file content (default is "data").
Additional Fields Optional extra settings for the document creation:
- Name Optional name for the document being created. If not provided, the system may assign a default name.
- Indexing Technique Choice between "High Quality" or "Economy" indexing techniques, affecting how the document content is processed and indexed.
- Process Rule Configuration for processing rules, including:
  Mode Processing mode can be "Automatic" or "Custom".
  Pre-Processing Rules When in "Custom" mode, a list of pre-processing rules can be enabled or disabled by their IDs.
  Segmentation In "Custom" mode, segmentation options allow specifying a text separator string and maximum tokens per segment to control how the document is split for indexing.

Output

The node outputs JSON data representing the created document's details as returned by the Dify API. This typically includes identifiers, status, metadata, and any relevant information about the newly created document.

If the node supports binary output (not explicitly shown here), it would represent the uploaded file or processed content, but for this operation, the main output is JSON describing the document.

Dependencies

  • Requires an API key credential for authenticating with the Dify AI service.
  • Needs the base URL of the Dify API configured in credentials.
  • The node depends on the n8n workflow environment to provide binary data input under the specified binary property name.

Troubleshooting

  • Common issues:

    • Missing or incorrect Dataset ID will cause failures in document creation.
    • Incorrect binary field name leads to no file data found error.
    • Invalid or expired API key results in authentication errors.
    • Unsupported file types or corrupted files may cause processing errors.
  • Error messages:

    • "The operation "createFromFile" is not supported for resource "document": Indicates a misconfiguration or unsupported operation call.
    • Authentication errors usually mention invalid token or unauthorized access.
    • File-related errors might indicate missing binary data or invalid format.
  • Resolutions:

    • Verify Dataset ID correctness.
    • Ensure the binary field name matches the incoming binary data property.
    • Confirm API credentials are valid and have necessary permissions.
    • Validate file integrity and supported formats before upload.

Links and References

Discussion