类class
agentscope.formatterAnthropicChatFormatter
class AnthropicChatFormatter(_AnthropicFormatterBase)
源码Source
agentscope/formatter/_anthropic_formatter.py:363–397Anthropic 聊天格式化器,在智能体、模型与前端之间传递结构化消息和事件。位于 agentscope.formatter 包,继承自 _AnthropicFormatterBase。核心成员包括 format。
The Anthropic formatter class for chatbot scenario, where only a user and an agent are involved. Declared in agentscope.formatter. Extends _AnthropicFormatterBase.
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
input_types | list[str] | 输入类型字段。 | Field(default_factory=lambda: ['text/plain', 'image/*', 'application/pdf'], description='The supported input types. Defaults to ``["text/plain", "image/*", "application/pdf"]``.') |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def format(msgs: list[Msg]) -> list[dict[str, Any]]async | 设置格式。 Format message objects into Anthropic API format. |
属性详情Attribute Detail
input_types
list[str] = Field(default_factory=lambda: ['text/plain', 'image/*', 'application/pdf'], description='The supported input types. Defaults to ``["text/plain", "image/*", "application/pdf"]``.')输入类型字段。声明为 list[str]。
The supported input types.
源码Source
agentscope/formatter/_anthropic_formatter.py:369方法详情Method Detail
format
async def format(msgs: list[Msg]) -> list[dict[str, Any]]
async
设置格式。
Format message objects into Anthropic API format.
说明Notes
- 注意:该行为受运行时配置或底层实现影响,建议结合对应源码与版本说明确认。Note: Anthropic suggests always passing all previous thinking blocks back to the API in subsequent calls to maintain reasoning continuity. For more details, please refer to `Anthropic's documentation `_.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | list[Msg] | 消息列表(类型 `list[Msg]`)。The list of message objects to format. |
list[dict[str, Any]]
返回dict[str,任意]列表。`list[dict[str, Any]]`:
源码Source
agentscope/formatter/_anthropic_formatter.py:377–397