AS AgentScopeAPI 手册 / API Reference

OpenAIMultiAgentFormatter

public class OpenAIMultiAgentFormatter extends OpenAIChatFormatter
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:42–224

OpenAI Multi 智能体格式化器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.openai.formatter 包,继承自 OpenAIChatFormatter。核心成员包括 doFormat、OpenAIMultiAgentFormatter。

Multi-agent formatter for OpenAI Chat Completion HTTP API. Converts AgentScope Msg objects to OpenAI DTO types with multi-agent support.

This formatter extends OpenAIChatFormatter and handles conversations between multiple agents by:

  • Grouping multi-agent messages into conversation history

  • Using special markup (e.g., history tags) to structure conversations

  • Consolidating multi-agent conversations into single user messages

Inherits all option, tool, and tool_choice handling from OpenAIChatFormatter.

构造器摘要Constructor Summary

构造器Constructor说明Description
public OpenAIMultiAgentFormatter()
创建OpenAIMultiAgentFormatter 使用默认会话历史提示词。
Create an OpenAIMultiAgentFormatter with default conversation history prompt.
public OpenAIMultiAgentFormatter(String conversationHistoryPrompt)
创建OpenAIMultiAgentFormatter 使用自定义会话历史提示词。
Create an OpenAIMultiAgentFormatter with custom conversation history prompt.

方法摘要Method Summary

方法Method说明Description
protected List<OpenAIMessage> doFormat(List<Msg> msgs)
执行格式操作。
Performs the do format operation.
protected List<OpenAIMessage> doFormat(List<Msg> msgs, GenerateOptions options)
执行格式操作。
Performs the do format operation.

构造器详情Constructor Detail

OpenAIMultiAgentFormatter

public OpenAIMultiAgentFormatter()

创建OpenAIMultiAgentFormatter 使用默认会话历史提示词。

Create an OpenAIMultiAgentFormatter with default conversation history prompt.

源码Source io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:54–56

OpenAIMultiAgentFormatter

public OpenAIMultiAgentFormatter(String conversationHistoryPrompt)

创建OpenAIMultiAgentFormatter 使用自定义会话历史提示词。

Create an OpenAIMultiAgentFormatter with custom conversation history prompt.

参数Parameters
名称Name类型Type说明Description
conversationHistoryPromptString会话历史提示词(类型 `String`)。The prompt to prepend before conversation history
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:63–66

方法详情Method Detail

doFormat

protected List<OpenAIMessage> doFormat(List<Msg> msgs)

执行格式操作。

Performs the do format operation.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。The msgs.
返回Returns List<OpenAIMessage>
返回列出。Returns list.
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:68–71

doFormat

protected List<OpenAIMessage> doFormat(List<Msg> msgs, GenerateOptions options)

执行格式操作。

Performs the do format operation.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。The msgs.
optionsGenerateOptions选项(类型 `GenerateOptions`)。The options.
返回Returns List<OpenAIMessage>
返回列出。Returns list.
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:73–113

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