AS AgentScopeAPI 手册 / API Reference
类class agentscope.formatter

XAIChatFormatter

class XAIChatFormatter(FormatterBase)
源码Source agentscope/formatter/_xai_formatter.py:101–355

用于xAI 聊天模型的格式化器。位于 agentscope.formatter 包,继承自 FormatterBase。核心成员包括 format。

Converts Msg objects into xai_sdk protobuf Message objects that can be appended directly to a xai_sdk chat session.

Unlike other formatters whose format() returns list[dict], this formatter returns list[chat_pb2.Message]. The type annotation is intentionally widened to list[Any] to accommodate this difference.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
input_typeslist[str]
输入类型字段。
Field(default=['text/plain', 'image/jpeg', 'image/png'], description='The supported input types. Defaults to ``["text/plain", "image/jpeg", "image/png"]``.')

方法摘要Method Summary

方法Method说明Description
async def format(msgs: list[Msg], **kwargs: Any) -> List[Any]async
执行格式相关操作。
Convert a list of ``Msg`` objects to ``xai_sdk`` proto messages.

属性详情Attribute Detail

input_types

list[str] = Field(default=['text/plain', 'image/jpeg', 'image/png'], description='The supported input types. Defaults to ``["text/plain", "image/jpeg", "image/png"]``.')

输入类型字段。声明为 list[str]。

The supported input types.

源码Source agentscope/formatter/_xai_formatter.py:112

方法详情Method Detail

format

async def format(msgs: list[Msg], **kwargs: Any) -> List[Any]
async

执行格式相关操作。

Convert a list of Msg objects to xai_sdk proto messages.

参数Parameters
名称Name类型Type说明Description
msgslist[Msg]消息列表(类型 `list[Msg]`)。A list of `Msg` objects representing the conversation.
kwargsAny关键字参数(类型 `Any`)。The kwargs.
返回Returns List[Any]
返回任意列表。`list[Any]`:
源码Source agentscope/formatter/_xai_formatter.py:121–355

继承成员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.