OpenAIMultiAgentFormatter
public class OpenAIMultiAgentFormatter extends OpenAIChatFormatter
io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:42–224OpenAI 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.
io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:54–56OpenAIMultiAgentFormatter
public OpenAIMultiAgentFormatter(String conversationHistoryPrompt)
创建OpenAIMultiAgentFormatter 使用自定义会话历史提示词。
Create an OpenAIMultiAgentFormatter with custom conversation history prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
conversationHistoryPrompt | String | 会话历史提示词(类型 `String`)。The prompt to prepend before conversation history |
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
List<OpenAIMessage>io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:68–71doFormat
protected List<OpenAIMessage> doFormat(List<Msg> msgs, GenerateOptions options)
执行格式操作。
Performs the do format operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
options | GenerateOptions | 选项(类型 `GenerateOptions`)。The options. |
List<OpenAIMessage>io/agentscope/extensions/model/openai/formatter/OpenAIMultiAgentFormatter.java:73–113