AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:271–545

DifyRAGConfig的构建器。位于 io.agentscope.core.rag.integration.dify 包。核心成员包括 apiKey、apiBaseUrl、datasetId、retrievalMode、topK、scoreThreshold。

Builder for DifyRAGConfig.

方法摘要Method Summary

方法Method说明Description
public Builder apiKey(String apiKey)
设置API 键。
Sets the Dify API key.
public Builder apiBaseUrl(String apiBaseUrl)
设置API 基类 URL。
Sets the Dify API base URL.
public Builder datasetId(String datasetId)
设置该配置项。
Sets the dataset (knowledge base) ID.
public Builder retrievalMode(RetrievalMode retrievalMode)
设置检索模式。
Sets the retrieval mode.
public Builder topK(Integer topK)
设置该配置项。
Sets the top K value for retrieval.
public Builder scoreThreshold(Double scoreThreshold)
设置分数阈值。
Sets the score threshold for filtering results.
public Builder enableRerank(Boolean enableRerank)
启用重排。
Sets whether to enable reranking.
public Builder rerankConfig(RerankConfig rerankConfig)
设置重排配置。
Sets the rerank configuration.
public Builder weights(Double weights)
设置该配置项。
Sets the hybrid search weights.
public Builder metadataFilter(MetadataFilter metadataFilter)
设置元数据过滤配置。
Sets the metadata filter configuration.
public Builder connectTimeout(Duration connectTimeout)
设置HTTP 连接超时。
Sets the HTTP connection timeout.
public Builder readTimeout(Duration readTimeout)
设置HTTP 读取超时。
Sets the HTTP read timeout.
public Builder maxRetries(Integer maxRetries)
设置最大重试。
Sets the maximum number of retries for failed requests.
public Builder customHeaders(Map<String, String> customHeaders)
设置自定义请求头。
Sets custom HTTP headers to include in all requests.
public Builder addCustomHeader(String name, String value)
添加自定义请求头。
Adds a single custom HTTP header.
public DifyRAGConfig build()
构建新的DifyRAGConfig 实例。
Builds a new DifyRAGConfig instance.

方法详情Method Detail

apiKey

public Builder apiKey(String apiKey)

设置API 键。

Sets the Dify API key.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 键(类型 `String`)。the API key (format: dataset-xxxxxxxxxxxxxxxx)
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:310–313

apiBaseUrl

public Builder apiBaseUrl(String apiBaseUrl)

设置API 基类 URL。

Sets the Dify API base URL.

参数Parameters
名称Name类型Type说明Description
apiBaseUrlStringAPI 基类 URL(类型 `String`)。the API base URL (must include /v1 suffix)
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:326–329

datasetId

public Builder datasetId(String datasetId)

设置该配置项。

Sets the dataset (knowledge base) ID.

参数Parameters
名称Name类型Type说明Description
datasetIdStringdataset 标识(类型 `String`)。the dataset ID
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:340–343

retrievalMode

public Builder retrievalMode(RetrievalMode retrievalMode)

设置检索模式。

Sets the retrieval mode.

参数Parameters
名称Name类型Type说明Description
retrievalModeRetrievalMode检索模式。the retrieval mode
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:361–364

topK

public Builder topK(Integer topK)

设置该配置项。

Sets the top K value for retrieval.

参数Parameters
名称Name类型Type说明Description
topKIntegertop K(类型 `Integer`)。the top K value
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if topK is not in valid range
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:376–382

scoreThreshold

public Builder scoreThreshold(Double scoreThreshold)

设置分数阈值。

Sets the score threshold for filtering results.

参数Parameters
名称Name类型Type说明Description
scoreThresholdDouble分数阈值。the score threshold
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if scoreThreshold is not in valid range
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:394–400

enableRerank

public Builder enableRerank(Boolean enableRerank)

启用重排。

Sets whether to enable reranking.

参数Parameters
名称Name类型Type说明Description
enableRerankBoolean启用重排(类型 `Boolean`)。true to enable reranking
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:413–416

rerankConfig

public Builder rerankConfig(RerankConfig rerankConfig)

设置重排配置。

Sets the rerank configuration.

参数Parameters
名称Name类型Type说明Description
rerankConfigRerankConfig重排配置。the rerank configuration
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:426–429

weights

public Builder weights(Double weights)

设置该配置项。

Sets the hybrid search weights.

参数Parameters
名称Name类型Type说明Description
weightsDoubleweights(类型 `Double`)。the weights value
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if weights is not in valid range
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:444–450

metadataFilter

public Builder metadataFilter(MetadataFilter metadataFilter)

设置元数据过滤配置。

Sets the metadata filter configuration.

参数Parameters
名称Name类型Type说明Description
metadataFilterMetadataFilter元数据过滤配置。the metadata filter configuration
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:460–463

connectTimeout

public Builder connectTimeout(Duration connectTimeout)

设置HTTP 连接超时。

Sets the HTTP connection timeout.

参数Parameters
名称Name类型Type说明Description
connectTimeoutDuration连接超时。the connection timeout
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:473–476

readTimeout

public Builder readTimeout(Duration readTimeout)

设置HTTP 读取超时。

Sets the HTTP read timeout.

参数Parameters
名称Name类型Type说明Description
readTimeoutDuration读取超时。the read timeout
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:486–489

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 = no retry)
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if maxRetries is negative
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:500–506

customHeaders

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

设置自定义请求头。

Sets custom HTTP headers to include in all requests.

参数Parameters
名称Name类型Type说明Description
customHeadersMap<String, String>请求头名称到值的映射。map of header name to value
返回Returns Builder
返回当前实例,以支持链式调用。this builder for method chaining
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:516–519

addCustomHeader

public Builder addCustomHeader(String name, String value)

添加自定义请求头。

Adds a single custom HTTP header.

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

build

public DifyRAGConfig build()

构建新的DifyRAGConfig 实例。

Builds a new DifyRAGConfig instance.

返回Returns DifyRAGConfig
一种新的DifyRAGConfig 实例。a new DifyRAGConfig instance
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if required parameters are missing or invalid
源码Source io/agentscope/core/rag/integration/dify/DifyRAGConfig.java:542–544
基于官方固定版本源码静态生成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.