Class DifyRAGConfig
java.lang.Object
io.agentscope.core.rag.integration.dify.DifyRAGConfig
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();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic DifyRAGConfig.Builderbuilder()Creates a new builder for DifyRAGConfig.Gets the Dify API base URL.Gets the Dify API key.Gets the HTTP connection timeout.Gets custom HTTP headers.Gets the dataset (knowledge base) ID.Checks if reranking is enabled.Gets the maximum number of retries for failed requests.Gets the metadata filter configuration.Gets the HTTP read timeout.Gets the rerank configuration.Gets the retrieval mode.Gets the score threshold for filtering results.getTopK()Gets the top K value for retrieval.Gets the hybrid search weights.toString()
-
Method Details
-
getApiKey
Gets the Dify API key.- Returns:
- the API key
-
getApiBaseUrl
Gets the Dify API base URL.- Returns:
- the base URL
-
getDatasetId
Gets the dataset (knowledge base) ID.- Returns:
- the dataset ID
-
getRetrievalMode
Gets the retrieval mode.- Returns:
- the retrieval mode
-
getTopK
Gets the top K value for retrieval.- Returns:
- the top K value (1-100)
-
getScoreThreshold
Gets the score threshold for filtering results.- Returns:
- the score threshold (0.0-1.0)
-
getEnableRerank
Checks if reranking is enabled.- Returns:
- true if reranking is enabled, null if not configured
-
getRerankConfig
Gets the rerank configuration.- Returns:
- the rerank config, or null if not set
-
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
Gets the metadata filter configuration.- Returns:
- the metadata filter, or null if not set
-
getConnectTimeout
Gets the HTTP connection timeout.- Returns:
- the connection timeout
-
getReadTimeout
Gets the HTTP read timeout.- Returns:
- the read timeout
-
getMaxRetries
Gets the maximum number of retries for failed requests.- Returns:
- the max retries
-
getCustomHeaders
Gets custom HTTP headers.- Returns:
- a copy of custom headers map
-
builder
Creates a new builder for DifyRAGConfig.- Returns:
- a new Builder instance
-
toString
-