AS AgentScopeAPI 手册 / API Reference

DashScopeChatModel

public class DashScopeChatModel extends ChatModelBase
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:65–841

DashScope 聊天模型,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.dashscope 包,继承自 ChatModelBase。核心成员包括 builder、doStream、getModelName、supportsNativeStructuredOutput、DashScopeChatModel。

DashScope Chat Model using native HTTP API.

This implementation uses direct HTTP calls to DashScope API via OkHttp, without depending on the DashScope Java SDK.

Supports both text and vision models through automatic endpoint routing. Use EndpointType to explicitly control the endpoint selection.

Features:

  • Streaming and non-streaming modes

  • Tool calling support

  • Thinking mode support

  • Automatic message format conversion

  • Timeout and retry configuration

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
A class in io.agentscope.extensions.model.dashscope that talks to model services and returns generated or embedded output.

构造器摘要Constructor Summary

构造器Constructor说明Description
public DashScopeChatModel(String apiKey, String modelName, boolean stream, Boolean enableThinking, Boolean enableSearch, GenerateOptions defaultOptions, String baseUrl, Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter, HttpTransport httpTransport, String publicKeyId, String publicKey)
初始化 `DashScopeChatModel` 实例。
Creates a new DashScope chat model instance with automatic API type detection.
public DashScopeChatModel(String apiKey, String modelName, boolean stream, Boolean enableThinking, Boolean enableSearch, EndpointType endpointType, GenerateOptions defaultOptions, String baseUrl, Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter, HttpTransport httpTransport, String publicKeyId, String publicKey)
初始化 `DashScopeChatModel` 实例。
Creates a new DashScope chat model instance with explicit API type.
public DashScopeChatModel(String apiKey, String modelName, boolean stream, Boolean enableThinking, Boolean enableSearch, EndpointType endpointType, GenerateOptions defaultOptions, String baseUrl, Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter, HttpTransport httpTransport, String publicKeyId, String publicKey, Collection<String> multimodalModelPatterns)
初始化 `DashScopeChatModel` 实例。
Creates a new DashScope chat model instance with explicit API type and additional multimodal model patterns.

方法摘要Method Summary

方法Method说明Description
public static Builder builder()
static
创建新的构建器用于 DashScopeChatModel。
Creates a new builder for DashScopeChatModel.
protected Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options)
以流式方式执行并返回结果。
Stream chat completion responses from DashScope's API.
public String getModelName()
获取模型名称。
Gets the model name for logging and identification.
public boolean supportsNativeStructuredOutput()
返回支持原生结构化输出。
Returns the supports native structured output.

构造器详情Constructor Detail

DashScopeChatModel

public DashScopeChatModel(String apiKey, String modelName, boolean stream, Boolean enableThinking, Boolean enableSearch, GenerateOptions defaultOptions, String baseUrl, Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter, HttpTransport httpTransport, String publicKeyId, String publicKey)

初始化 DashScopeChatModel 实例。

Creates a new DashScope chat model instance with automatic API type detection.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 键(类型 `String`)。the API key for DashScope authentication
modelNameString模型名称(类型 `String`)。the model name (e.g., "qwen-max", "qwen-vl-plus")
streamboolean流(类型 `boolean`)。whether streaming should be enabled
enableThinkingBoolean启用 Thinking(类型 `Boolean`)。whether thinking mode should be enabled (null for disabled)
enableSearchBoolean启用搜索(类型 `Boolean`)。whether search enhancement should be enabled (null for disabled)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。default generation options (null for defaults)
baseUrlString基类 URL(类型 `String`)。custom base URL for DashScope API (null for default)
formatterFormatter<DashScopeMessage, DashScopeResponse, DashScopeRequest>格式化器(类型 `Formatter`)。the message formatter to use (null for default DashScope formatter)
httpTransportHttpTransportHTTP 传输层(类型 `HttpTransport`)。custom HTTP transport (null for default from factory)
publicKeyIdStringpublic 键标识(类型 `String`)。the RSA public key ID for encryption (null to disable encryption)
publicKeyStringpublic 键(类型 `String`)。the RSA public key for encryption (Base64-encoded, null to disable encryption)
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:98–123

DashScopeChatModel

public DashScopeChatModel(String apiKey, String modelName, boolean stream, Boolean enableThinking, Boolean enableSearch, EndpointType endpointType, GenerateOptions defaultOptions, String baseUrl, Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter, HttpTransport httpTransport, String publicKeyId, String publicKey)

初始化 DashScopeChatModel 实例。

Creates a new DashScope chat model instance with explicit API type.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 键(类型 `String`)。the API key for DashScope authentication
modelNameString模型名称(类型 `String`)。the model name (e.g., "qwen-max", "qwen-vl-plus")
streamboolean流(类型 `boolean`)。whether streaming should be enabled
enableThinkingBoolean启用 Thinking(类型 `Boolean`)。whether thinking mode should be enabled (null for disabled)
enableSearchBoolean启用搜索(类型 `Boolean`)。whether search enhancement should be enabled (null for disabled)
endpointTypeEndpointType端点类型(类型 `EndpointType`)。the endpoint type to use (null for AUTO detection)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。default generation options (null for defaults)
baseUrlString基类 URL(类型 `String`)。custom base URL for DashScope API (null for default)
formatterFormatter<DashScopeMessage, DashScopeResponse, DashScopeRequest>格式化器(类型 `Formatter`)。the message formatter to use (null for default DashScope formatter)
httpTransportHttpTransportHTTP 传输层(类型 `HttpTransport`)。custom HTTP transport (null for default from factory)
publicKeyIdStringpublic 键标识(类型 `String`)。the RSA public key ID for encryption (null to disable encryption)
publicKeyStringpublic 键(类型 `String`)。the RSA public key for encryption (Base64-encoded, null to disable encryption)
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:141–168

DashScopeChatModel

public DashScopeChatModel(String apiKey, String modelName, boolean stream, Boolean enableThinking, Boolean enableSearch, EndpointType endpointType, GenerateOptions defaultOptions, String baseUrl, Formatter<DashScopeMessage, DashScopeResponse, DashScopeRequest> formatter, HttpTransport httpTransport, String publicKeyId, String publicKey, Collection<String> multimodalModelPatterns)

初始化 DashScopeChatModel 实例。

Creates a new DashScope chat model instance with explicit API type and additional multimodal model patterns.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 键(类型 `String`)。the API key for DashScope authentication
modelNameString模型名称(类型 `String`)。the model name (e.g., "qwen-max", "qwen-vl-plus")
streamboolean流(类型 `boolean`)。whether streaming should be enabled
enableThinkingBoolean启用 Thinking(类型 `Boolean`)。whether thinking mode should be enabled (null for disabled)
enableSearchBoolean启用搜索(类型 `Boolean`)。whether search enhancement should be enabled (null for disabled)
endpointTypeEndpointType端点类型(类型 `EndpointType`)。the endpoint type to use (null for AUTO detection)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。default generation options (null for defaults)
baseUrlString基类 URL(类型 `String`)。custom base URL for DashScope API (null for default)
formatterFormatter<DashScopeMessage, DashScopeResponse, DashScopeRequest>格式化器(类型 `Formatter`)。the message formatter to use (null for default DashScope formatter)
httpTransportHttpTransportHTTP 传输层(类型 `HttpTransport`)。custom HTTP transport (null for default from factory)
publicKeyIdStringpublic 键标识(类型 `String`)。the RSA public key ID for encryption (null to disable encryption)
publicKeyStringpublic 键(类型 `String`)。the RSA public key for encryption (Base64-encoded, null to disable encryption)
multimodalModelPatternsCollection<String>多模态模型 Patterns(类型 `Collection`)。case-insensitive substring patterns that extend the built-in multimodal model detection when endpointType is AUTO (null to disable)
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:189–226

方法详情Method Detail

builder

public static Builder builder()
static

创建新的构建器用于 DashScopeChatModel。

Creates a new builder for DashScopeChatModel.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:233–235

doStream

protected Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options)

以流式方式执行并返回结果。

Stream chat completion responses from DashScope's API.

参数Parameters
名称Name类型Type说明Description
messagesList<Msg>消息列表(类型 `List`)。AgentScope messages to send to the model
toolsList<ToolSchema>工具模式的可选列出。Optional list of tool schemas
optionsGenerateOptions选项(类型 `GenerateOptions`)。Optional generation options (null to use defaults)
返回Returns Flux<ChatResponse>
返回Flux。Flux stream of chat responses
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:253–271

getModelName

public String getModelName()

获取模型名称。

Gets the model name for logging and identification.

返回Returns String
模型名称。the model name
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:427–430

supportsNativeStructuredOutput

public boolean supportsNativeStructuredOutput()

返回支持原生结构化输出。

Returns the supports native structured output.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/model/dashscope/DashScopeChatModel.java:432–438

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 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.

继承成员Inherited Members

基于官方固定版本源码静态生成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.