类 DashScopeToolsHelper

java.lang.Object
io.agentscope.core.formatter.dashscope.DashScopeToolsHelper

public class DashScopeToolsHelper extends Object
Handles tool registration and options application for DashScope API.

This class converts AgentScope tool schemas and options to DashScope DTO format.

  • 构造器详细资料

    • DashScopeToolsHelper

      public DashScopeToolsHelper()
  • 方法详细资料

    • applyOptions

      public void applyOptions(DashScopeParameters params, GenerateOptions options, GenerateOptions defaultOptions)
      Apply GenerateOptions to DashScopeParameters.
      参数:
      params - DashScope parameters to modify
      options - Generation options to apply
      defaultOptions - Default options to use if options parameter is null
    • convertTools

      public List<DashScopeTool> convertTools(List<ToolSchema> tools)
      Convert tool schemas to DashScope tool list.
      参数:
      tools - List of tool schemas to convert (may be null or empty)
      返回:
      List of DashScopeTool objects
    • applyTools

      public void applyTools(DashScopeParameters params, List<ToolSchema> tools)
      Apply tools to DashScopeParameters.
      参数:
      params - DashScope parameters to modify
      tools - List of tool schemas to apply (may be null or empty)
    • convertToolChoice

      public Object convertToolChoice(ToolChoice toolChoice)
      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

      public void applyToolChoice(DashScopeParameters params, ToolChoice toolChoice)
      Apply tool choice configuration to DashScopeParameters.
      参数:
      params - DashScope parameters to modify
      toolChoice - The tool choice configuration (null means auto/default)
    • convertToolCalls

      public List<DashScopeToolCall> convertToolCalls(List<ToolUseBlock> toolBlocks)
      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