AS AgentScopeAPI 手册 / API Reference

DashScopeToolsHelper

public class DashScopeToolsHelper
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:42–337

处理工具注册和选项应用用于 DashScope API。位于 io.agentscope.extensions.model.dashscope.formatter 包。核心成员包括 applyOptions、convertTools、applyTools、convertToolChoice、applyToolChoice、convertToolCalls。

Handles tool registration and options application for DashScope API.

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

构造器摘要Constructor Summary

构造器Constructor说明Description
public DashScopeToolsHelper()
初始化 `DashScopeToolsHelper` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void applyOptions(DashScopeParameters params, GenerateOptions options, GenerateOptions defaultOptions)
应用选项。
Apply GenerateOptions to DashScopeParameters.
public List<DashScopeTool> convertTools(List<ToolSchema> tools)
转换工具模式到 DashScope 工具列出。
Convert tool schemas to DashScope tool list.
public void applyTools(DashScopeParameters params, List<ToolSchema> tools)
应用工具。
Apply tools to DashScopeParameters.
public Object convertToolChoice(ToolChoice toolChoice)
转换工具选项到 DashScope 格式。
Convert tool choice to DashScope format.
public void applyToolChoice(DashScopeParameters params, ToolChoice toolChoice)
应用工具选项。
Apply tool choice configuration to DashScopeParameters.
public List<DashScopeToolCall> convertToolCalls(List<ToolUseBlock> toolBlocks)
转换ToolUseBlock 列出到 DashScope 工具调用格式。
Convert ToolUseBlock list to DashScope ToolCall format.
public Map<String, String> mergeAdditionalHeaders(GenerateOptions options, GenerateOptions defaultOptions)
合并 `mergeAdditionalHeaders`。
Merge additional headers from options and default options.
public Map<String, Object> mergeAdditionalBodyParams(GenerateOptions options, GenerateOptions defaultOptions)
合并 `mergeAdditionalBodyParams`。
Merge additional body parameters from options and default options.
public Map<String, String> mergeAdditionalQueryParams(GenerateOptions options, GenerateOptions defaultOptions)
合并 `mergeAdditionalQueryParams`。
Merge additional query parameters from options and default options.

构造器详情Constructor Detail

DashScopeToolsHelper

public DashScopeToolsHelper()

初始化 DashScopeToolsHelper 实例。

Creates a new instance.

源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:46

方法详情Method Detail

applyOptions

public void applyOptions(DashScopeParameters params, GenerateOptions options, GenerateOptions defaultOptions)

应用选项。

Apply GenerateOptions to DashScopeParameters.

参数Parameters
名称Name类型Type说明Description
paramsDashScopeParameters参数(类型 `DashScopeParameters`)。DashScope parameters to modify
optionsGenerateOptions选项(类型 `GenerateOptions`)。Generation options to apply
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。Default options to use if options parameter is null
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:55–113

convertTools

public List<DashScopeTool> convertTools(List<ToolSchema> tools)

转换工具模式到 DashScope 工具列出。

Convert tool schemas to DashScope tool list.

参数Parameters
名称Name类型Type说明Description
toolsList<ToolSchema>工具列表(类型 `List`)。List of tool schemas to convert (may be null or empty)
返回Returns List<DashScopeTool>
返回列出。List of DashScopeTool objects
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:140–164

applyTools

public void applyTools(DashScopeParameters params, List<ToolSchema> tools)

应用工具。

Apply tools to DashScopeParameters.

参数Parameters
名称Name类型Type说明Description
paramsDashScopeParameters参数(类型 `DashScopeParameters`)。DashScope parameters to modify
toolsList<ToolSchema>工具列表(类型 `List`)。List of tool schemas to apply (may be null or empty)
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:172–177

convertToolChoice

public Object convertToolChoice(ToolChoice toolChoice)

转换工具选项到 DashScope 格式。

Convert tool choice to DashScope format.

参数Parameters
名称Name类型Type说明Description
toolChoiceToolChoice工具选项(类型 `ToolChoice`)。The tool choice configuration (null means auto/default)
返回Returns Object
已转换工具选项对象。The converted tool choice object
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:192–219

applyToolChoice

public void applyToolChoice(DashScopeParameters params, ToolChoice toolChoice)

应用工具选项。

Apply tool choice configuration to DashScopeParameters.

参数Parameters
名称Name类型Type说明Description
paramsDashScopeParameters参数(类型 `DashScopeParameters`)。DashScope parameters to modify
toolChoiceToolChoice工具选项(类型 `ToolChoice`)。The tool choice configuration (null means auto/default)
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:227–232

convertToolCalls

public List<DashScopeToolCall> convertToolCalls(List<ToolUseBlock> toolBlocks)

转换ToolUseBlock 列出到 DashScope 工具调用格式。

Convert ToolUseBlock list to DashScope ToolCall format.

参数Parameters
名称Name类型Type说明Description
toolBlocksList<ToolUseBlock>工具 Blocks(类型 `List`)。The tool use blocks to convert
返回Returns List<DashScopeToolCall>
返回列出。List of DashScopeToolCall objects (empty list if input is null/empty)
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:240–267

mergeAdditionalHeaders

public Map<String, String> mergeAdditionalHeaders(GenerateOptions options, GenerateOptions defaultOptions)

合并 mergeAdditionalHeaders。

Merge additional headers from options and default options.

参数Parameters
名称Name类型Type说明Description
optionsGenerateOptions选项(类型 `GenerateOptions`)。the primary options (higher priority)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。the fallback options (lower priority)
返回Returns Map<String, String>
返回映射。merged headers map, or null if both are empty
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:278–290

mergeAdditionalBodyParams

public Map<String, Object> mergeAdditionalBodyParams(GenerateOptions options, GenerateOptions defaultOptions)

合并 mergeAdditionalBodyParams。

Merge additional body parameters from options and default options.

参数Parameters
名称Name类型Type说明Description
optionsGenerateOptions选项(类型 `GenerateOptions`)。the primary options (higher priority)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。the fallback options (lower priority)
返回Returns Map<String, Object>
返回映射。merged body params map, or null if both are empty
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:301–313

mergeAdditionalQueryParams

public Map<String, String> mergeAdditionalQueryParams(GenerateOptions options, GenerateOptions defaultOptions)

合并 mergeAdditionalQueryParams。

Merge additional query parameters from options and default options.

参数Parameters
名称Name类型Type说明Description
optionsGenerateOptions选项(类型 `GenerateOptions`)。the primary options (higher priority)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。the fallback options (lower priority)
返回Returns Map<String, String>
返回映射。merged query params map, or null if both are empty
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeToolsHelper.java:324–336
基于官方固定版本源码静态生成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.