Dify Knowledge Base icon

Dify Knowledge Base

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

Segment → Add

AI-generated

Overview

The node manages segments within a knowledge base dataset in the Dify AI platform. Specifically, the "Add" operation for the "Segment" resource allows users to add one or more new segments to a specified document inside a dataset. Each segment can contain content, an optional answer (useful for Q&A formats), and keywords.

This node is beneficial when you want to enrich your knowledge base by programmatically adding segmented pieces of information to documents, enabling better organization, searchability, and retrieval of knowledge. For example, you might use it to upload multiple FAQ entries or text snippets with associated answers and keywords into a document for AI-powered querying.

Properties

Name Meaning
Dataset ID The unique identifier of the dataset where the document resides.
Document ID The unique identifier of the document to which the segments will be added.
Segments One or more segments to add. Each segment includes:
- Content: The main textual content of the segment.
- Answer: An optional answer related to the segment content, useful for Q&A style data.
- Keywords: Comma-separated keywords to tag or describe the segment for easier searching.

Output

The node outputs JSON data representing the result of adding the segments. This typically includes details about the newly created segments such as their IDs and stored content. The output structure corresponds to the API response from the Dify knowledge base service confirming successful addition.

No binary data output is indicated for this operation.

Dependencies

  • Requires an API key credential for authenticating with the Dify AI knowledge base service.
  • The node uses the base URL and authorization token configured in the credentials to make HTTP requests.
  • No other external dependencies are required.

Troubleshooting

  • Common issues:

    • Invalid or missing Dataset ID or Document ID will cause errors because the node cannot locate where to add segments.
    • Providing empty or improperly formatted segments (e.g., missing content) may lead to API rejection.
    • Network or authentication failures if the API key or base URL is incorrect or expired.
  • Error messages:

    • "The operation "add" is not supported for resource "segment": Indicates a misconfiguration or unsupported operation; ensure the correct resource and operation are selected.
    • API errors related to authorization usually mean the API key is invalid or missing.
    • Validation errors from the API often indicate missing required fields like Dataset ID, Document ID, or segment content.

To resolve these, verify all required inputs are correctly set, check API credentials, and ensure network connectivity.

Links and References

Discussion