AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:179–459

构建器,用于构建并配置目标实例。位于 io.agentscope.core.rag.integration.haystack 包。核心成员包括 baseUrl、successCode、topK、scaleScore、returnEmbedding、scoreThreshold。

A class in io.agentscope.core.rag.integration.haystack that turns private documents into retrievable knowledge. Declared in io.agentscope.core.rag.integration.haystack.

方法摘要Method Summary

方法Method说明Description
public Builder baseUrl(String baseUrl)
设置HayStack 基类 URL。
Sets the HayStack base URL.
public Builder successCode(Integer successCode)
设置该配置项。
Sets the HayStack API success code.
public Builder topK(Integer topK)
设置该配置项。
The maximum number of documents to return.
public Builder scaleScore(Boolean scaleScore)
设置该配置项。
Whether to scale the scores of the retrieved documents or not
public Builder returnEmbedding(Boolean returnEmbedding)
设置该配置项。
Whether to return the embedding of the retrieved Documents.
public Builder scoreThreshold(Double scoreThreshold)
设置分数阈值。
A minimal score threshold for the result.
public Builder groupBy(String groupBy)
设置组通过。
Payload field to group by, must be a string or number field.
public Builder groupSize(Integer groupSize)
设置组大小。
Maximum amount of points to return per group.
public Builder queryEmbedding(List<Float> queryEmbedding)
设置查询向量化。
Use vector retrieval from the vector store.
public Builder querySparseEmbedding(SparseEmbedding querySparseEmbedding)
设置该配置项。
Sparse Embedding of the query.
public Builder documents(List<HayStackDocument> documents)
设置文档。
Performs the documents operation.
public Builder retrievedDocuments(List<HayStackDocument> retrievedDocuments)
设置该配置项。
The documents must include `metadata` indicating their origin and position:
public Builder 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.
public Builder filters(Map<String, Object> filters)
设置该配置项。
A dictionary with filters to narrow down the retriever's search space in the document store.
public Builder filterPolicy(FilterPolicy filterPolicy)
设置过滤策略。
Policy to determine how filters are applied in retrievers interacting with document stores.
public Builder timeout(Duration timeout)
设置HTTP 超时。
Sets the HTTP timeout.
public Builder maxRetries(Integer maxRetries)
设置最大重试。
Sets the maximum number of retries for failed requests.
public Builder customHeaders(Map<String, String> customHeaders)
设置自定义 HTTP 请求头。
Sets custom HTTP headers.
public Builder addCustomHeader(String key, String value)
添加自定义请求头。
Adds a custom HTTP header.
public HayStackConfig build()
构建HayStackConfig 实例。
Builds the HayStackConfig instance.

方法详情Method Detail

baseUrl

public Builder baseUrl(String baseUrl)

设置HayStack 基类 URL。

Sets the HayStack base URL.

参数Parameters
名称Name类型Type说明Description
baseUrlString基类 URL。the base URL
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:223–226

successCode

public Builder successCode(Integer successCode)

设置该配置项。

Sets the HayStack API success code.

参数Parameters
名称Name类型Type说明Description
successCodeInteger成功 Code(类型 `Integer`)。the success code
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:235–238

topK

public Builder topK(Integer topK)

设置该配置项。

The maximum number of documents to return.

参数Parameters
名称Name类型Type说明Description
topKIntegertop K(类型 `Integer`)。the number of chunks to retrieve (must be > 0)
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:247–253

scaleScore

public Builder scaleScore(Boolean 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.

参数Parameters
名称Name类型Type说明Description
scaleScoreBooleanscale 分数(类型 `Boolean`)。whether to scale scores
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:264–267

returnEmbedding

public Builder returnEmbedding(Boolean returnEmbedding)

设置该配置项。

Whether to return the embedding of the retrieved Documents.

参数Parameters
名称Name类型Type说明Description
returnEmbeddingBooleanreturn 向量化(类型 `Boolean`)。whether to return embedding
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:275–278

scoreThreshold

public Builder scoreThreshold(Double scoreThreshold)

设置分数阈值。

A minimal score threshold for the result.

参数Parameters
名称Name类型Type说明Description
scoreThresholdDouble分数阈值。the score threshold
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:288–291

groupBy

public Builder groupBy(String groupBy)

设置组通过。

Payload field to group by, must be a string or number field.

参数Parameters
名称Name类型Type说明Description
groupByString组通过(类型 `String`)。group name
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:300–303

groupSize

public Builder groupSize(Integer groupSize)

设置组大小。

Maximum amount of points to return per group.

参数Parameters
名称Name类型Type说明Description
groupSizeInteger组大小(类型 `Integer`)。group size
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:313–316

queryEmbedding

public Builder queryEmbedding(List<Float> queryEmbedding)

设置查询向量化。

Use vector retrieval from the vector store.

参数Parameters
名称Name类型Type说明Description
queryEmbeddingList<Float>查询向量化(类型 `List`)。queryEmbedding
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:325–328

querySparseEmbedding

public Builder querySparseEmbedding(SparseEmbedding querySparseEmbedding)

设置该配置项。

Sparse Embedding of the query.

参数Parameters
名称Name类型Type说明Description
querySparseEmbeddingSparseEmbedding查询 Sparse 向量化(类型 `SparseEmbedding`)。SparseEmbedding
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:336–339

documents

public Builder documents(List<HayStackDocument> documents)

设置文档。

Performs the documents operation.

参数Parameters
名称Name类型Type说明Description
documentsList<HayStackDocument>文档列表(类型 `List`)。The documents.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:341–344

retrievedDocuments

public Builder retrievedDocuments(List<HayStackDocument> 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.

参数Parameters
名称Name类型Type说明Description
retrievedDocumentsList<HayStackDocument>文档。the documents
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:354–357

windowSize

public Builder 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.

参数Parameters
名称Name类型Type说明Description
windowSizeIntegerwindow 大小(类型 `Integer`)。the window size
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:365–368

filters

public Builder filters(Map<String, Object> filters)

设置该配置项。

A dictionary with filters to narrow down the retriever's search space in the document store.

参数Parameters
名称Name类型Type说明Description
filtersMap<String, Object>filters(类型 `Map`)。the filters
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:376–379

filterPolicy

public Builder filterPolicy(FilterPolicy filterPolicy)

设置过滤策略。

Policy to determine how filters are applied in retrievers interacting with document stores.

参数Parameters
名称Name类型Type说明Description
filterPolicyFilterPolicy过滤策略(类型 `FilterPolicy`)。FilterPolicy.REPLACE or FilterPolicy.MERGE
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:387–390

timeout

public Builder timeout(Duration timeout)

设置HTTP 超时。

Sets the HTTP timeout.

参数Parameters
名称Name类型Type说明Description
timeoutDuration超时时长。the timeout duration
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:400–403

maxRetries

public Builder maxRetries(Integer maxRetries)

设置最大重试。

Sets the maximum number of retries for failed requests.

参数Parameters
名称Name类型Type说明Description
maxRetriesInteger最大重试(>=0)。the max retries (>= 0)
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:413–419

customHeaders

public Builder customHeaders(Map<String, String> customHeaders)

设置自定义 HTTP 请求头。

Sets custom HTTP headers.

参数Parameters
名称Name类型Type说明Description
customHeadersMap<String, String>自定义请求头映射。the custom headers map
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:427–430

addCustomHeader

public Builder addCustomHeader(String key, String value)

添加自定义请求头。

Adds a custom HTTP header.

参数Parameters
名称Name类型Type说明Description
keyString请求头名称。the header name
valueString请求头值。the header value
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:439–442

build

public HayStackConfig build()

构建HayStackConfig 实例。

Builds the HayStackConfig instance.

返回Returns HayStackConfig
一种新的`HayStackConfig`实例。a new `HayStackConfig` instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if the required `baseUrl` parameter is missing or blank
源码Source io/agentscope/core/rag/integration/haystack/HayStackConfig.java:452–458
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.