AS AgentScopeAPI 手册 / API Reference

AnthropicChatFormatter

public class AnthropicChatFormatter extends AnthropicBaseFormatter
源码Source io/agentscope/extensions/model/anthropic/formatter/AnthropicChatFormatter.java:37–52

Anthropic 聊天格式化器,与模型服务通信并返回生成或向量化结果。位于 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
msgsList<Msg>消息列表(类型 `List`)。The msgs.
返回Returns List<MessageParam>
返回列出。Returns list.
源码Source io/agentscope/extensions/model/anthropic/formatter/AnthropicChatFormatter.java:39–42

parseResponse

public ChatResponse parseResponse(Object response, Instant startTime)

解析响应。

Parses the response.

参数Parameters
名称Name类型Type说明Description
responseObject响应(类型 `Object`)。The response.
startTimeInstant启动时间(类型 `Instant`)。The start time.
返回Returns ChatResponse
返回ChatResponse。Returns chat response.
源码Source io/agentscope/extensions/model/anthropic/formatter/AnthropicChatFormatter.java:44–51

继承成员Inherited Members

基于官方固定版本源码静态生成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.