UNPKG

adk-typescript

Version:

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

57 lines (56 loc) 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseRetrievalTool = void 0; const BaseTool_1 = require("../BaseTool"); /** * Base class for retrieval tools that search for information */ class BaseRetrievalTool extends BaseTool_1.BaseTool { /** * Create a new retrieval tool * * @param options Options for the retrieval tool */ constructor(options) { super(options); this.maxResults = options.maxResults || 5; } /** * Get the function declaration for retrieval tools * * @returns The function declaration */ _getDeclaration() { return { name: this.name, description: this.description, parameters: { type: 'object', properties: { query: { type: 'string', description: 'The query to retrieve information for.' }, maxResults: { type: 'integer', description: `Maximum number of results to return (default: ${this.maxResults}).` } }, required: ['query'] } }; } /** * Execute the retrieval tool * * @param params The parameters for the tool execution * @param context The context for the tool execution * @returns The result of the tool execution */ async execute(params, context) { const query = params.query; const maxResults = params.maxResults || this.maxResults; return this.retrieve(query, maxResults, context); } } exports.BaseRetrievalTool = BaseRetrievalTool;