类 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)
  • 构造器详细资料

    • GeminiMultiAgentFormatter

      public GeminiMultiAgentFormatter()
      Create a GeminiMultiAgentFormatter with default conversation history prompt.
    • GeminiMultiAgentFormatter

      public GeminiMultiAgentFormatter(String conversationHistoryPrompt)
      Create a GeminiMultiAgentFormatter with custom conversation history prompt.
      参数:
      conversationHistoryPrompt - The prompt to prepend before conversation history
  • 方法详细资料

    • doFormat

      protected List<com.google.genai.types.Content> doFormat(List<Msg> msgs)
      指定者:
      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)
      从接口复制的说明: Formatter
      Parse provider-specific response to AgentScope ChatResponse.
      参数:
      response - Provider-specific response object
      startTime - Request start time for calculating duration
      返回:
      AgentScope ChatResponse
    • applyOptions

      public void applyOptions(com.google.genai.types.GenerateContentConfig.Builder configBuilder, GenerateOptions options, GenerateOptions defaultOptions)
      从接口复制的说明: Formatter
      Apply generation options to provider-specific request parameters.
      参数:
      configBuilder - Provider-specific request parameters builder
      options - Generation options to apply
      defaultOptions - Default options to use if options parameter is null
    • applyTools

      public void applyTools(com.google.genai.types.GenerateContentConfig.Builder configBuilder, List<ToolSchema> tools)
      从接口复制的说明: Formatter
      Apply tool schemas to provider-specific request parameters.
      参数:
      configBuilder - Provider-specific request parameters builder
      tools - List of tool schemas to apply (may be null or empty)
    • applyToolChoice

      public void applyToolChoice(com.google.genai.types.GenerateContentConfig.Builder configBuilder, ToolChoice toolChoice)
      从接口复制的说明: Formatter
      Apply 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 builder
      toolChoice - Tool choice configuration (null means provider default)