AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:440–840

构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.model.dashscope 包。核心成员包括 apiKey、modelName、stream、enableThinking、enableSearch、endpointType。

A class in io.agentscope.extensions.model.dashscope that talks to model services and returns generated or embedded output. Declared in io.agentscope.extensions.model.dashscope.

方法摘要Method Summary

方法Method说明Description
public Builder apiKey(String apiKey)
设置API 键。
Sets the API key for DashScope authentication.
public Builder modelName(String modelName)
设置模型名称到使用。
Sets the model name to use.
public Builder stream(boolean stream)
设置流。
Sets whether streaming should be enabled.
public Builder enableThinking(Boolean enableThinking)
启用该配置。
Sets whether thinking mode should be enabled.
public Builder enableSearch(Boolean enableSearch)
启用搜索。
Sets whether search enhancement should be enabled.
public Builder endpointType(EndpointType endpointType)
设置端点类型到使用用于端点路由。
Sets the endpoint type to use for endpoint routing.
public Builder defaultOptions(GenerateOptions options)
设置默认选项。
Sets the default generation options.
public Builder baseUrl(String baseUrl)
设置自定义基类 URL 用于 DashScope API。
Sets a custom base URL for DashScope API.
public Builder formatter(Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter)
设置消息格式化器到使用。
Sets the message formatter to use.
public Builder httpTransport(HttpTransport httpTransport)
设置HTTP 传输层到使用。
Sets the HTTP transport to use.
public Builder proxy(ProxyConfig proxyConfig)
设置代理。
Sets the proxy configuration for HTTP traffic.
public Builder enableEncrypt(boolean enableEncrypt)
启用该配置。
Sets whether encryption should be enabled.
public Builder contextWindowSize(int contextWindowSize)
设置该配置项。
Overrides the inferred context window size (in tokens).
public Builder nativeStructuredOutput(boolean nativeStructuredOutput)
设置原生结构化输出。
Sets whether this model supports native structured output via `response_format` with `json_schema` type.
public Builder nativeStructuredOutputWithTools(boolean nativeStructuredOutputWithTools)
设置原生结构化输出使用工具。
Sets whether this model correctly handles native structured output (`response_format`) alongside tool calling.
public Builder multimodalModelPatterns(Collection<String> multimodalModelPatterns)
设置该配置项。
Sets additional case-insensitive substring patterns for multimodal model detection.
public DashScopeChatModel build()
构建DashScopeChatModel 实例。
Builds the DashScopeChatModel instance.

方法详情Method Detail

apiKey

public Builder apiKey(String apiKey)

设置API 键。

Sets the API key for DashScope authentication.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 密钥。the API key
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:464–467

modelName

public Builder modelName(String modelName)

设置模型名称到使用。

Sets the model name to use.

另见See also @see DashScopeHttpClient#isMultimodalModel(String)
参数Parameters
名称Name类型Type说明Description
modelNameString模型名称(类型 `String`)。the model name (e.g., "qwen-max", "qwen-vl-plus")
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:478–481

stream

public Builder stream(boolean stream)

设置流。

Sets whether streaming should be enabled.

参数Parameters
名称Name类型Type说明Description
streamboolean流(类型 `boolean`)。true to enable streaming, false for non-streaming
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:489–492

enableThinking

public Builder enableThinking(Boolean enableThinking)

启用该配置。

Sets whether thinking mode should be enabled.

参数Parameters
名称Name类型Type说明Description
enableThinkingBoolean启用 Thinking(类型 `Boolean`)。true to enable thinking mode, false to disable, null for default
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:500–503

enableSearch

public Builder enableSearch(Boolean enableSearch)

启用搜索。

Sets whether search enhancement should be enabled.

参数Parameters
名称Name类型Type说明Description
enableSearchBoolean启用搜索(类型 `Boolean`)。true to enable search mode, false to disable, null for default (disabled)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:514–517

endpointType

public Builder endpointType(EndpointType endpointType)

设置端点类型到使用用于端点路由。

Sets the endpoint type to use for endpoint routing.

另见See also @see EndpointType, @see DashScopeHttpClient#isMultimodalModel(String)
参数Parameters
名称Name类型Type说明Description
endpointTypeEndpointType端点类型(类型 `EndpointType`)。the endpoint type to use (null for AUTO)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:527–530

defaultOptions

public Builder defaultOptions(GenerateOptions options)

设置默认选项。

Sets the default generation options.

参数Parameters
名称Name类型Type说明Description
optionsGenerateOptions选项(类型 `GenerateOptions`)。the default options to use (null for defaults)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:538–541

baseUrl

public Builder baseUrl(String baseUrl)

设置自定义基类 URL 用于 DashScope API。

Sets a custom base URL for DashScope API.

参数Parameters
名称Name类型Type说明Description
baseUrlString基类 URL(类型 `String`)。the base URL (null for default)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:549–552

formatter

public Builder formatter(Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter)

设置消息格式化器到使用。

Sets the message formatter to use.

参数Parameters
名称Name类型Type说明Description
formatterFormatter<DashScopeMessage, DashScopeResponse, DashScopeRequest>格式化器(类型 `Formatter`)。the formatter (null for default DashScope formatter)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:560–564

httpTransport

public Builder httpTransport(HttpTransport httpTransport)

设置HTTP 传输层到使用。

Sets the HTTP transport to use.

参数Parameters
名称Name类型Type说明Description
httpTransportHttpTransportHTTP 传输层(类型 `HttpTransport`)。the HTTP transport (null for default from factory)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:606–609

proxy

public Builder proxy(ProxyConfig proxyConfig)

设置代理。

Sets the proxy configuration for HTTP traffic.

参数Parameters
名称Name类型Type说明Description
proxyConfigProxyConfig代理配置(类型 `ProxyConfig`)。the proxy configuration (see `ProxyConfig`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:636–639

enableEncrypt

public Builder enableEncrypt(boolean enableEncrypt)

启用该配置。

Sets whether encryption should be enabled.

参数Parameters
名称Name类型Type说明Description
enableEncryptboolean启用 Encrypt(类型 `boolean`)。true to enable encryption (will fetch public key automatically), false to disable encryption
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:666–669

contextWindowSize

public Builder contextWindowSize(int contextWindowSize)

设置该配置项。

Overrides the inferred context window size (in tokens).

参数Parameters
名称Name类型Type说明Description
contextWindowSizeint上下文 Window 大小(类型 `int`)。The context window size.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:675–678

nativeStructuredOutput

public Builder nativeStructuredOutput(boolean nativeStructuredOutput)

设置原生结构化输出。

Sets whether this model supports native structured output via response_format with json_schema type.

参数Parameters
名称Name类型Type说明Description
nativeStructuredOutputboolean原生结构化输出(类型 `boolean`)。true to enable native json_schema path
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:695–698

nativeStructuredOutputWithTools

public Builder nativeStructuredOutputWithTools(boolean nativeStructuredOutputWithTools)

设置原生结构化输出使用工具。

Sets whether this model correctly handles native structured output (response_format) alongside tool calling.

参数Parameters
名称Name类型Type说明Description
nativeStructuredOutputWithToolsboolean原生结构化输出使用工具(类型 `boolean`)。false to use fallback when tools are present
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:711–714

multimodalModelPatterns

public Builder multimodalModelPatterns(Collection<String> multimodalModelPatterns)

设置该配置项。

Sets additional case-insensitive substring patterns for multimodal model detection.

另见See also @see DashScopeHttpClient.Builder#multimodalModelPatterns(Collection)
参数Parameters
名称Name类型Type说明Description
multimodalModelPatternsCollection<String>多模态模型 Patterns(类型 `Collection`)。case-insensitive substring patterns (may be null)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:739–742

build

public DashScopeChatModel build()

构建DashScopeChatModel 实例。

Builds the DashScopeChatModel instance.

返回Returns DashScopeChatModel
返回DashScopeChatModel。configured DashScopeChatModel instance
抛出Throws
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:762–804
基于官方固定版本源码静态生成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.