Class DifyRAGClient

java.lang.Object
io.agentscope.core.rag.integration.dify.DifyRAGClient

public class DifyRAGClient extends Object
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 Details

    • DifyRAGClient

      public DifyRAGClient(DifyRAGConfig config)
      Creates a new DifyRAGClient instance.
      Parameters:
      config - the Dify configuration
  • Method Details

    • retrieve

      public reactor.core.publisher.Mono<DifyResponse> retrieve(String query, Integer limit)
      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 text
      limit - the maximum number of documents to retrieve (null for default)
      Returns:
      a Mono emitting the Dify API response
    • getConfig

      public DifyRAGConfig getConfig()
      Gets the Dify configuration.
      Returns:
      the configuration