Class GeminiToolsHelper

java.lang.Object
io.agentscope.extensions.model.gemini.formatter.GeminiToolsHelper

public class GeminiToolsHelper extends Object
Handles tool registration and configuration for Gemini API.

This helper converts AgentScope tool schemas to Gemini's Tool and ToolConfig format:

  • Tool: Contains function declarations with JSON Schema parameters
  • ToolConfig: Contains function calling mode configuration

Tool Choice Mapping:

  • Auto: mode=AUTO (model decides)
  • None: mode=NONE (disable tool calling)
  • Required: mode=ANY (force tool call from all provided tools)
  • Specific: mode=ANY + allowedFunctionNames (force specific tool)
  • Constructor Details

    • GeminiToolsHelper

      public GeminiToolsHelper()
      Creates a new GeminiToolsHelper.
  • Method Details

    • convertToGeminiTool

      public com.google.genai.types.Tool convertToGeminiTool(List<io.agentscope.core.model.ToolSchema> tools)
      Convert AgentScope ToolSchema list to Gemini Tool object.
      Parameters:
      tools - List of tool schemas (may be null or empty)
      Returns:
      Gemini Tool object with function declarations, or null if no tools
    • convertToolChoice

      public com.google.genai.types.ToolConfig convertToolChoice(io.agentscope.core.model.ToolChoice toolChoice)
      Create Gemini ToolConfig from AgentScope ToolChoice.

      Tool choice mapping:

      • null or Auto: mode=AUTO (model decides)
      • None: mode=NONE (disable tool calling)
      • Required: mode=ANY (force tool call from all provided tools)
      • Specific: mode=ANY + allowedFunctionNames (force specific tool)
      Parameters:
      toolChoice - The tool choice configuration (null means auto)
      Returns:
      Gemini ToolConfig object, or null if auto (default behavior)