Class HayStackConfig.Builder
java.lang.Object
io.agentscope.core.rag.integration.haystack.HayStackConfig.Builder
- Enclosing class:
- HayStackConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCustomHeader(String key, String value) Adds a custom HTTP header.Sets the HayStack base URL.build()Builds the HayStackConfig instance.customHeaders(Map<String, String> customHeaders) Sets custom HTTP headers.documents(List<HayStackDocument> documents) filterPolicy(FilterPolicy filterPolicy) Policy to determine how filters are applied in retrievers interacting with document stores.A dictionary with filters to narrow down the retriever's search space in the document store.Payload field to group by, must be a string or number field.Maximum amount of points to return per group.maxRetries(Integer maxRetries) Sets the maximum number of retries for failed requests.queryEmbedding(List<Float> queryEmbedding) Use vector retrieval from the vector store.querySparseEmbedding(SparseEmbedding querySparseEmbedding) Sparse Embedding of the query.retrievedDocuments(List<HayStackDocument> retrievedDocuments) The documents must include `metadata` indicating their origin and position:returnEmbedding(Boolean returnEmbedding) Whether to return the embedding of the retrieved Documents.scaleScore(Boolean scaleScore) Whether to scale the scores of the retrieved documents or notscoreThreshold(Double scoreThreshold) A minimal score threshold for the result.successCode(Integer successCode) Sets the HayStack API success code.Sets the HTTP timeout.The maximum number of documents to return.windowSize(Integer windowSize) The number of adjacent documents to include on each side of the retrieved document can be configured using the `window_size` parameter.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
baseUrl
Sets the HayStack base URL.- Parameters:
baseUrl- the base URL- Returns:
- this builder
-
successCode
Sets the HayStack API success code.Default: 0
- Parameters:
successCode- the success code- Returns:
- this builder
-
topK
The maximum number of documents to return. If using `group_by` parameters, maximum number of groups to return.Default: 3
- Parameters:
topK- the number of chunks to retrieve (must be > 0)- Returns:
- this builder
-
scaleScore
Whether to scale the scores of the retrieved documents or not- When `true`, scales the score of retrieved documents to a range of 0 to 1, where 1 means extremely relevant.
- When `false`, uses raw similarity scores.
- Parameters:
scaleScore- whether to scale scores- Returns:
- this builder
-
returnEmbedding
Whether to return the embedding of the retrieved Documents.- Parameters:
returnEmbedding- whether to return embedding- Returns:
- this builder
-
scoreThreshold
A minimal score threshold for the result.Score of the returned result might be higher or smaller than the threshold depending on the Distance function used.
E.g. for cosine similarity only higher scores will be returned.
- Parameters:
scoreThreshold- the score threshold- Returns:
- this builder
-
groupBy
Payload field to group by, must be a string or number field. If the field contains more than 1 value, all values will be used for grouping. One point can be in multiple groups.- Parameters:
groupBy- group name- Returns:
- this builder
-
groupSize
Maximum amount of points to return per group.Default is 3.
- Parameters:
groupSize- group size- Returns:
- this builder
-
queryEmbedding
Use vector retrieval from the vector store.Normally you should not use it directly, instead use normal `query text` together with Haystack's `Embedders`.
- Parameters:
queryEmbedding- queryEmbedding- Returns:
- this builder
-
querySparseEmbedding
Sparse Embedding of the query.- Parameters:
querySparseEmbedding- SparseEmbedding- Returns:
- this builder
-
documents
-
retrievedDocuments
The documents must include `metadata` indicating their origin and position:- `source_id` is used to group sentence chunks belonging to the same original document.
- `split_id` represents the position/order of the chunk within the document.
- Parameters:
retrievedDocuments- the documents- Returns:
- this builder
-
windowSize
The number of adjacent documents to include on each side of the retrieved document can be configured using the `window_size` parameter.- Parameters:
windowSize- the window size- Returns:
- this builder
-
filters
A dictionary with filters to narrow down the retriever's search space in the document store.- Parameters:
filters- the filters- Returns:
- this builder
-
filterPolicy
Policy to determine how filters are applied in retrievers interacting with document stores.- Parameters:
filterPolicy- FilterPolicy.REPLACE or FilterPolicy.MERGE- 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 HayStackConfig instance.The
baseUrlparameter is required and must not benullor blank.- Returns:
- a new
HayStackConfiginstance - Throws:
IllegalArgumentException- if the requiredbaseUrlparameter is missing or blank
-