A plugin for managing Dify knowledge base - creating knowledge bases, uploading text content, and retrieving information.
Before using this plugin, you need:
- A Dify platform account
- Knowledge base API Key
- Log in to Dify.ai
- Navigate to the knowledge base page
- Switch to the API Access page from the left navigation
- Manage access credentials in the API Keys section
The knowledge base ID can be obtained from the knowledge base URL, for example:
https://app.dify.ai/datasets/12345678-1234-1234-1234-123456789012
where 12345678-1234-1234-1234-123456789012
is the knowledge base ID.
- Knowledge Base Name: The name of the knowledge base to create
- Description: Description of the knowledge base (optional)
- Document Name: The name of the document to create
- Text Content: The text content to upload
- Permission: Knowledge base permission settings
- only_me: Only the creator can access
- publicly_readable: Everyone can read
- Indexing Technology: Choose high_quality or economy mode
- Knowledge Base ID: The ID of the knowledge base to retrieve from (required)
- Query: The query to search for in the knowledge base (required)
- Search Method: The method to use for searching the knowledge base (optional, default is semantic search)
- keyword_search: Keyword search, based on keyword matching
- semantic_search: Semantic search, based on semantic understanding
- full_text_search: Full text search, searches the entire text content
- hybrid_search: Hybrid search, combines keyword and semantic search
- Enable Reranking: Whether to enable reranking of search results (optional, default is false)
- Number of Results: The number of results to return (optional, default is 3)
- Enable Score Threshold: Whether to enable score threshold filtering (optional, default is false)
- Score Threshold: The minimum score threshold for results (0-1) (optional, default is 0.5)
The upload tool returns a JSON response with the following structure:
{
"status": "success",
"knowledge_base_id": "12345678-1234-1234-1234-123456789012",
"knowledge_base": {
"id": "12345678-1234-1234-1234-123456789012",
"name": "Knowledge Base Name"
},
"document": {
"id": "document-id",
"name": "Document Name",
"batch": "batch-id",
"status": "completed"
}
}
The retrieve tool returns a JSON response with the following structure:
{
"status": "success",
"query": "Query content",
"knowledge_base_id": "Knowledge base ID",
"results": [
{
"segment": {
"id": "Segment ID",
"content": "Segment content",
"document": {
"id": "Document ID",
"name": "Document name"
}
},
"score": 0.95
}
]
}
The knowledge_base_id
field can be used for further operations with the knowledge base.
- Text content requires some time for processing and indexing after upload
- Processing large amounts of text may take longer
- If processing is not complete, the plugin will return the current status, and you can check the processing results later on the Dify platform
- Text content will be automatically segmented for processing, using automatic mode by default
- Text files (.txt)
- PDF files (.pdf)
- Word documents (.doc, .docx)
- Markdown files (.md, .markdown)
- HTML files (.html, .htm)
- Excel files (.xlsx)
- CSV files (.csv)