https://github.com/stvlynn/better-knowledge-base
Better Dify knowledge base plugin
https://github.com/stvlynn/better-knowledge-base
Last synced: about 1 month ago
JSON representation
Better Dify knowledge base plugin
- Host: GitHub
- URL: https://github.com/stvlynn/better-knowledge-base
- Owner: stvlynn
- License: mit
- Created: 2025-03-10T14:49:40.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-10T14:57:09.000Z (about 2 months ago)
- Last Synced: 2025-03-10T15:44:02.035Z (about 2 months ago)
- Language: Python
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hacking-lists - stvlynn/better-knowledge-base - Better Dify knowledge base plugin (Python)
README
# Dify Knowledge Base Manager Plugin
A plugin for managing Dify knowledge base - creating knowledge bases, uploading text content, and retrieving information.
## Prerequisites
Before using this plugin, you need:
1. A Dify platform account
2. Knowledge base API Key## How to Get API Key
1. Log in to [Dify.ai](https://cloud.dify.ai)
2. Navigate to the knowledge base page
3. Switch to the **API Access** page from the left navigation
4. Manage access credentials in the **API Keys** section## How to Get Knowledge Base ID
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.## Upload Tool Parameters

- **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## Retrieve Tool Parameters

- **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)## Upload Output
The upload tool returns a JSON response with the following structure:
```json
{
"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"
}
}
```## Retrieve Output
The retrieve tool returns a JSON response with the following structure:
```json
{
"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.
## Notes
- 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## Supported File Formats
- Text files (.txt)
- PDF files (.pdf)
- Word documents (.doc, .docx)
- Markdown files (.md, .markdown)
- HTML files (.html, .htm)
- Excel files (.xlsx)
- CSV files (.csv)