类 GeminiToolsHelper

java.lang.Object
io.agentscope.core.formatter.gemini.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)
  • 构造器详细资料

    • GeminiToolsHelper

      public GeminiToolsHelper()
      Creates a new GeminiToolsHelper.
  • 方法详细资料

    • convertToGeminiTool

      public com.google.genai.types.Tool convertToGeminiTool(List<ToolSchema> tools)
      Convert AgentScope ToolSchema list to Gemini Tool object.
      参数:
      tools - List of tool schemas (may be null or empty)
      返回:
      Gemini Tool object with function declarations, or null if no tools
    • convertParametersToSchema

      protected com.google.genai.types.Schema convertParametersToSchema(Map<String,Object> parameters)
      Convert parameters map to Gemini Schema object.
      参数:
      parameters - Parameter schema map (JSON Schema format)
      返回:
      Gemini Schema object
    • convertJsonTypeToGeminiType

      protected com.google.genai.types.Type convertJsonTypeToGeminiType(String jsonType)
      Convert JSON Schema type string to Gemini Type.
      参数:
      jsonType - JSON Schema type string (e.g., "object", "string", "number")
      返回:
      Gemini Type object
    • convertToolChoice

      public com.google.genai.types.ToolConfig convertToolChoice(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)
      参数:
      toolChoice - The tool choice configuration (null means auto)
      返回:
      Gemini ToolConfig object, or null if auto (default behavior)