Class DifyRAGConfig

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

public class DifyRAGConfig extends Object
Configuration for Dify Knowledge Base integration.

This class contains all necessary configuration parameters to connect to and interact with Dify Knowledge Base service, including connection settings, retrieval parameters, and HTTP client settings.

Example usage:


 DifyRAGConfig config = DifyRAGConfig.builder()
     .apiKey(System.getenv("DIFY_RAG_API_KEY"))
     .datasetId("your-dataset-id")  // Configure in code
     .apiBaseUrl("https://api.dify.ai/v1")  // Optional, for self-hosted
     .retrievalMode(RetrievalMode.HYBRID_SEARCH)
     .topK(10)
     .scoreThreshold(0.5)
     .enableRerank(true)
     .rerankConfig(RerankConfig.builder()
         .topN(5)
         .build())
     .build();
 
  • Method Details

    • getApiKey

      public String getApiKey()
      Gets the Dify API key.
      Returns:
      the API key
    • getApiBaseUrl

      public String getApiBaseUrl()
      Gets the Dify API base URL.
      Returns:
      the base URL
    • getDatasetId

      public String getDatasetId()
      Gets the dataset (knowledge base) ID.
      Returns:
      the dataset ID
    • getRetrievalMode

      public RetrievalMode getRetrievalMode()
      Gets the retrieval mode.
      Returns:
      the retrieval mode
    • getTopK

      public Integer getTopK()
      Gets the top K value for retrieval.
      Returns:
      the top K value (1-100)
    • getScoreThreshold

      public Double getScoreThreshold()
      Gets the score threshold for filtering results.
      Returns:
      the score threshold (0.0-1.0)
    • getEnableRerank

      public Boolean getEnableRerank()
      Checks if reranking is enabled.
      Returns:
      true if reranking is enabled, null if not configured
    • getRerankConfig

      public RerankConfig getRerankConfig()
      Gets the rerank configuration.
      Returns:
      the rerank config, or null if not set
    • getWeights

      public Double getWeights()
      Gets the hybrid search weights.

      This parameter is used when retrieval mode is HYBRID_SEARCH. It controls the balance between keyword and semantic search.

      Returns:
      the weights value (0-1), or null if not set
    • getMetadataFilter

      public MetadataFilter getMetadataFilter()
      Gets the metadata filter configuration.
      Returns:
      the metadata filter, or null if not set
    • getConnectTimeout

      public Duration getConnectTimeout()
      Gets the HTTP connection timeout.
      Returns:
      the connection timeout
    • getReadTimeout

      public Duration getReadTimeout()
      Gets the HTTP read timeout.
      Returns:
      the read timeout
    • getMaxRetries

      public Integer getMaxRetries()
      Gets the maximum number of retries for failed requests.
      Returns:
      the max retries
    • getCustomHeaders

      public Map<String,String> getCustomHeaders()
      Gets custom HTTP headers.
      Returns:
      a copy of custom headers map
    • builder

      public static DifyRAGConfig.Builder builder()
      Creates a new builder for DifyRAGConfig.
      Returns:
      a new Builder instance
    • toString

      public String toString()
      Overrides:
      toString in class Object