AS AgentScopeAPI 手册 / API Reference

DashScopeResponseParser

public class DashScopeResponseParser
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:43–196

DashScope 响应解析器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.dashscope.formatter 包。核心成员包括 parseResponse、addToolCallsFromMessage、DashScopeResponseParser、FRAGMENT_PLACEHOLDER。

Parses DashScope API responses to AgentScope ChatResponse.

字段摘要Field Summary

字段Field类型Type说明Description
FRAGMENT_PLACEHOLDER
staticfinal
String
FRAGMENT PLACEHOLDER字段。
Placeholder name for tool call argument fragments in streaming responses.

构造器摘要Constructor Summary

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

方法摘要Method Summary

方法Method说明Description
public ChatResponse parseResponse(DashScopeResponse response, Instant startTime)
解析响应。
Parse DashScopeResponse to AgentScope ChatResponse.
protected void addToolCallsFromMessage(DashScopeMessage message, List<ContentBlock> blocks)
添加工具调用来自消息。
Parse tool calls from DashScopeMessage and add to blocks.

字段详情Field Detail

FRAGMENT_PLACEHOLDER

protected static final String FRAGMENT_PLACEHOLDER
staticfinal

FRAGMENT PLACEHOLDER字段。声明为 protected static final String FRAGMENT_PLACEHOLDER。

Placeholder name for tool call argument fragments in streaming responses.

源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:48

构造器详情Constructor Detail

DashScopeResponseParser

public DashScopeResponseParser()

初始化 DashScopeResponseParser 实例。

Creates a new instance.

源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:50

方法详情Method Detail

parseResponse

public ChatResponse parseResponse(DashScopeResponse response, Instant startTime)

解析响应。

Parse DashScopeResponse to AgentScope ChatResponse.

参数Parameters
名称Name类型Type说明Description
responseDashScopeResponse响应(类型 `DashScopeResponse`)。DashScope response DTO
startTimeInstant启动时间(类型 `Instant`)。Request start time for calculating duration
返回Returns ChatResponse
返回ChatResponse。AgentScope ChatResponse
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:59–142

addToolCallsFromMessage

protected void addToolCallsFromMessage(DashScopeMessage message, List<ContentBlock> blocks)

添加工具调用来自消息。

Parse tool calls from DashScopeMessage and add to blocks.

参数Parameters
名称Name类型Type说明Description
messageDashScopeMessage消息(类型 `DashScopeMessage`)。DashScopeMessage
blocksList<ContentBlock>内容块列表(类型 `List`)。Content blocks to add tool use blocks to
源码Source io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:150–195
基于官方固定版本源码静态生成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.