类 DashScopeChatModel
java.lang.Object
io.agentscope.core.model.ChatModelBase
io.agentscope.core.model.DashScopeChatModel
- 所有已实现的接口:
Model
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
-
嵌套类概要
嵌套类 -
构造器概要
构造器构造器说明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) Creates a new DashScope chat model instance with explicit API type.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) Creates a new DashScope chat model instance with automatic API type detection. -
方法概要
修饰符和类型方法说明static DashScopeChatModel.Builderbuilder()Creates a new builder for DashScopeChatModel.protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses from DashScope's API.Gets the model name for logging and identification.从类继承的方法 io.agentscope.core.model.ChatModelBase
stream
-
构造器详细资料
-
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) Creates a new DashScope chat model instance with automatic API type detection.This constructor maintains backward compatibility. API type defaults to AUTO, which detects the endpoint based on model name.
- 参数:
apiKey- the API key for DashScope authenticationmodelName- the model name (e.g., "qwen-max", "qwen-vl-plus")stream- whether streaming should be enabled (ignored if enableThinking is true)enableThinking- whether thinking mode should be enabled (null for disabled)enableSearch- whether search enhancement should be enabled (null for disabled)defaultOptions- default generation options (null for defaults)baseUrl- custom base URL for DashScope API (null for default)formatter- the message formatter to use (null for default DashScope formatter)httpTransport- custom HTTP transport (null for default from factory)publicKeyId- the RSA public key ID for encryption (null to disable encryption)publicKey- the RSA public key for encryption (Base64-encoded, null to disable encryption)
-
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) Creates a new DashScope chat model instance with explicit API type.- 参数:
apiKey- the API key for DashScope authenticationmodelName- the model name (e.g., "qwen-max", "qwen-vl-plus")stream- whether streaming should be enabled (ignored if enableThinking is true)enableThinking- whether thinking mode should be enabled (null for disabled)enableSearch- whether search enhancement should be enabled (null for disabled)endpointType- the endpoint type to use (null for AUTO detection)defaultOptions- default generation options (null for defaults)baseUrl- custom base URL for DashScope API (null for default)formatter- the message formatter to use (null for default DashScope formatter)httpTransport- custom HTTP transport (null for default from factory)publicKeyId- the RSA public key ID for encryption (null to disable encryption)publicKey- the RSA public key for encryption (Base64-encoded, null to disable encryption)
-
-
方法详细资料
-
builder
Creates a new builder for DashScopeChatModel.- 返回:
- a new Builder instance
-
doStream
protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses from DashScope's API.This method automatically routes to the appropriate API based on the model name:
- Vision models (qvq* or *-vl*) → MultiModal API
- Text models → Text Generation API
Supports timeout and retry configuration through GenerateOptions.
- 指定者:
doStream在类中ChatModelBase- 参数:
messages- AgentScope messages to send to the modeltools- Optional list of tool schemasoptions- Optional generation options (null to use defaults)- 返回:
- Flux stream of chat responses
-
getModelName
Gets the model name for logging and identification.- 返回:
- the model name
-