Class RAGFlowKnowledge
- All Implemented Interfaces:
io.agentscope.core.rag.Knowledge
This class provides integration with RAGFlow Knowledge Base service, implementing the Knowledge interface to enable seamless RAG (Retrieval-Augmented Generation) capabilities with RAGFlow-hosted knowledge bases.
Key features:
- Local or remote RAGFlow deployment support
- Advanced document understanding with OCR
- Knowledge graph enhanced retrieval
- Reranking support for better results
- Conversation history support for context-aware retrieval
- Compatible with Bailian and Dify RAG plugins (same Knowledge interface)
Functional Scope: This plugin focuses on retrieval capabilities only, similar to Bailian and Dify RAG plugins. Document management (upload/delete/update) should be performed via RAGFlow console.
Example usage:
RAGFlowConfig config = RAGFlowConfig.builder()
.apiKey("ragflow-xxx")
.baseUrl("http://localhost:9380")
.knowledgeBaseId("kb-xxx")
.topK(10)
.similarityThreshold(0.5)
.enableRerank(true)
.build();
RAGFlowKnowledge knowledge = RAGFlowKnowledge.builder()
.config(config)
.build();
// Retrieve documents
List<Document> docs = knowledge.retrieve("What is AI?", retrieveConfig).block();
// Use with Agent
ReActAgent agent = ReActAgent.builder()
.knowledge(knowledge)
.ragMode(RAGMode.AGENTIC)
.build();
Note: Document management is not supported via this plugin. Please use RAGFlow console to upload, delete, and manage documents. This design ensures compatibility with Bailian and Dify RAG plugins and keeps the plugin focused.
- Author:
- RAGFlow Integration Team
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>addDocuments(List<io.agentscope.core.rag.model.Document> documents) Adds documents to the knowledge base.static RAGFlowKnowledge.Builderbuilder()reactor.core.publisher.Mono<List<io.agentscope.core.rag.model.Document>>Retrieve documents from the RAGFlow knowledge base.
-
Method Details
-
builder
-
retrieve
public reactor.core.publisher.Mono<List<io.agentscope.core.rag.model.Document>> retrieve(String query, io.agentscope.core.rag.model.RetrieveConfig config) Retrieve documents from the RAGFlow knowledge base.This method searches the RAGFlow dataset for documents relevant to the given query. The RAGFlow retrieve-chunks API is used under the hood.
API Endpoint:
POST /api/v1/datasets/{dataset_id}/retrieve-chunksFeatures:
- Vector similarity search
- Configurable top-K results
- Similarity threshold filtering
- Metadata-based filtering (via config)
Note: Unlike some other RAG systems, RAGFlow's retrieve-chunks API does not support:
- ❌ Conversation history for context-aware retrieval
- Specified by:
retrievein interfaceio.agentscope.core.rag.Knowledge- Parameters:
query- the query text (required)config- the retrieval configuration (limit, score threshold)- Returns:
- a Mono emitting the list of retrieved documents, sorted by relevance
-
addDocuments
public reactor.core.publisher.Mono<Void> addDocuments(List<io.agentscope.core.rag.model.Document> documents) Adds documents to the knowledge base.Note: This operation is not supported, consistent with Bailian and Dify RAG plugins. Document management should be performed via RAGFlow console:
- Access RAGFlow console (http://localhost:9380)
- Navigate to Knowledge Base > Select your dataset
- Click "Upload Document" to add files
- Wait for processing to complete
- Documents will be available for retrieval via this plugin
- Specified by:
addDocumentsin interfaceio.agentscope.core.rag.Knowledge- Parameters:
documents- the list of documents to add- Returns:
- a Mono that completes with an error indicating the operation is not supported
-