ADK for TypeScript: API Reference
    Preparing search index...

    类型别名工具:`ToolOptions<TParameters>`

    用于创建基于函数的工具的配置选项。

    模型所展示的关于该工具的信息,是根据这些选项构建而成的。 name, description 以及 parameters 该模式(schema)实际上就是其函数声明(function declaration)本身。 TypeScript 的类型信息以及 JSDoc 的注释在运行时会被清除,因此无法再次被读取或使用。 description 这是必需的,每个参数的描述都必须包含在模式中(通常以 Zod 的格式表示)。 .describe() calls.

    new FunctionTool({
    name: 'get_weather',
    description: 'Returns the current weather for a city.',
    parameters: z.object({
    city: z.string().describe('City name, e.g. "San Francisco".'),
    }),
    execute: async ({city}) => fetchWeather(city),
    });

    一个子类可以在其继承自的类声明中添加额外的选项;在选项完全相同的情况下(即所有选项都相同的情况下), LongRunningFunctionTool 在……后面添加一个句子 description 告诉模型不要重新调用那些仍在执行中的(即尚未完成处理的)请求。

    parameters 这是对模型的描述;在调用该模型时,仅会强制执行 Zod 对象的规范(即 Zod 对象的结构要求)。详情请参见…… FunctionTool.runAsync.

    type ToolOptions<TParameters extends ToolInputParameters> = {
        description: string;
        execute: ToolExecuteFunction<TParameters>;
        isLongRunning?: boolean;
        name?: string;
        parameters?: TParameters;
        requireConfirmation?: RequireConfirmation<TParameters>;
        response?: SchemaLike;
    }

    类型参数(Type Parameters)

    description: string
    isLongRunning?: boolean
    name?: string
    parameters?: TParameters
    requireConfirmation?: RequireConfirmation<TParameters>

    该工具在运行前是否需要用户确认?返回一个布尔值(true/false);或者,可以对该工具的调用参数(已通过验证)及工具上下文信息进行判断,从而返回一个布尔值。

    当该工具通过某个特定方式被调用时,就会强制执行“HITL 规则”(即 HITL Gate)。 LlmAgent turn: agents/functions.ts (该短语在标准英语中并不常见,可能是拼写错误或特定领域的术语。如果是指“暴露出某种问题/情况”等含义,可译为:)“暴露出……” adk_request_confirmation 被该工具中断的(操作或流程) requestedToolConfirmations该工具仅在用户批准后(通过相应方式)才会执行一次。 RequestConfirmationLlmRequestProcessor).

    注意:这是一个工作流程(workflow)。 ToolNode 目前还没有通过该路径进行数据传输(或路由),因此…… requireConfirmation 直接用作节点的工具不会暂停执行;它会返回“需要确认”(requires confirmation)的错误作为其执行结果。工作流节点的审批流程尚未被实现(即:这些节点目前还不支持审批功能)。该工具的设计类似于 Python 的相关实现方式。 FunctionTool(require_confirmation=...).

    response?: SchemaLike

    可选的架构(schema),用于描述该工具返回的值。