Class DifyRAGClient
java.lang.Object
io.agentscope.core.rag.integration.dify.DifyRAGClient
Client for interacting with Dify Knowledge Base API.
This class wraps OkHttp client and provides reactive API methods for knowledge base operations. It handles HTTP request construction, authentication, error handling, and response parsing.
Example usage:
DifyRAGConfig config = DifyRAGConfig.builder()
.apiKey(...)
.datasetId(...)
.build();
DifyRAGClient client = new DifyRAGClient(config);
DifyResponse response = client.retrieve("query text", 10).block();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the Dify configuration.reactor.core.publisher.Mono<DifyResponse>Retrieves relevant documents from the knowledge base.
-
Constructor Details
-
DifyRAGClient
Creates a new DifyRAGClient instance.- Parameters:
config- the Dify configuration
-
-
Method Details
-
retrieve
Retrieves relevant documents from the knowledge base.This method searches the Dify knowledge base for documents relevant to the given query. The retrieval mode (keyword/semantic/hybrid) is configured in DifyRAGConfig.
API endpoint: POST /datasets/{dataset_id}/retrieve
- Parameters:
query- the search query textlimit- the maximum number of documents to retrieve (null for default)- Returns:
- a Mono emitting the Dify API response
-
getConfig
Gets the Dify configuration.- Returns:
- the configuration
-