类 GeminiResponseParser
java.lang.Object
io.agentscope.core.formatter.gemini.GeminiResponseParser
Parses Gemini API responses to AgentScope ChatResponse.
This parser handles the conversion of Gemini's GenerateContentResponse to AgentScope's ChatResponse format, including:
- Text blocks from text parts
- Thinking blocks from parts with thought=true flag
- Tool use blocks from function_call parts
- Usage metadata with token counts
Important: In Gemini API, thinking content is indicated by the "thought" flag on Part objects.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidparsePartsToBlocks(List<com.google.genai.types.Part> parts, List<ContentBlock> blocks) Parse Gemini Part objects to AgentScope ContentBlocks.parseResponse(com.google.genai.types.GenerateContentResponse response, Instant startTime) Parse Gemini GenerateContentResponse to AgentScope ChatResponse.protected voidparseToolCall(com.google.genai.types.FunctionCall functionCall, byte[] thoughtSignature, List<ContentBlock> blocks) Parse Gemini FunctionCall to ToolUseBlock.
-
构造器详细资料
-
GeminiResponseParser
public GeminiResponseParser()Creates a new GeminiResponseParser.
-
-
方法详细资料
-
parseResponse
public ChatResponse parseResponse(com.google.genai.types.GenerateContentResponse response, Instant startTime) Parse Gemini GenerateContentResponse to AgentScope ChatResponse.- 参数:
response- Gemini generation responsestartTime- Request start time for calculating duration- 返回:
- AgentScope ChatResponse
-
parsePartsToBlocks
protected void parsePartsToBlocks(List<com.google.genai.types.Part> parts, List<ContentBlock> blocks) Parse Gemini Part objects to AgentScope ContentBlocks. Order of block types: ThinkingBlock, TextBlock, ToolUseBlock- 参数:
parts- List of Gemini Part objectsblocks- List to add parsed ContentBlocks to
-
parseToolCall
protected void parseToolCall(com.google.genai.types.FunctionCall functionCall, byte[] thoughtSignature, List<ContentBlock> blocks) Parse Gemini FunctionCall to ToolUseBlock.- 参数:
functionCall- Gemini FunctionCall objectthoughtSignature- Thought signature from the Part (may be null)blocks- List to add parsed ToolUseBlock to
-