AS AgentScopeAPI 手册 / API Reference

GeminiToolsHelper

public class GeminiToolsHelper
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiToolsHelper.java:47–138

Gemini 工具 Helper,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.gemini.formatter 包。核心成员包括 convertToGeminiTool、convertToolChoice、GeminiToolsHelper。

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 Summary

构造器Constructor说明Description
public GeminiToolsHelper()
创建新的GeminiToolsHelper。
Creates a new GeminiToolsHelper.

方法摘要Method Summary

方法Method说明Description
public Tool convertToGeminiTool(List<ToolSchema> tools)
转换 `convertToGeminiTool`。
Convert AgentScope ToolSchema list to Gemini Tool object.
public ToolConfig convertToolChoice(ToolChoice toolChoice)
转换工具选项。
Create Gemini ToolConfig from AgentScope ToolChoice.

构造器详情Constructor Detail

GeminiToolsHelper

public GeminiToolsHelper()

创建新的GeminiToolsHelper。

Creates a new GeminiToolsHelper.

源码Source io/agentscope/extensions/model/gemini/formatter/GeminiToolsHelper.java:52

方法详情Method Detail

convertToGeminiTool

public Tool convertToGeminiTool(List<ToolSchema> tools)

转换 convertToGeminiTool。

Convert AgentScope ToolSchema list to Gemini Tool object.

参数Parameters
名称Name类型Type说明Description
toolsList<ToolSchema>工具列表(类型 `List`)。List of tool schemas (may be null or empty)
返回Returns Tool
返回工具。Gemini Tool object with function declarations, or null if no tools
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiToolsHelper.java:60–87

convertToolChoice

public ToolConfig convertToolChoice(ToolChoice toolChoice)

转换工具选项。

Create Gemini ToolConfig from AgentScope ToolChoice.

参数Parameters
名称Name类型Type说明Description
toolChoiceToolChoice工具选项(类型 `ToolChoice`)。The tool choice configuration (null means auto)
返回Returns ToolConfig
返回ToolConfig。Gemini ToolConfig object, or null if auto (default behavior)
源码Source io/agentscope/extensions/model/gemini/formatter/GeminiToolsHelper.java:103–137
基于官方固定版本源码静态生成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.