类 DashScopeMultiAgentFormatter
ThinkingBlock Handling: ThinkingBlock content is filtered out and NOT sent to DashScope API. It is stored in memory but excluded from all formatted messages.
-
构造器概要
构造器构造器说明Create a DashScopeMultiAgentFormatter with default conversation history prompt.DashScopeMultiAgentFormatter(String conversationHistoryPrompt) Create a DashScopeMultiAgentFormatter with custom conversation history prompt. -
方法概要
修饰符和类型方法说明voidapplyCacheControl(List<DashScopeMessage> messages) Apply cache control to DashScope messages.voidapplyOptions(DashScopeRequest request, GenerateOptions options, GenerateOptions defaultOptions) Apply generation options to provider-specific request parameters.voidapplyToolChoice(DashScopeRequest request, ToolChoice toolChoice) Apply tool choice configuration to provider-specific request parameters.voidapplyTools(DashScopeRequest request, List<ToolSchema> tools) Apply tool schemas to provider-specific request parameters.buildRequest(String model, List<DashScopeMessage> messages, boolean stream) Build a complete DashScopeRequest for the API call.protected List<DashScopeMessage> formatMultiModal(List<Msg> msgs) Format AgentScope Msg objects to DashScope MultiModal message format.parseResponse(DashScopeResponse result, Instant startTime) Parse provider-specific response to AgentScope ChatResponse.从类继承的方法 io.agentscope.core.formatter.AbstractBaseFormatter
convertToolResultToString, extractTextContent, extractTextContent, format, formatRoleLabel, getOptionOrDefault, hasMediaContent, saveBase64DataToTempFile, shouldBypassHistory从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.formatter.Formatter
applyToolChoice, applyTools
-
构造器详细资料
-
DashScopeMultiAgentFormatter
public DashScopeMultiAgentFormatter()Create a DashScopeMultiAgentFormatter with default conversation history prompt. -
DashScopeMultiAgentFormatter
Create a DashScopeMultiAgentFormatter with custom conversation history prompt.- 参数:
conversationHistoryPrompt- The prompt to prepend before conversation history
-
-
方法详细资料
-
doFormat
-
parseResponse
从接口复制的说明:FormatterParse provider-specific response to AgentScope ChatResponse.- 参数:
result- Provider-specific response objectstartTime- Request start time for calculating duration- 返回:
- AgentScope ChatResponse
-
applyOptions
public void applyOptions(DashScopeRequest request, GenerateOptions options, GenerateOptions defaultOptions) 从接口复制的说明:FormatterApply generation options to provider-specific request parameters.- 参数:
request- Provider-specific request parameters builderoptions- Generation options to applydefaultOptions- Default options to use if options parameter is null
-
applyTools
从接口复制的说明:FormatterApply tool schemas to provider-specific request parameters.- 参数:
request- Provider-specific request parameters buildertools- List of tool schemas to apply (may be null or empty)
-
applyToolChoice
从接口复制的说明:FormatterApply tool choice configuration to provider-specific request parameters.This method controls how the model uses tools. The default implementation does nothing, allowing formatters to override for providers that support tool choice configuration.
- 参数:
request- Provider-specific request parameters buildertoolChoice- Tool choice configuration (null means provider default)
-
formatMultiModal
Format AgentScope Msg objects to DashScope MultiModal message format. This method is used for vision models that require the MultiModalConversation API.This method follows Python's logic: 1. Process system message (if any) 2. Group remaining messages into "agent_message" and "tool_sequence" 3. Process each group in order, with first agent_message having history prompt
- 参数:
msgs- The AgentScope messages to convert- 返回:
- List of DashScopeMessage objects with multimodal content
-
buildRequest
Build a complete DashScopeRequest for the API call.- 参数:
model- Model namemessages- Formatted DashScope messagesstream- Whether to enable streaming- 返回:
- Complete DashScopeRequest ready for API call
-
applyCacheControl
Apply cache control to DashScope messages.Adds
cache_control: {"type": "ephemeral"}to all system messages and the last message in the list. Messages that already have cache_control set (e.g., via manual metadata marking) will not be overwritten.- 参数:
messages- the list of formatted DashScope messages
-