Class DashScopeToolsHelper
java.lang.Object
io.agentscope.extensions.model.dashscope.formatter.DashScopeToolsHelper
Handles tool registration and options application for DashScope API.
This class converts AgentScope tool schemas and options to DashScope DTO format.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyOptions(DashScopeParameters params, io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Apply GenerateOptions to DashScopeParameters.voidapplyToolChoice(DashScopeParameters params, io.agentscope.core.model.ToolChoice toolChoice) Apply tool choice configuration to DashScopeParameters.voidapplyTools(DashScopeParameters params, List<io.agentscope.core.model.ToolSchema> tools) Apply tools to DashScopeParameters.convertToolCalls(List<io.agentscope.core.message.ToolUseBlock> toolBlocks) Convert ToolUseBlock list to DashScope ToolCall format.convertToolChoice(io.agentscope.core.model.ToolChoice toolChoice) Convert tool choice to DashScope format.convertTools(List<io.agentscope.core.model.ToolSchema> tools) Convert tool schemas to DashScope tool list.mergeAdditionalBodyParams(io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Merge additional body parameters from options and default options.mergeAdditionalHeaders(io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Merge additional headers from options and default options.mergeAdditionalQueryParams(io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Merge additional query parameters from options and default options.
-
Constructor Details
-
DashScopeToolsHelper
public DashScopeToolsHelper()
-
-
Method Details
-
applyOptions
public void applyOptions(DashScopeParameters params, io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Apply GenerateOptions to DashScopeParameters.- Parameters:
params- DashScope parameters to modifyoptions- Generation options to applydefaultOptions- Default options to use if options parameter is null
-
convertTools
Convert tool schemas to DashScope tool list.- Parameters:
tools- List of tool schemas to convert (may be null or empty)- Returns:
- List of DashScopeTool objects
-
applyTools
Apply tools to DashScopeParameters.- Parameters:
params- DashScope parameters to modifytools- List of tool schemas to apply (may be null or empty)
-
convertToolChoice
Convert tool choice to DashScope format.DashScope API supports:
- String "auto": model decides whether to call tools (default)
- String "none": disable tool calling
- Object {"type": "function", "function": {"name": "tool_name"}}: force specific tool
- Parameters:
toolChoice- The tool choice configuration (null means auto/default)- Returns:
- The converted tool choice object
-
applyToolChoice
public void applyToolChoice(DashScopeParameters params, io.agentscope.core.model.ToolChoice toolChoice) Apply tool choice configuration to DashScopeParameters.- Parameters:
params- DashScope parameters to modifytoolChoice- The tool choice configuration (null means auto/default)
-
convertToolCalls
public List<DashScopeToolCall> convertToolCalls(List<io.agentscope.core.message.ToolUseBlock> toolBlocks) Convert ToolUseBlock list to DashScope ToolCall format.- Parameters:
toolBlocks- The tool use blocks to convert- Returns:
- List of DashScopeToolCall objects (empty list if input is null/empty)
-
mergeAdditionalHeaders
public Map<String,String> mergeAdditionalHeaders(io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Merge additional headers from options and default options.Default options are applied first, then options override.
- Parameters:
options- the primary options (higher priority)defaultOptions- the fallback options (lower priority)- Returns:
- merged headers map, or null if both are empty
-
mergeAdditionalBodyParams
public Map<String,Object> mergeAdditionalBodyParams(io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Merge additional body parameters from options and default options.Default options are applied first, then options override.
- Parameters:
options- the primary options (higher priority)defaultOptions- the fallback options (lower priority)- Returns:
- merged body params map, or null if both are empty
-
mergeAdditionalQueryParams
public Map<String,String> mergeAdditionalQueryParams(io.agentscope.core.model.GenerateOptions options, io.agentscope.core.model.GenerateOptions defaultOptions) Merge additional query parameters from options and default options.Default options are applied first, then options override.
- Parameters:
options- the primary options (higher priority)defaultOptions- the fallback options (lower priority)- Returns:
- merged query params map, or null if both are empty
-