类class
agentscope.formatterOpenAIResponseFormatter
class OpenAIResponseFormatter(_OpenAIResponseFormatterBase)
源码Source
agentscope/formatter/_openai_response_formatter.py:162–403OpenAIResponse 格式化器,在智能体、模型与前端之间传递结构化消息和事件。位于 agentscope.formatter 包,继承自 _OpenAIResponseFormatterBase。核心成员包括 format。
Produces input items compatible with client.responses.create(
input=...).
Compared with the Chat Completions format, the key differences are:
- Text content blocks use
input_textinstead oftext. - Image content blocks use
input_imageinstead ofimage_url. - Assistant tool-call messages become top-level
function_callitems. - Tool result messages become
function_call_outputitems. - Reasoning items (
ThinkingBlockwithreasoning_item_id) are echoed back verbatim as required by reasoning models (e.g.o1).
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def format(msgs: list[Msg]) -> list[dict[str, Any]]async | 设置格式。 Format message objects into OpenAI Response API input items. |
方法详情Method Detail
format
async def format(msgs: list[Msg]) -> list[dict[str, Any]]
async
设置格式。
Format message objects into OpenAI Response API input items.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | list[Msg] | 消息列表(类型 `list[Msg]`)。The list of Msg objects to format. |
list[dict[str, Any]]
返回dict[str,任意]列表。`list[dict[str, Any]]`:
源码Source
agentscope/formatter/_openai_response_formatter.py:178–403