DashScopeResponseParser
public class DashScopeResponseParser
源码Source
io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:43–196DashScope 响应解析器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.dashscope.formatter 包。核心成员包括 parseResponse、addToolCallsFromMessage、DashScopeResponseParser、FRAGMENT_PLACEHOLDER。
Parses DashScope API responses to AgentScope ChatResponse.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
FRAGMENT_PLACEHOLDERstaticfinal | 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 |
|---|---|---|
response | DashScopeResponse | 响应(类型 `DashScopeResponse`)。DashScope response DTO |
startTime | Instant | 启动时间(类型 `Instant`)。Request start time for calculating duration |
ChatResponse返回ChatResponse。AgentScope ChatResponse
源码Source
io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:59–142addToolCallsFromMessage
protected void addToolCallsFromMessage(DashScopeMessage message, List<ContentBlock> blocks)
添加工具调用来自消息。
Parse tool calls from DashScopeMessage and add to blocks.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | DashScopeMessage | 消息(类型 `DashScopeMessage`)。DashScopeMessage |
blocks | List<ContentBlock> | 内容块列表(类型 `List`)。Content blocks to add tool use blocks to |
源码Source
io/agentscope/extensions/model/dashscope/formatter/DashScopeResponseParser.java:150–195