UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

59 lines (58 loc) 1.69 kB
import { BaseTool, BaseToolOptions, FunctionDeclaration } from './BaseTool'; import { ToolContext } from './ToolContext'; /** * Function to be executed by the FunctionTool */ export type ToolFunction = (params: Record<string, any>, context: ToolContext) => Promise<any>; /** * Options for creating a FunctionTool */ export interface FunctionToolOptions extends BaseToolOptions { /** * The function to execute */ fn: ToolFunction; /** * The function declaration schema */ functionDeclaration?: Record<string, any>; } /** * A tool that executes a provided function */ export declare class FunctionTool extends BaseTool { /** * The function to execute */ private fn; /** * The function declaration schema */ private functionDeclaration?; /** * Create a new function tool * @param options Options for the function tool */ constructor(options: FunctionToolOptions); /** * Internal method to get the function declaration * This overrides the protected method from BaseTool * * @returns The function declaration */ protected _getDeclaration(): FunctionDeclaration | null; /** * Get the function declaration for the tool * * @returns The function declaration */ getFunctionDeclaration(): Record<string, any>; /** * Execute the tool by calling the provided function * * @param params The parameters for the tool execution * @param context The context for the tool execution * @returns The result of the function execution */ execute(params: Record<string, any>, context: ToolContext): Promise<any>; }