类 GeminiMultiAgentFormatter
java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<com.google.genai.types.Content,com.google.genai.types.GenerateContentResponse,com.google.genai.types.GenerateContentConfig.Builder>
io.agentscope.core.formatter.gemini.GeminiMultiAgentFormatter
- 所有已实现的接口:
Formatter<com.google.genai.types.Content,com.google.genai.types.GenerateContentResponse, com.google.genai.types.GenerateContentConfig.Builder>
public class GeminiMultiAgentFormatter
extends AbstractBaseFormatter<com.google.genai.types.Content,com.google.genai.types.GenerateContentResponse,com.google.genai.types.GenerateContentConfig.Builder>
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)
-
构造器概要
构造器构造器说明Create a GeminiMultiAgentFormatter with default conversation history prompt.GeminiMultiAgentFormatter(String conversationHistoryPrompt) Create a GeminiMultiAgentFormatter with custom conversation history prompt. -
方法概要
修饰符和类型方法说明voidapplyOptions(com.google.genai.types.GenerateContentConfig.Builder configBuilder, GenerateOptions options, GenerateOptions defaultOptions) Apply generation options to provider-specific request parameters.voidapplyToolChoice(com.google.genai.types.GenerateContentConfig.Builder configBuilder, ToolChoice toolChoice) Apply tool choice configuration to provider-specific request parameters.voidapplyTools(com.google.genai.types.GenerateContentConfig.Builder configBuilder, List<ToolSchema> tools) Apply tool schemas to provider-specific request parameters.protected List<com.google.genai.types.Content> parseResponse(com.google.genai.types.GenerateContentResponse response, Instant startTime) Parse provider-specific response to AgentScope ChatResponse.从类继承的方法 io.agentscope.core.formatter.AbstractBaseFormatter
convertToolResultToString, extractTextContent, extractTextContent, format, formatRoleLabel, getOptionOrDefault, hasMediaContent, saveBase64DataToTempFile, shouldBypassHistory从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.formatter.Formatter
applyToolChoice, applyTools
-
构造器详细资料
-
GeminiMultiAgentFormatter
public GeminiMultiAgentFormatter()Create a GeminiMultiAgentFormatter with default conversation history prompt. -
GeminiMultiAgentFormatter
Create a GeminiMultiAgentFormatter with custom conversation history prompt.- 参数:
conversationHistoryPrompt- The prompt to prepend before conversation history
-
-
方法详细资料
-
doFormat
- 指定者:
doFormat在类中AbstractBaseFormatter<com.google.genai.types.Content,com.google.genai.types.GenerateContentResponse, com.google.genai.types.GenerateContentConfig.Builder>
-
parseResponse
public ChatResponse parseResponse(com.google.genai.types.GenerateContentResponse response, Instant startTime) 从接口复制的说明:FormatterParse provider-specific response to AgentScope ChatResponse.- 参数:
response- Provider-specific response objectstartTime- Request start time for calculating duration- 返回:
- AgentScope ChatResponse
-
applyOptions
public void applyOptions(com.google.genai.types.GenerateContentConfig.Builder configBuilder, GenerateOptions options, GenerateOptions defaultOptions) 从接口复制的说明:FormatterApply generation options to provider-specific request parameters.- 参数:
configBuilder- Provider-specific request parameters builderoptions- Generation options to applydefaultOptions- Default options to use if options parameter is null
-
applyTools
public void applyTools(com.google.genai.types.GenerateContentConfig.Builder configBuilder, List<ToolSchema> tools) 从接口复制的说明:FormatterApply tool schemas to provider-specific request parameters.- 参数:
configBuilder- Provider-specific request parameters buildertools- List of tool schemas to apply (may be null or empty)
-
applyToolChoice
public void applyToolChoice(com.google.genai.types.GenerateContentConfig.Builder configBuilder, ToolChoice toolChoice) 从接口复制的说明:FormatterApply tool choice configuration to provider-specific request parameters.This method controls how the model uses tools. The default implementation does nothing, allowing formatters to override for providers that support tool choice configuration.
- 参数:
configBuilder- Provider-specific request parameters buildertoolChoice- Tool choice configuration (null means provider default)
-