AS AgentScopeAPI 手册 / API Reference

GeminiConversationMerger

public class GeminiConversationMerger
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiConversationMerger.java:51–182

Gemini 会话 Merger,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.gemini.formatter 包。核心成员包括 mergeToContent、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>

构造器摘要Constructor Summary

构造器Constructor说明Description
public GeminiConversationMerger(String conversationHistoryPrompt)
创建GeminiConversationMerger 使用自定义会话历史提示词。
Create a GeminiConversationMerger with custom conversation history prompt.

方法摘要Method Summary

方法Method说明Description
public 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).

构造器详情Constructor Detail

GeminiConversationMerger

public GeminiConversationMerger(String conversationHistoryPrompt)

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

Create a GeminiConversationMerger 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/GeminiConversationMerger.java:66–69

方法详情Method Detail

mergeToContent

public 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).

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。List of conversation messages to merge
nameExtractorFunction<Msg, String>名称 Extractor(类型 `Function`)。Function to extract agent name from message
toolResultConverterFunction<List<ContentBlock>, String>工具结果转换器(类型 `Function , String>`)。Function to convert tool result blocks to strings
historyPromptString历史提示词(类型 `String`)。The prompt to prepend (empty if not first group)
返回Returns Content
返回内容。Single merged Content for Gemini API
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiConversationMerger.java:84–181
基于官方固定版本源码静态生成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.