GeminiMultiAgentFormatter
public class GeminiMultiAgentFormatter extends AbstractBaseFormatter< Content, GenerateContentResponse, GenerateContentConfig.Builder>
io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:48–226Gemini Multi 智能体格式化器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.gemini.formatter 包,继承自 AbstractBaseFormatter<Content, GenerateContentResponse, GenerateContentConfig.Builder>。核心成员包括 doFormat、parseResponse、applyOptions、applyTools、applyToolChoice、GeminiMultiAgentFormatter。
Gemini formatter for multi-agent conversations.
Converts AgentScope Msg objects to Gemini Content objects with multi-agent support. Collapses multi-agent conversation into a single user message with history tags.
Format Strategy:
-
System messages: Converted to user role (Gemini doesn't support system in contents)
-
Agent messages: Merged into single Content with
<history>tags -
Tool sequences: Converted directly (assistant with tool calls + user with tool results)
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public GeminiMultiAgentFormatter() | 创建GeminiMultiAgentFormatter 使用默认会话历史提示词。 Create a GeminiMultiAgentFormatter with default conversation history prompt. |
public GeminiMultiAgentFormatter(String conversationHistoryPrompt) | 创建GeminiMultiAgentFormatter 使用自定义会话历史提示词。 Create a GeminiMultiAgentFormatter with custom conversation history prompt. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
protected List<Content> doFormat(List<Msg> msgs) | 执行格式操作。 Performs the do format operation. |
public ChatResponse parseResponse(GenerateContentResponse response, Instant startTime) | 解析响应。 Parses the response. |
public void applyOptions(GenerateContentConfig.Builder configBuilder, GenerateOptions options, GenerateOptions defaultOptions) | 应用选项。 Performs the apply options operation. |
public void applyTools(GenerateContentConfig.Builder configBuilder, List<ToolSchema> tools) | 应用工具。 Performs the apply tools operation. |
public void applyToolChoice(GenerateContentConfig.Builder configBuilder, ToolChoice toolChoice) | 应用工具选项。 Performs the apply tool choice operation. |
构造器详情Constructor Detail
GeminiMultiAgentFormatter
public GeminiMultiAgentFormatter()
创建GeminiMultiAgentFormatter 使用默认会话历史提示词。
Create a GeminiMultiAgentFormatter with default conversation history prompt.
io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:66–68GeminiMultiAgentFormatter
public GeminiMultiAgentFormatter(String conversationHistoryPrompt)
创建GeminiMultiAgentFormatter 使用自定义会话历史提示词。
Create a GeminiMultiAgentFormatter with custom conversation history prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
conversationHistoryPrompt | String | 会话历史提示词(类型 `String`)。The prompt to prepend before conversation history |
io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:75–81方法详情Method Detail
doFormat
protected List<Content> doFormat(List<Msg> msgs)
执行格式操作。
Performs the do format operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
List<Content>io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:83–130parseResponse
public ChatResponse parseResponse(GenerateContentResponse response, Instant startTime)
解析响应。
Parses the response.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
response | GenerateContentResponse | 响应(类型 `GenerateContentResponse`)。The response. |
startTime | Instant | 启动时间(类型 `Instant`)。The start time. |
ChatResponseio/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:132–135applyOptions
public void applyOptions(GenerateContentConfig.Builder configBuilder, GenerateOptions options, GenerateOptions defaultOptions)
应用选项。
Performs the apply options operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
configBuilder | GenerateContentConfig.Builder | 配置构建器(类型 `GenerateContentConfig.Builder`)。The config builder. |
options | GenerateOptions | 选项(类型 `GenerateOptions`)。The options. |
defaultOptions | GenerateOptions | 默认选项(类型 `GenerateOptions`)。The default options. |
io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:137–144applyTools
public void applyTools(GenerateContentConfig.Builder configBuilder, List<ToolSchema> tools)
应用工具。
Performs the apply tools operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
configBuilder | GenerateContentConfig.Builder | 配置构建器(类型 `GenerateContentConfig.Builder`)。The config builder. |
tools | List<ToolSchema> | 工具列表(类型 `List`)。The tools. |
io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:146–149applyToolChoice
public void applyToolChoice(GenerateContentConfig.Builder configBuilder, ToolChoice toolChoice)
应用工具选项。
Performs the apply tool choice operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
configBuilder | GenerateContentConfig.Builder | 配置构建器(类型 `GenerateContentConfig.Builder`)。The config builder. |
toolChoice | ToolChoice | 工具选项(类型 `ToolChoice`)。The tool choice. |
io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:151–155