类 GeminiConversationMerger

java.lang.Object
io.agentscope.core.formatter.gemini.GeminiConversationMerger

public class GeminiConversationMerger extends Object
Merges multi-agent conversation messages for Gemini API.

This class consolidates multiple agent messages into a single Content with conversation history wrapped in special tags. It preserves agent names and roles in the merged text.

Format:

 # Conversation History
 <history>
 ## AgentName (role)
 Agent message content...
 </history>
 
  • 构造器详细资料

    • GeminiConversationMerger

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

    • mergeToContent

      public com.google.genai.types.Content mergeToContent(List<Msg> msgs, Function<Msg,String> nameExtractor, Function<List<ContentBlock>,String> toolResultConverter, String historyPrompt)
      Merge conversation messages into a single Content (for Gemini API).

      This method combines all agent messages into a single "user" role Content with conversation history wrapped in <history> tags. Agent names and roles are embedded in the text.

      参数:
      msgs - List of conversation messages to merge
      nameExtractor - Function to extract agent name from message
      toolResultConverter - Function to convert tool result blocks to strings
      historyPrompt - The prompt to prepend (empty if not first group)
      返回:
      Single merged Content for Gemini API