AS AgentScopeAPI 手册 / API Reference

GeminiMultiAgentFormatter

public class GeminiMultiAgentFormatter extends AbstractBaseFormatter< Content, GenerateContentResponse, GenerateContentConfig.Builder>
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:48–226

Gemini 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.

源码Source io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:66–68

GeminiMultiAgentFormatter

public GeminiMultiAgentFormatter(String conversationHistoryPrompt)

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

Create a GeminiMultiAgentFormatter with custom conversation history prompt.

参数Parameters
名称Name类型Type说明Description
conversationHistoryPromptString会话历史提示词(类型 `String`)。The prompt to prepend before conversation history
源码Source 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.

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

parseResponse

public ChatResponse parseResponse(GenerateContentResponse response, Instant startTime)

解析响应。

Parses the response.

参数Parameters
名称Name类型Type说明Description
responseGenerateContentResponse响应(类型 `GenerateContentResponse`)。The response.
startTimeInstant启动时间(类型 `Instant`)。The start time.
返回Returns ChatResponse
返回ChatResponse。Returns chat response.
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:132–135

applyOptions

public void applyOptions(GenerateContentConfig.Builder configBuilder, GenerateOptions options, GenerateOptions defaultOptions)

应用选项。

Performs the apply options operation.

参数Parameters
名称Name类型Type说明Description
configBuilderGenerateContentConfig.Builder配置构建器(类型 `GenerateContentConfig.Builder`)。The config builder.
optionsGenerateOptions选项(类型 `GenerateOptions`)。The options.
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。The default options.
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:137–144

applyTools

public void applyTools(GenerateContentConfig.Builder configBuilder, List<ToolSchema> tools)

应用工具。

Performs the apply tools operation.

参数Parameters
名称Name类型Type说明Description
configBuilderGenerateContentConfig.Builder配置构建器(类型 `GenerateContentConfig.Builder`)。The config builder.
toolsList<ToolSchema>工具列表(类型 `List`)。The tools.
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:146–149

applyToolChoice

public void applyToolChoice(GenerateContentConfig.Builder configBuilder, ToolChoice toolChoice)

应用工具选项。

Performs the apply tool choice operation.

参数Parameters
名称Name类型Type说明Description
configBuilderGenerateContentConfig.Builder配置构建器(类型 `GenerateContentConfig.Builder`)。The config builder.
toolChoiceToolChoice工具选项(类型 `ToolChoice`)。The tool choice.
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiMultiAgentFormatter.java:151–155
基于官方固定版本源码静态生成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.