类 GeminiConversationMerger
java.lang.Object
io.agentscope.core.formatter.gemini.GeminiConversationMerger
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(String conversationHistoryPrompt) Create a GeminiConversationMerger with custom conversation history prompt. -
方法概要
-
构造器详细资料
-
GeminiConversationMerger
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 mergenameExtractor- Function to extract agent name from messagetoolResultConverter- Function to convert tool result blocks to stringshistoryPrompt- The prompt to prepend (empty if not first group)- 返回:
- Single merged Content for Gemini API
-