Class RAGFlowConfig.Builder
- Enclosing class:
- RAGFlowConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCrossLanguage(String language) Adds a language for cross-language retrieval.addCustomHeader(String key, String value) Adds a custom HTTP header.addDatasetId(String datasetId) Adds a single dataset ID to the list.addDocumentId(String documentId) Adds a single document ID to the filter list.Sets the RAGFlow API key.Sets the RAGFlow base URL.build()Builds the RAGFlowConfig instance.crossLanguages(List<String> crossLanguages) Sets the languages for cross-language retrieval.customHeaders(Map<String, String> customHeaders) Sets custom HTTP headers.datasetIds(List<String> datasetIds) Sets the dataset IDs (replaces existing list).documentIds(List<String> documentIds) Sets the document IDs to filter retrieval (optional).Sets whether to enable highlighting of matched terms in results.Sets whether to enable keyword-based matching.maxRetries(Integer maxRetries) Sets the maximum number of retries for failed requests.metadataCondition(Map<String, Object> metadataCondition) Sets the metadata filtering condition.Sets the page number for pagination.Sets the page size for pagination.Deprecated, for removal: This API element is subject to removal in a future version.Sets the rerank model ID.similarityThreshold(Double similarityThreshold) Sets the similarity threshold.Sets the HTTP timeout.tocEnhance(Boolean tocEnhance) Sets whether to use TOC (Table of Contents) enhancement.Sets the top K value for retrieval.Sets whether to use knowledge graph for multi-hop queries.vectorSimilarityWeight(Double vectorSimilarityWeight) Sets the vector similarity weight.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
apiKey
Sets the RAGFlow API key.- Parameters:
apiKey- the API key (required)- Returns:
- this builder
-
baseUrl
Sets the RAGFlow base URL.Default: http://localhost:9380
- Parameters:
baseUrl- the base URL- Returns:
- this builder
-
datasetIds
Sets the dataset IDs (replaces existing list).These are the IDs of RAGFlow datasets to search in. You can find these IDs in the RAGFlow console.
- Parameters:
datasetIds- the list of dataset IDs (required, at least one)- Returns:
- this builder
-
addDatasetId
Adds a single dataset ID to the list.- Parameters:
datasetId- the dataset ID to add- Returns:
- this builder
-
documentIds
Sets the document IDs to filter retrieval (optional).If specified, only search within these documents.
- Parameters:
documentIds- the list of document IDs- Returns:
- this builder
-
addDocumentId
Adds a single document ID to the filter list.- Parameters:
documentId- the document ID to add- Returns:
- this builder
-
topK
Sets the top K value for retrieval.Default: 5
- Parameters:
topK- the number of chunks to retrieve (must be > 0)- Returns:
- this builder
-
similarityThreshold
Sets the similarity threshold.Only chunks with similarity >= threshold will be returned.
Default: 0.2
- Parameters:
similarityThreshold- the similarity threshold (0.0-1.0)- Returns:
- this builder
-
vectorSimilarityWeight
Sets the vector similarity weight.The weight of vector cosine similarity. If x represents the weight, then (1 - x) is the term similarity weight.
Default: 0.3
- Parameters:
vectorSimilarityWeight- the weight (0.0-1.0)- Returns:
- this builder
-
page
Sets the page number for pagination.Default: 1
- Parameters:
page- the page number (>= 1)- Returns:
- this builder
-
pageSize
Sets the page size for pagination.Default: 30
- Parameters:
pageSize- the page size (>= 1)- Returns:
- this builder
-
useKg
Sets whether to use knowledge graph for multi-hop queries.Before enabling this, ensure you have successfully constructed a knowledge graph for the specified datasets.
Default: false
- Parameters:
useKg- true to enable knowledge graph- Returns:
- this builder
-
tocEnhance
Sets whether to use TOC (Table of Contents) enhancement.Before enabling this, ensure you have enabled TOC_Enhance and successfully extracted table of contents for the specified datasets.
Default: false
- Parameters:
tocEnhance- true to enable TOC enhancement- Returns:
- this builder
-
rerankId
Sets the rerank model ID.RAGFlow's
/api/v1/retrievalendpoint expectsrerank_idto be the rerank model's name, e.g."BAAI/bge-reranker-v2-m3@BAAI"or a hex UUID such as"b2a62730759d11ef987d0242ac120004".- Parameters:
rerankId- the rerank model ID- Returns:
- this builder
-
rerankId
Deprecated, for removal: This API element is subject to removal in a future version.RAGFlow identifies rerank models by name, not by a numeric id, so noIntegermaps to a real model and the retrieval request is rejected. UsererankId(String)instead. This overload only keeps existing call sites compiling and stringifies the value.Sets the rerank model ID from a numeric value.- Parameters:
rerankId- the rerank model ID- Returns:
- this builder
-
keyword
Sets whether to enable keyword-based matching.Default: false
- Parameters:
keyword- true to enable keyword matching- Returns:
- this builder
-
highlight
Sets whether to enable highlighting of matched terms in results.Default: false
- Parameters:
highlight- true to enable highlighting- Returns:
- this builder
-
crossLanguages
Sets the languages for cross-language retrieval.The languages that should be translated into, in order to achieve keywords retrievals in different languages.
- Parameters:
crossLanguages- the list of target languages- Returns:
- this builder
-
addCrossLanguage
Adds a language for cross-language retrieval.- Parameters:
language- the target language to add- Returns:
- this builder
-
metadataCondition
Sets the metadata filtering condition.Use this to filter chunks based on their metadata. For example:
builder.metadataCondition(Map.of( "author", "John", "category", "tech" ));- Parameters:
metadataCondition- the metadata condition map- Returns:
- this builder
-
timeout
Sets the HTTP timeout.Default: 30 seconds
- Parameters:
timeout- the timeout duration- Returns:
- this builder
-
maxRetries
Sets the maximum number of retries for failed requests.Default: 3
- Parameters:
maxRetries- the max retries (>= 0)- Returns:
- this builder
-
customHeaders
Sets custom HTTP headers.- Parameters:
customHeaders- the custom headers map- Returns:
- this builder
-
addCustomHeader
Adds a custom HTTP header.- Parameters:
key- the header namevalue- the header value- Returns:
- this builder
-
build
Builds the RAGFlowConfig instance.Either dataset_ids or document_ids must be set (or both). If document_ids is set without dataset_ids, ensure all documents use the same embedding model.
- Returns:
- a new RAGFlowConfig instance
- Throws:
IllegalArgumentException- if required parameters are missing
-
Integermaps to a real model and the retrieval request is rejected.