AnthropicChatFormatter
public class AnthropicChatFormatter extends AnthropicBaseFormatter
源码Source
io/agentscope/extensions/model/anthropic/formatter/AnthropicChatFormatter.java:37–52Anthropic 聊天格式化器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.anthropic.formatter 包,继承自 AnthropicBaseFormatter。核心成员包括 doFormat、parseResponse。
Formatter for Anthropic Messages API. Converts between AgentScope Msg objects and Anthropic SDK types.
Important: Anthropic API has special requirements:
-
Only the first message can be a system message (handled via system parameter)
-
Tool results must be in separate user messages
-
Supports thinking blocks natively (extended thinking feature)
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public List<MessageParam> doFormat(List<Msg> msgs) | 执行格式操作。 Performs the do format operation. |
public ChatResponse parseResponse(Object response, Instant startTime) | 解析响应。 Parses the response. |
方法详情Method Detail
doFormat
public List<MessageParam> doFormat(List<Msg> msgs)
执行格式操作。
Performs the do format operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
List<MessageParam>返回列出。Returns list.
源码Source
io/agentscope/extensions/model/anthropic/formatter/AnthropicChatFormatter.java:39–42parseResponse
public ChatResponse parseResponse(Object response, Instant startTime)
解析响应。
Parses the response.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
response | Object | 响应(类型 `Object`)。The response. |
startTime | Instant | 启动时间(类型 `Instant`)。The start time. |
ChatResponse返回ChatResponse。Returns chat response.
源码Source
io/agentscope/extensions/model/anthropic/formatter/AnthropicChatFormatter.java:44–51