类 DashScopeToolsHelper
java.lang.Object
io.agentscope.core.formatter.dashscope.DashScopeToolsHelper
Handles tool registration and options application for DashScope API.
This class converts AgentScope tool schemas and options to DashScope DTO format.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidapplyOptions(DashScopeParameters params, GenerateOptions options, GenerateOptions defaultOptions) Apply GenerateOptions to DashScopeParameters.voidapplyToolChoice(DashScopeParameters params, ToolChoice toolChoice) Apply tool choice configuration to DashScopeParameters.voidapplyTools(DashScopeParameters params, List<ToolSchema> tools) Apply tools to DashScopeParameters.convertToolCalls(List<ToolUseBlock> toolBlocks) Convert ToolUseBlock list to DashScope ToolCall format.convertToolChoice(ToolChoice toolChoice) Convert tool choice to DashScope format.convertTools(List<ToolSchema> tools) Convert tool schemas to DashScope tool list.mergeAdditionalBodyParams(GenerateOptions options, GenerateOptions defaultOptions) Merge additional body parameters from options and default options.mergeAdditionalHeaders(GenerateOptions options, GenerateOptions defaultOptions) Merge additional headers from options and default options.mergeAdditionalQueryParams(GenerateOptions options, GenerateOptions defaultOptions) Merge additional query parameters from options and default options.
-
构造器详细资料
-
DashScopeToolsHelper
public DashScopeToolsHelper()
-
-
方法详细资料
-
applyOptions
public void applyOptions(DashScopeParameters params, GenerateOptions options, GenerateOptions defaultOptions) Apply GenerateOptions to DashScopeParameters.- 参数:
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.- 参数:
tools- List of tool schemas to convert (may be null or empty)- 返回:
- List of DashScopeTool objects
-
applyTools
Apply tools to DashScopeParameters.- 参数:
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
- 参数:
toolChoice- The tool choice configuration (null means auto/default)- 返回:
- The converted tool choice object
-
applyToolChoice
Apply tool choice configuration to DashScopeParameters.- 参数:
params- DashScope parameters to modifytoolChoice- The tool choice configuration (null means auto/default)
-
convertToolCalls
Convert ToolUseBlock list to DashScope ToolCall format.- 参数:
toolBlocks- The tool use blocks to convert- 返回:
- List of DashScopeToolCall objects (empty list if input is null/empty)
-
mergeAdditionalHeaders
public Map<String,String> mergeAdditionalHeaders(GenerateOptions options, GenerateOptions defaultOptions) Merge additional headers from options and default options.Default options are applied first, then options override.
- 参数:
options- the primary options (higher priority)defaultOptions- the fallback options (lower priority)- 返回:
- merged headers map, or null if both are empty
-
mergeAdditionalBodyParams
public Map<String,Object> mergeAdditionalBodyParams(GenerateOptions options, GenerateOptions defaultOptions) Merge additional body parameters from options and default options.Default options are applied first, then options override.
- 参数:
options- the primary options (higher priority)defaultOptions- the fallback options (lower priority)- 返回:
- merged body params map, or null if both are empty
-
mergeAdditionalQueryParams
public Map<String,String> mergeAdditionalQueryParams(GenerateOptions options, GenerateOptions defaultOptions) Merge additional query parameters from options and default options.Default options are applied first, then options override.
- 参数:
options- the primary options (higher priority)defaultOptions- the fallback options (lower priority)- 返回:
- merged query params map, or null if both are empty
-