AS AgentScopeAPI 手册 / API Reference

DashScopeMultiAgentFormatter

public class DashScopeMultiAgentFormatter extends AbstractBaseFormatter<DashScopeMessage, DashScopeResponse, DashScopeRequest>
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:46–406

DashScope Multi 智能体格式化器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.dashscope.formatter 包,继承自 AbstractBaseFormatter<DashScopeMessage, DashScopeResponse, DashScopeRequest>。核心成员包括 doFormat、parseResponse、applyOptions、applyTools、applyToolChoice、formatMultiModal。

DashScope formatter for multi-agent conversations. Converts AgentScope Msg objects to DashScope DTO Message objects with multi-agent support. Collapses multi-agent conversation into a single user message with history tags.

ThinkingBlock Handling: ThinkingBlock content is filtered out and NOT sent to DashScope API. It is stored in memory but excluded from all formatted messages.

构造器摘要Constructor Summary

构造器Constructor说明Description
public DashScopeMultiAgentFormatter()
创建DashScopeMultiAgentFormatter 使用默认会话历史提示词。
Create a DashScopeMultiAgentFormatter with default conversation history prompt.
public DashScopeMultiAgentFormatter(String conversationHistoryPrompt)
创建DashScopeMultiAgentFormatter 使用自定义会话历史提示词。
Create a DashScopeMultiAgentFormatter with custom conversation history prompt.

方法摘要Method Summary

方法Method说明Description
protected List<DashScopeMessage> doFormat(List<Msg> msgs)
执行格式操作。
Performs the do format operation.
protected List<DashScopeMessage> doFormat(List<Msg> msgs, GenerateOptions options)
执行格式操作。
Performs the do format operation.
public ChatResponse parseResponse(DashScopeResponse result, Instant startTime)
解析响应。
Parses the response.
public void applyOptions(DashScopeRequest request, GenerateOptions options, GenerateOptions defaultOptions)
应用选项。
Performs the apply options operation.
public void applyTools(DashScopeRequest request, List<ToolSchema> tools)
应用工具。
Performs the apply tools operation.
public void applyToolChoice(DashScopeRequest request, ToolChoice toolChoice)
应用工具选项。
Performs the apply tool choice operation.
public List<DashScopeMessage> formatMultiModal(List<Msg> msgs)
格式化 `formatMultiModal`。
Format AgentScope Msg objects to DashScope MultiModal message format.
public List<DashScopeMessage> formatMultiModal(List<Msg> msgs, GenerateOptions options)
格式化 `formatMultiModal`。
Format AgentScope Msg objects to DashScope MultiModal message format using request-scoped generation options.
public DashScopeRequest buildRequest(String model, List<DashScopeMessage> messages, boolean stream)
构建请求。
Build a complete DashScopeRequest for the API call.

构造器详情Constructor Detail

DashScopeMultiAgentFormatter

public DashScopeMultiAgentFormatter()

创建DashScopeMultiAgentFormatter 使用默认会话历史提示词。

Create a DashScopeMultiAgentFormatter with default conversation history prompt.

源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:63–65

DashScopeMultiAgentFormatter

public DashScopeMultiAgentFormatter(String conversationHistoryPrompt)

创建DashScopeMultiAgentFormatter 使用自定义会话历史提示词。

Create a DashScopeMultiAgentFormatter with custom conversation history prompt.

参数Parameters
名称Name类型Type说明Description
conversationHistoryPromptString会话历史提示词(类型 `String`)。The prompt to prepend before conversation history
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:72–78

方法详情Method Detail

doFormat

protected List<DashScopeMessage> doFormat(List<Msg> msgs)

执行格式操作。

Performs the do format operation.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。The msgs.
返回Returns List<DashScopeMessage>
返回列出。Returns list.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:80–83

doFormat

protected List<DashScopeMessage> doFormat(List<Msg> msgs, GenerateOptions options)

执行格式操作。

Performs the do format operation.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。The msgs.
optionsGenerateOptions选项(类型 `GenerateOptions`)。The options.
返回Returns List<DashScopeMessage>
返回列出。Returns list.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:85–141

parseResponse

public ChatResponse parseResponse(DashScopeResponse result, Instant startTime)

解析响应。

Parses the response.

参数Parameters
名称Name类型Type说明Description
resultDashScopeResponse结果(类型 `DashScopeResponse`)。The result.
startTimeInstant启动时间(类型 `Instant`)。The start time.
返回Returns ChatResponse
返回ChatResponse。Returns chat response.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:143–146

applyOptions

public void applyOptions(DashScopeRequest request, GenerateOptions options, GenerateOptions defaultOptions)

应用选项。

Performs the apply options operation.

参数Parameters
名称Name类型Type说明Description
requestDashScopeRequest请求(类型 `DashScopeRequest`)。The request.
optionsGenerateOptions选项(类型 `GenerateOptions`)。The options.
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。The default options.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:148–157

applyTools

public void applyTools(DashScopeRequest request, List<ToolSchema> tools)

应用工具。

Performs the apply tools operation.

参数Parameters
名称Name类型Type说明Description
requestDashScopeRequest请求(类型 `DashScopeRequest`)。The request.
toolsList<ToolSchema>工具列表(类型 `List`)。The tools.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:159–167

applyToolChoice

public void applyToolChoice(DashScopeRequest request, ToolChoice toolChoice)

应用工具选项。

Performs the apply tool choice operation.

参数Parameters
名称Name类型Type说明Description
requestDashScopeRequest请求(类型 `DashScopeRequest`)。The request.
toolChoiceToolChoice工具选项(类型 `ToolChoice`)。The tool choice.
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:169–177

formatMultiModal

public List<DashScopeMessage> formatMultiModal(List<Msg> msgs)

格式化 formatMultiModal。

Format AgentScope Msg objects to DashScope MultiModal message format.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>AgentScope 消息到转换。The AgentScope messages to convert
返回Returns List<DashScopeMessage>
返回列出。List of DashScopeMessage objects with multimodal content
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:191–193

formatMultiModal

public List<DashScopeMessage> formatMultiModal(List<Msg> msgs, GenerateOptions options)

格式化 formatMultiModal。

Format AgentScope Msg objects to DashScope MultiModal message format using request-scoped generation options.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>AgentScope 消息到转换。The AgentScope messages to convert
optionsGenerateOptions选项(类型 `GenerateOptions`)。request-scoped generation options; may be `null`
返回Returns List<DashScopeMessage>
返回列出。List of DashScopeMessage objects with multimodal content
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:203–254

buildRequest

public DashScopeRequest buildRequest(String model, List<DashScopeMessage> messages, boolean stream)

构建请求。

Build a complete DashScopeRequest for the API call.

参数Parameters
名称Name类型Type说明Description
modelString模型实例(类型 `String`)。Model name
messagesList<DashScopeMessage>消息列表(类型 `List`)。Formatted DashScope messages
streamboolean判断是否到启用流式。Whether to enable streaming
返回Returns DashScopeRequest
返回DashScopeRequest。Complete DashScopeRequest ready for API call
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeMultiAgentFormatter.java:264–274
基于官方固定版本源码静态生成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.